mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-22 05:47:31 +02:00
Fix trimming of unsigned verinum values.
Incorrect trimming of unsigned verinum values was causing the compilers unsigned constant verinum pow function to give incorrect results. This patch restores the pow compile time optimization and fixes the trimming to always leave a single zero in the MSB.
This commit is contained in:
+1
-6
@@ -979,12 +979,7 @@ NetExpr* NetEBPow::eval_tree(int prune_to_width)
|
|||||||
verinum lval = lc->value();
|
verinum lval = lc->value();
|
||||||
verinum rval = rc->value();
|
verinum rval = rc->value();
|
||||||
|
|
||||||
if (lc->has_sign() || rc->has_sign()) {
|
return new NetEConst( pow(lval,rval) );
|
||||||
return new NetEConst( pow(lval,rval) );
|
|
||||||
} else {
|
|
||||||
return 0; // For now force this to the runtime.
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+9
-6
@@ -496,11 +496,15 @@ verinum trim_vnum(const verinum&that)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* If the result is unsigned and has an indefinite
|
/* If the result is unsigned and has an indefinite
|
||||||
length, then trim off leading zeros. */
|
length, then trim off all but one leading zero. */
|
||||||
tlen = 1;
|
unsigned top = that.len()-1;
|
||||||
for (unsigned idx = tlen ; idx < that.len() ; idx += 1)
|
while ((top > 0) && (that.get(top) == verinum::V0))
|
||||||
if (that.get(idx) != verinum::V0)
|
top -= 1;
|
||||||
tlen = idx+1;
|
tlen = top+2;
|
||||||
|
|
||||||
|
/* This can only happen when the verinum is all zeros,
|
||||||
|
so make it a single bit wide. */
|
||||||
|
if (that.get(top) == verinum::V0) tlen -= 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1211,4 +1215,3 @@ verinum::V operator ^ (verinum::V l, verinum::V r)
|
|||||||
|
|
||||||
return verinum::Vx;
|
return verinum::Vx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user