Add port checks for primitives.

This patch adds functionality to verify that primitives are given
an appropriate number of ports. For multiple output gates (but,
not, pulldown, pullup) it also reports that Icarus currently does
not support multiple outputs when more than one is given.
This commit is contained in:
Cary R 2007-09-03 19:47:32 -07:00 committed by Stephen Williams
parent 7c852aa075
commit d43cda3def
1 changed files with 161 additions and 40 deletions

View File

@ -442,82 +442,203 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
switch (type()) { switch (type()) {
case AND: case AND:
if (pin_count() < 2) {
cerr << get_line() << ": error: the AND "
"primitive must have an input." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::AND, instance_width); NetLogic::AND, instance_width);
break; break;
case BUF: case BUF:
if (pin_count() > 2) {
cerr << get_line() << ": sorry: multiple output BUF "
"primitives are not supported." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::BUF, instance_width); NetLogic::BUF, instance_width);
break; break;
case BUFIF0: case BUFIF0:
if (pin_count() != 3) {
cerr << get_line() << ": error: the BUFIF0 "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::BUFIF0, instance_width); NetLogic::BUFIF0, instance_width);
break; break;
case BUFIF1: case BUFIF1:
if (pin_count() != 3) {
cerr << get_line() << ": error: the BUFIF1 "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::BUFIF1, instance_width); NetLogic::BUFIF1, instance_width);
break; break;
case CMOS: case CMOS:
if (pin_count() != 4) {
cerr << get_line() << ": error: the CMOS "
"primitive must have four arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::CMOS, instance_width); NetLogic::CMOS, instance_width);
break; break;
case NAND: case NAND:
if (pin_count() < 2) {
cerr << get_line() << ": error: the NAND "
"primitive must have an input." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::NAND, instance_width); NetLogic::NAND, instance_width);
break; break;
case NMOS: case NMOS:
if (pin_count() != 3) {
cerr << get_line() << ": error: the NMOS "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::NMOS, instance_width); NetLogic::NMOS, instance_width);
break; break;
case NOR: case NOR:
if (pin_count() < 2) {
cerr << get_line() << ": error: the NOR "
"primitive must have an input." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::NOR, instance_width); NetLogic::NOR, instance_width);
break; break;
case NOT: case NOT:
if (pin_count() > 2) {
cerr << get_line() << ": sorry: multiple output NOT "
"primitives are not supported." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::NOT, instance_width); NetLogic::NOT, instance_width);
break; break;
case NOTIF0: case NOTIF0:
if (pin_count() != 3) {
cerr << get_line() << ": error: the NOTIF0 "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::NOTIF0, instance_width); NetLogic::NOTIF0, instance_width);
break; break;
case NOTIF1: case NOTIF1:
if (pin_count() != 3) {
cerr << get_line() << ": error: the NOTIF1 "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::NOTIF1, instance_width); NetLogic::NOTIF1, instance_width);
break; break;
case OR: case OR:
if (pin_count() < 2) {
cerr << get_line() << ": error: the OR "
"primitive must have an input." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::OR, instance_width); NetLogic::OR, instance_width);
break; break;
case RCMOS: case RCMOS:
if (pin_count() != 4) {
cerr << get_line() << ": error: the RCMOS "
"primitive must have four arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::RCMOS, instance_width); NetLogic::RCMOS, instance_width);
break; break;
case RNMOS: case RNMOS:
if (pin_count() != 3) {
cerr << get_line() << ": error: the RNMOS "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::RNMOS, instance_width); NetLogic::RNMOS, instance_width);
break; break;
case RPMOS: case RPMOS:
if (pin_count() != 3) {
cerr << get_line() << ": error: the RPMOS "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::RPMOS, instance_width); NetLogic::RPMOS, instance_width);
break; break;
case PMOS: case PMOS:
if (pin_count() != 3) {
cerr << get_line() << ": error: the PMOS "
"primitive must have three arguments." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::PMOS, instance_width); NetLogic::PMOS, instance_width);
break; break;
case PULLDOWN: case PULLDOWN:
if (pin_count() > 1) {
cerr << get_line() << ": sorry: multiple output PULLDOWN "
"primitives are not supported." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::PULLDOWN, instance_width); NetLogic::PULLDOWN,
instance_width);
break; break;
case PULLUP: case PULLUP:
if (pin_count() > 1) {
cerr << get_line() << ": sorry: multiple output PULLUP "
"primitives are not supported." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::PULLUP, instance_width); NetLogic::PULLUP, instance_width);
break; break;
case XNOR: case XNOR:
if (pin_count() < 2) {
cerr << get_line() << ": error: the XNOR "
"primitive must have an input." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::XNOR, instance_width); NetLogic::XNOR, instance_width);
break; break;
case XOR: case XOR:
if (pin_count() < 2) {
cerr << get_line() << ": error: the XOR "
"primitive must have an input." << endl;
des->errors += 1;
return;
} else
cur[idx] = new NetLogic(scope, inm, pin_count(), cur[idx] = new NetLogic(scope, inm, pin_count(),
NetLogic::XOR, instance_width); NetLogic::XOR, instance_width);
break; break;