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:
parent
b3d828885c
commit
3ed6c0cfa4
|
|
@ -1415,9 +1415,15 @@ NetNet* NetEUFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
|
|||
/* Connect the pins to the arguments. */
|
||||
NetFuncDef*def = func_->func_def();
|
||||
for (unsigned idx = 0; idx < eparms.count(); idx += 1) {
|
||||
NetNet*tmp = pad_to_width(des, eparms[idx],
|
||||
def->port(idx)->vector_width(), *this);
|
||||
connect(net->pin(idx+1), tmp->pin(0));
|
||||
unsigned width = def->port(idx)->vector_width();
|
||||
NetNet*tmp;
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue