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,84 +442,205 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
switch (type()) { switch (type()) {
case AND: case AND:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::AND, instance_width); 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(),
NetLogic::AND, instance_width);
break; break;
case BUF: case BUF:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() > 2) {
NetLogic::BUF, instance_width); 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(),
NetLogic::BUF, instance_width);
break; break;
case BUFIF0: case BUFIF0:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::BUFIF0, instance_width); 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(),
NetLogic::BUFIF0, instance_width);
break; break;
case BUFIF1: case BUFIF1:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::BUFIF1, instance_width); 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(),
NetLogic::BUFIF1, instance_width);
break; break;
case CMOS: case CMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 4) {
NetLogic::CMOS, instance_width); 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(),
NetLogic::CMOS, instance_width);
break; break;
case NAND: case NAND:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::NAND, instance_width); 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(),
NetLogic::NAND, instance_width);
break; break;
case NMOS: case NMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::NMOS, instance_width); 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(),
NetLogic::NMOS, instance_width);
break; break;
case NOR: case NOR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::NOR, instance_width); 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(),
NetLogic::NOR, instance_width);
break; break;
case NOT: case NOT:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() > 2) {
NetLogic::NOT, instance_width); 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(),
NetLogic::NOT, instance_width);
break; break;
case NOTIF0: case NOTIF0:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::NOTIF0, instance_width); 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(),
NetLogic::NOTIF0, instance_width);
break; break;
case NOTIF1: case NOTIF1:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::NOTIF1, instance_width); 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(),
NetLogic::NOTIF1, instance_width);
break; break;
case OR: case OR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::OR, instance_width); 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(),
NetLogic::OR, instance_width);
break; break;
case RCMOS: case RCMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 4) {
NetLogic::RCMOS, instance_width); 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(),
NetLogic::RCMOS, instance_width);
break; break;
case RNMOS: case RNMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::RNMOS, instance_width); 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(),
NetLogic::RNMOS, instance_width);
break; break;
case RPMOS: case RPMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::RPMOS, instance_width); 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(),
NetLogic::RPMOS, instance_width);
break; break;
case PMOS: case PMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::PMOS, instance_width); 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(),
NetLogic::PMOS, instance_width);
break; break;
case PULLDOWN: case PULLDOWN:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() > 1) {
NetLogic::PULLDOWN, instance_width); 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(),
NetLogic::PULLDOWN,
instance_width);
break; break;
case PULLUP: case PULLUP:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() > 1) {
NetLogic::PULLUP, instance_width); 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(),
NetLogic::PULLUP, instance_width);
break; break;
case XNOR: case XNOR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::XNOR, instance_width); 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(),
NetLogic::XNOR, instance_width);
break; break;
case XOR: case XOR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::XOR, instance_width); 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(),
NetLogic::XOR, instance_width);
break; break;
default: default:
cerr << get_line() << ": internal error: unhandled " cerr << get_line() << ": internal error: unhandled "