mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-22 05:47:31 +02:00
Properly extend/crop a user function argument in a continuous assignment.
When passing an argument to a user function in a continuous assignment we need to sign extend the value if it is signed and too short. We need to crop an argument if it is too long.
This commit is contained in:
+9
-3
@@ -1413,9 +1413,15 @@ NetNet* NetEUFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
|
|||||||
/* Connect the pins to the arguments. */
|
/* Connect the pins to the arguments. */
|
||||||
NetFuncDef*def = func_->func_def();
|
NetFuncDef*def = func_->func_def();
|
||||||
for (unsigned idx = 0; idx < eparms.count(); idx += 1) {
|
for (unsigned idx = 0; idx < eparms.count(); idx += 1) {
|
||||||
NetNet*tmp = pad_to_width(des, eparms[idx],
|
unsigned width = def->port(idx)->vector_width();
|
||||||
def->port(idx)->vector_width(), *this);
|
NetNet*tmp;
|
||||||
connect(net->pin(idx+1), tmp->pin(0));
|
if (eparms[idx]->get_signed()) {
|
||||||
|
tmp = pad_to_width_signed(des, eparms[idx], width, *this);
|
||||||
|
} else {
|
||||||
|
tmp = pad_to_width(des, eparms[idx], width, *this);
|
||||||
|
}
|
||||||
|
NetNet*tmpc = crop_to_width(des, tmp, width);
|
||||||
|
connect(net->pin(idx+1), tmpc->pin(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return osig;
|
return osig;
|
||||||
|
|||||||
Reference in New Issue
Block a user