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()) { switch (type()) {
case AND: case AND:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::AND); 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; break;
case BUF: case BUF:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::BUF); 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; break;
case BUFIF0: case BUFIF0:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::BUFIF0); 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; break;
case BUFIF1: case BUFIF1:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::BUFIF1); 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; break;
case NAND: case NAND:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::NAND); 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; break;
case NMOS: case NMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::NMOS); 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; break;
case NOR: case NOR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::NOR); 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; break;
case NOT: case NOT:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::NOT); 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; break;
case NOTIF0: case NOTIF0:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::NOTIF0); 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; break;
case NOTIF1: case NOTIF1:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::NOTIF1); 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; break;
case OR: case OR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::OR); 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; break;
case RNMOS: case RNMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::RNMOS); 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; break;
case RPMOS: case RPMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::RPMOS); 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; break;
case PMOS: case PMOS:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 3) {
NetLogic::PMOS); 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; break;
case PULLDOWN: case PULLDOWN:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 1) {
NetLogic::PULLDOWN); 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; break;
case PULLUP: case PULLUP:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() != 1) {
NetLogic::PULLUP); 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; break;
case XNOR: case XNOR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::XNOR); 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; break;
case XOR: case XOR:
cur[idx] = new NetLogic(scope, inm, pin_count(), if (pin_count() < 2) {
NetLogic::XOR); 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; break;
default: default:
cerr << get_line() << ": internal error: unhandled " cerr << get_line() << ": internal error: unhandled "