Disable width minimisation of literal numbers passed to system tasks.
The final step of expression elaboration is to reduce the width of lossless/unsized constant expressions to the minimum needed to hold the resulting constant value. This leads to unexpected results if the user supplies a literal number with redundant digits that gets passed to a system task that is sensitive to the width (e.g. $display). This patch prevents width reduction occurring in this case.
This commit is contained in:
parent
fb3969b5b8
commit
75b12151a4
|
|
@ -602,7 +602,11 @@ NetExpr* elab_sys_task_arg(Design*des, NetScope*scope, perm_string name,
|
|||
eval_expr(tmp, -1);
|
||||
|
||||
if (NetEConst*ce = dynamic_cast<NetEConst*>(tmp)) {
|
||||
if (mode != PExpr::SIZED)
|
||||
// For lossless/unsized constant expressions, we can now
|
||||
// determine the exact width required to hold the result.
|
||||
// But leave literal numbers exactly as the user supplied
|
||||
// them.
|
||||
if ((mode != PExpr::SIZED) && !dynamic_cast<PENumber*>(pe))
|
||||
ce->trim();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue