Unary minus size assertion
Fix errors with unary subtraction producing logic gates with inconsistent widths. Signed-off-by: Stephen Williams <steve@wing.icarus.com>
This commit is contained in:
parent
4c8df2a370
commit
b2159d1e64
12
elab_net.cc
12
elab_net.cc
|
|
@ -2426,6 +2426,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
reduction=true; gtype = NetLogic::XNOR; break;
|
reduction=true; gtype = NetLogic::XNOR; break;
|
||||||
|
|
||||||
case '-': // Unary 2's complement.
|
case '-': // Unary 2's complement.
|
||||||
|
if (owidth == 0)
|
||||||
|
owidth = sub_sig->pin_count();
|
||||||
|
|
||||||
sig = new NetNet(scope, scope->local_symbol(),
|
sig = new NetNet(scope, scope->local_symbol(),
|
||||||
NetNet::WIRE, owidth);
|
NetNet::WIRE, owidth);
|
||||||
sig->local_flag(true);
|
sig->local_flag(true);
|
||||||
|
|
@ -2472,15 +2475,15 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
NetAddSub*sub = new NetAddSub(scope, scope->local_symbol(),
|
NetAddSub*sub = new NetAddSub(scope, scope->local_symbol(),
|
||||||
sig->pin_count());
|
owidth);
|
||||||
sub->attribute(perm_string::literal("LPM_Direction"), verinum("SUB"));
|
sub->attribute(perm_string::literal("LPM_Direction"), verinum("SUB"));
|
||||||
|
|
||||||
des->add_node(sub);
|
des->add_node(sub);
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < sig->pin_count(); idx += 1)
|
for (unsigned idx = 0 ; idx < owidth ; idx += 1)
|
||||||
connect(sig->pin(idx), sub->pin_Result(idx));
|
connect(sig->pin(idx), sub->pin_Result(idx));
|
||||||
|
|
||||||
for (unsigned idx = 0; idx < sub_sig->pin_count(); idx += 1)
|
for (unsigned idx = 0; idx < owidth; idx += 1)
|
||||||
connect(sub_sig->pin(idx), sub->pin_DataB(idx));
|
connect(sub_sig->pin(idx), sub->pin_DataB(idx));
|
||||||
|
|
||||||
verinum tmp_num (verinum::V0, sub->width(), true);
|
verinum tmp_num (verinum::V0, sub->width(), true);
|
||||||
|
|
@ -2490,8 +2493,7 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
des->add_node(tmp_con);
|
des->add_node(tmp_con);
|
||||||
|
|
||||||
NetNet*tmp_sig = new NetNet(scope, scope->local_symbol(),
|
NetNet*tmp_sig = new NetNet(scope, scope->local_symbol(),
|
||||||
NetNet::WIRE,
|
NetNet::WIRE, owidth);
|
||||||
sub_sig->pin_count());
|
|
||||||
tmp_sig->local_flag(true);
|
tmp_sig->local_flag(true);
|
||||||
|
|
||||||
for (unsigned idx = 0; idx < sig->pin_count(); idx += 1) {
|
for (unsigned idx = 0; idx < sig->pin_count(); idx += 1) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue