Code cleanup from Larry.
This commit is contained in:
parent
69cfdbdc54
commit
9ee0210cac
237
elab_net.cc
237
elab_net.cc
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: elab_net.cc,v 1.131 2004/06/22 18:41:48 steve Exp $"
|
#ident "$Id: elab_net.cc,v 1.132 2004/06/24 15:22:23 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -244,15 +244,8 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, NetScope*scope,
|
||||||
gate->decay_time(decay);
|
gate->decay_time(decay);
|
||||||
des->add_node(gate);
|
des->add_node(gate);
|
||||||
|
|
||||||
switch (op_) {
|
gate->attribute(perm_string::literal("LPM_Direction"),
|
||||||
case '+':
|
verinum(op_ == '+' ? "ADD" : "SUB"));
|
||||||
gate->attribute(perm_string::literal("LPM_Direction"), verinum("ADD"));
|
|
||||||
break;
|
|
||||||
case '-':
|
|
||||||
gate->attribute(perm_string::literal("LPM_Direction"), verinum("SUB"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return osig;
|
return osig;
|
||||||
}
|
}
|
||||||
|
|
@ -303,11 +296,20 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope,
|
||||||
lsig->pin_count());
|
lsig->pin_count());
|
||||||
osig->local_flag(true);
|
osig->local_flag(true);
|
||||||
|
|
||||||
|
NetLogic::TYPE gtype=NetLogic::AND;
|
||||||
switch (op_) {
|
switch (op_) {
|
||||||
case '^': // XOR
|
case '^': gtype = NetLogic::XOR; break; // XOR
|
||||||
|
case 'X': gtype = NetLogic::XNOR; break; // XNOR
|
||||||
|
case '&': gtype = NetLogic::AND; break; // AND
|
||||||
|
case 'A': gtype = NetLogic::NAND; break; // NAND (~&)
|
||||||
|
case '|': gtype = NetLogic::OR; break; // Bitwise OR
|
||||||
|
case 'O': gtype = NetLogic::NOR; break; // Bitwise NOR
|
||||||
|
default: assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
||||||
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
||||||
3, NetLogic::XOR);
|
3, gtype);
|
||||||
connect(gate->pin(1), lsig->pin(idx));
|
connect(gate->pin(1), lsig->pin(idx));
|
||||||
connect(gate->pin(2), rsig->pin(idx));
|
connect(gate->pin(2), rsig->pin(idx));
|
||||||
connect(gate->pin(0), osig->pin(idx));
|
connect(gate->pin(0), osig->pin(idx));
|
||||||
|
|
@ -316,82 +318,6 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope,
|
||||||
gate->decay_time(decay);
|
gate->decay_time(decay);
|
||||||
des->add_node(gate);
|
des->add_node(gate);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case 'X': // XNOR
|
|
||||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
|
||||||
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
3, NetLogic::XNOR);
|
|
||||||
connect(gate->pin(1), lsig->pin(idx));
|
|
||||||
connect(gate->pin(2), rsig->pin(idx));
|
|
||||||
connect(gate->pin(0), osig->pin(idx));
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
des->add_node(gate);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '&': // AND
|
|
||||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
|
||||||
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
3, NetLogic::AND);
|
|
||||||
connect(gate->pin(1), lsig->pin(idx));
|
|
||||||
connect(gate->pin(2), rsig->pin(idx));
|
|
||||||
connect(gate->pin(0), osig->pin(idx));
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
des->add_node(gate);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'A': // NAND (~&)
|
|
||||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
|
||||||
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
3, NetLogic::NAND);
|
|
||||||
connect(gate->pin(1), lsig->pin(idx));
|
|
||||||
connect(gate->pin(2), rsig->pin(idx));
|
|
||||||
connect(gate->pin(0), osig->pin(idx));
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
des->add_node(gate);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '|': // Bitwise OR
|
|
||||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
|
||||||
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
3, NetLogic::OR);
|
|
||||||
connect(gate->pin(1), lsig->pin(idx));
|
|
||||||
connect(gate->pin(2), rsig->pin(idx));
|
|
||||||
connect(gate->pin(0), osig->pin(idx));
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
des->add_node(gate);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'O': // Bitwise NOR
|
|
||||||
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) {
|
|
||||||
NetLogic*gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
3, NetLogic::NOR);
|
|
||||||
connect(gate->pin(1), lsig->pin(idx));
|
|
||||||
connect(gate->pin(2), rsig->pin(idx));
|
|
||||||
connect(gate->pin(0), osig->pin(idx));
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
des->add_node(gate);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return osig;
|
return osig;
|
||||||
}
|
}
|
||||||
|
|
@ -464,20 +390,14 @@ static NetNet* compare_eq_constant(Design*des, NetScope*scope,
|
||||||
will put the invert on that instead. */
|
will put the invert on that instead. */
|
||||||
NetLogic*zero_gate = 0;
|
NetLogic*zero_gate = 0;
|
||||||
NetLogic*ones_gate = 0;
|
NetLogic*ones_gate = 0;
|
||||||
if (zeros > 0 && op_code == 'e')
|
if (zeros > 0)
|
||||||
zero_gate = new NetLogic(scope, scope->local_symbol(),
|
zero_gate = new NetLogic(scope,
|
||||||
zeros + 1, NetLogic::NOR);
|
scope->local_symbol(), zeros + 1,
|
||||||
if (zeros > 0 && op_code == 'n')
|
(op_code == 'n') ? NetLogic::OR : NetLogic::NOR);
|
||||||
zero_gate = new NetLogic(scope, scope->local_symbol(),
|
if (ones > 0)
|
||||||
zeros + 1,
|
ones_gate = new NetLogic(scope,
|
||||||
ones > 0? NetLogic::NOR : NetLogic::OR);
|
scope->local_symbol(), ones + 1,
|
||||||
if (ones > 0 && op_code == 'e')
|
(op_code == 'n') ? NetLogic::NAND : NetLogic::AND);
|
||||||
ones_gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
ones + 1, NetLogic::AND);
|
|
||||||
if (ones > 0 && op_code == 'n')
|
|
||||||
ones_gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
ones + 1,
|
|
||||||
zeros > 0? NetLogic::AND : NetLogic::NAND);
|
|
||||||
|
|
||||||
unsigned zidx = 0;
|
unsigned zidx = 0;
|
||||||
unsigned oidx = 0;
|
unsigned oidx = 0;
|
||||||
|
|
@ -504,7 +424,7 @@ static NetNet* compare_eq_constant(Design*des, NetScope*scope,
|
||||||
connect(and_sig->pin(1), ones_gate->pin(0));
|
connect(and_sig->pin(1), ones_gate->pin(0));
|
||||||
NetLogic*and_gate = new NetLogic(scope,
|
NetLogic*and_gate = new NetLogic(scope,
|
||||||
scope->local_symbol(), 3,
|
scope->local_symbol(), 3,
|
||||||
op_code == 'n'? NetLogic::NAND : NetLogic::AND);
|
(op_code == 'n') ? NetLogic::OR : NetLogic::AND);
|
||||||
connect(and_gate->pin(0), osig->pin(0));
|
connect(and_gate->pin(0), osig->pin(0));
|
||||||
connect(and_gate->pin(1), and_sig->pin(0));
|
connect(and_gate->pin(1), and_sig->pin(0));
|
||||||
connect(and_gate->pin(2), and_sig->pin(1));
|
connect(and_gate->pin(2), and_sig->pin(1));
|
||||||
|
|
@ -2368,7 +2288,7 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetNet* sig;
|
NetNet* sig = 0;
|
||||||
NetLogic*gate;
|
NetLogic*gate;
|
||||||
|
|
||||||
// Handle the special case of a 2's complement of a constant
|
// Handle the special case of a 2's complement of a constant
|
||||||
|
|
@ -2407,6 +2327,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
assert(sub_sig);
|
assert(sub_sig);
|
||||||
|
|
||||||
|
bool reduction=false;
|
||||||
|
NetLogic::TYPE gtype = NetLogic::AND;
|
||||||
|
|
||||||
switch (op_) {
|
switch (op_) {
|
||||||
case '~': // Bitwise NOT
|
case '~': // Bitwise NOT
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE,
|
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE,
|
||||||
|
|
@ -2426,95 +2349,17 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
|
|
||||||
case 'N': // Reduction NOR
|
case 'N': // Reduction NOR
|
||||||
case '!': // Reduction NOT
|
case '!': // Reduction NOT
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
reduction=true; gtype = NetLogic::NOR; break;
|
||||||
sig->local_flag(true);
|
|
||||||
gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
1+sub_sig->pin_count(), NetLogic::NOR);
|
|
||||||
connect(gate->pin(0), sig->pin(0));
|
|
||||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
|
||||||
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
|
||||||
|
|
||||||
des->add_node(gate);
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '&': // Reduction AND
|
case '&': // Reduction AND
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
reduction=true; gtype = NetLogic::AND; break;
|
||||||
sig->local_flag(true);
|
|
||||||
gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
1+sub_sig->pin_count(), NetLogic::AND);
|
|
||||||
connect(gate->pin(0), sig->pin(0));
|
|
||||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
|
||||||
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
|
||||||
|
|
||||||
des->add_node(gate);
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '|': // Reduction OR
|
case '|': // Reduction OR
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
reduction=true; gtype = NetLogic::OR; break;
|
||||||
sig->local_flag(true);
|
|
||||||
gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
1+sub_sig->pin_count(), NetLogic::OR);
|
|
||||||
connect(gate->pin(0), sig->pin(0));
|
|
||||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
|
||||||
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
|
||||||
|
|
||||||
des->add_node(gate);
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '^': // Reduction XOR
|
case '^': // Reduction XOR
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
reduction=true; gtype = NetLogic::XOR; break;
|
||||||
sig->local_flag(true);
|
|
||||||
gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
1+sub_sig->pin_count(), NetLogic::XOR);
|
|
||||||
connect(gate->pin(0), sig->pin(0));
|
|
||||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
|
||||||
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
|
||||||
|
|
||||||
des->add_node(gate);
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'A': // Reduction NAND (~&)
|
case 'A': // Reduction NAND (~&)
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
reduction=true; gtype = NetLogic::NAND; break;
|
||||||
sig->local_flag(true);
|
|
||||||
gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
1+sub_sig->pin_count(), NetLogic::NAND);
|
|
||||||
connect(gate->pin(0), sig->pin(0));
|
|
||||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
|
||||||
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
|
||||||
|
|
||||||
des->add_node(gate);
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case 'X': // Reduction XNOR (~^)
|
case 'X': // Reduction XNOR (~^)
|
||||||
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
reduction=true; gtype = NetLogic::XNOR; break;
|
||||||
sig->local_flag(true);
|
|
||||||
gate = new NetLogic(scope, scope->local_symbol(),
|
|
||||||
1+sub_sig->pin_count(), NetLogic::XNOR);
|
|
||||||
connect(gate->pin(0), sig->pin(0));
|
|
||||||
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
|
||||||
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
|
||||||
|
|
||||||
des->add_node(gate);
|
|
||||||
gate->rise_time(rise);
|
|
||||||
gate->fall_time(fall);
|
|
||||||
gate->decay_time(decay);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-': // Unary 2's complement.
|
case '-': // Unary 2's complement.
|
||||||
sig = new NetNet(scope, scope->local_symbol(),
|
sig = new NetNet(scope, scope->local_symbol(),
|
||||||
|
|
@ -2597,13 +2442,29 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
|
||||||
cerr << "internal error: Unhandled UNARY '" << op_ << "'" << endl;
|
cerr << "internal error: Unhandled UNARY '" << op_ << "'" << endl;
|
||||||
sig = 0;
|
sig = 0;
|
||||||
}
|
}
|
||||||
|
if (reduction) {
|
||||||
|
sig = new NetNet(scope, scope->local_symbol(), NetNet::WIRE);
|
||||||
|
sig->local_flag(true);
|
||||||
|
gate = new NetLogic(scope, scope->local_symbol(),
|
||||||
|
1+sub_sig->pin_count(), gtype);
|
||||||
|
connect(gate->pin(0), sig->pin(0));
|
||||||
|
for (unsigned idx = 0 ; idx < sub_sig->pin_count() ; idx += 1)
|
||||||
|
connect(gate->pin(idx+1), sub_sig->pin(idx));
|
||||||
|
|
||||||
|
des->add_node(gate);
|
||||||
|
gate->rise_time(rise);
|
||||||
|
gate->fall_time(fall);
|
||||||
|
gate->decay_time(decay);
|
||||||
|
}
|
||||||
|
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elab_net.cc,v $
|
* $Log: elab_net.cc,v $
|
||||||
|
* Revision 1.132 2004/06/24 15:22:23 steve
|
||||||
|
* Code cleanup from Larry.
|
||||||
|
*
|
||||||
* Revision 1.131 2004/06/22 18:41:48 steve
|
* Revision 1.131 2004/06/22 18:41:48 steve
|
||||||
* Fix broken calcuation of NE for constant.
|
* Fix broken calcuation of NE for constant.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue