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:
Cary R 2008-12-09 18:41:09 -08:00 committed by Stephen Williams
parent 918b0a410f
commit 27be6e88bc
1 changed files with 172 additions and 36 deletions

View File

@ -369,76 +369,212 @@ 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);
}
break;
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(),
NetLogic::BUF);
}
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);
}
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);
}
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);
}
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);
}
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);
}
break;
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(),
NetLogic::NOT);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
break;
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(),
NetLogic::PULLDOWN);
}
break;
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(),
NetLogic::PULLUP);
}
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);
}
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);
}
break;
default:
cerr << get_line() << ": internal error: unhandled "