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:
parent
7c852aa075
commit
d43cda3def
123
elaborate.cc
123
elaborate.cc
|
|
@ -442,82 +442,203 @@ void PGBuiltin::elaborate(Design*des, NetScope*scope) const
|
|||
|
||||
switch (type()) {
|
||||
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(),
|
||||
NetLogic::AND, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::BUF, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::BUFIF0, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::BUFIF1, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::CMOS, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::NAND, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::NMOS, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::NOR, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::NOT, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::NOTIF0, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::NOTIF1, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::OR, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::RCMOS, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::RNMOS, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::RPMOS, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::PMOS, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::PULLDOWN, instance_width);
|
||||
NetLogic::PULLDOWN,
|
||||
instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::PULLUP, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::XNOR, instance_width);
|
||||
break;
|
||||
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(),
|
||||
NetLogic::XOR, instance_width);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue