V0.8: backport of check primitive port count code.
This patch backports from multiple places checks that verify that the various primitives are given the correct number of port expressions.
This commit is contained in:
parent
918b0a410f
commit
27be6e88bc
136
elaborate.cc
136
elaborate.cc
|
|
@ -369,76 +369,212 @@ 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);
|
NetLogic::AND);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BUF:
|
case BUF:
|
||||||
|
if (pin_count() < 2) {
|
||||||
|
cerr << get_line() << ": error: the BUF "
|
||||||
|
"primitive must have an input." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return;
|
||||||
|
} else if (pin_count() > 2) {
|
||||||
|
cerr << get_line() << ": sorry: the BUF "
|
||||||
|
"primitive may only have one output in V0.8." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
||||||
NetLogic::BUF);
|
NetLogic::BUF);
|
||||||
|
}
|
||||||
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);
|
NetLogic::BUFIF0);
|
||||||
|
}
|
||||||
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);
|
NetLogic::BUFIF1);
|
||||||
|
}
|
||||||
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);
|
NetLogic::NAND);
|
||||||
|
}
|
||||||
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);
|
NetLogic::NMOS);
|
||||||
|
}
|
||||||
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);
|
NetLogic::NOR);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NOT:
|
case NOT:
|
||||||
|
if (pin_count() < 2) {
|
||||||
|
cerr << get_line() << ": error: the NOT "
|
||||||
|
"primitive must have an input." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return;
|
||||||
|
} else if (pin_count() > 2) {
|
||||||
|
cerr << get_line() << ": sorry: the NOT "
|
||||||
|
"primitive may only have one output in V0.8." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
||||||
NetLogic::NOT);
|
NetLogic::NOT);
|
||||||
|
}
|
||||||
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);
|
NetLogic::NOTIF0);
|
||||||
|
}
|
||||||
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);
|
NetLogic::NOTIF1);
|
||||||
|
}
|
||||||
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);
|
NetLogic::OR);
|
||||||
|
}
|
||||||
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);
|
NetLogic::RNMOS);
|
||||||
|
}
|
||||||
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);
|
NetLogic::RPMOS);
|
||||||
|
}
|
||||||
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);
|
NetLogic::PMOS);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PULLDOWN:
|
case PULLDOWN:
|
||||||
|
if (pin_count() != 1) {
|
||||||
|
cerr << get_line() << ": sorry: the PULLDOWN "
|
||||||
|
"primitive may only have one output in V0.8." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
||||||
NetLogic::PULLDOWN);
|
NetLogic::PULLDOWN);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PULLUP:
|
case PULLUP:
|
||||||
|
if (pin_count() != 1) {
|
||||||
|
cerr << get_line() << ": sorry: the PULLUP "
|
||||||
|
"primitive may only have one output in V0.8." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
cur[idx] = new NetLogic(scope, inm, pin_count(),
|
||||||
NetLogic::PULLUP);
|
NetLogic::PULLUP);
|
||||||
|
}
|
||||||
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);
|
NetLogic::XNOR);
|
||||||
|
}
|
||||||
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);
|
NetLogic::XOR);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cerr << get_line() << ": internal error: unhandled "
|
cerr << get_line() << ": internal error: unhandled "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue