From e8b4c5be857fe7ab56439d7004d77878da9f008b Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 8 Dec 2008 10:55:02 -0800 Subject: [PATCH] Check for too few buf/not port expressions. This patch adds code to check that buf and not primitives have at least two port expressions. An error message is printed for this case. --- elaborate.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 94cf46fec..5162e34d9 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -285,7 +285,8 @@ unsigned PGBuiltin::calculate_output_count_(void) const switch (type()) { case BUF: case NOT: - output_count = pin_count() - 1; + if (pin_count() > 2) output_count = pin_count() - 1; + else output_count = 1; break; case PULLDOWN: case PULLUP: @@ -319,8 +320,14 @@ NetNode* PGBuiltin::create_gate_for_output_(Design*des, NetScope*scope, break; case BUF: - gate = new NetLogic(scope, gate_name, 2, - NetLogic::BUF, instance_width); + if (pin_count() < 2) { + cerr << get_fileline() << ": error: the BUF " + "primitive must have an input." << endl; + des->errors += 1; + } else { + gate = new NetLogic(scope, gate_name, 2, + NetLogic::BUF, instance_width); + } break; case BUFIF0: @@ -390,8 +397,14 @@ NetNode* PGBuiltin::create_gate_for_output_(Design*des, NetScope*scope, break; case NOT: - gate = new NetLogic(scope, gate_name, 2, - NetLogic::NOT, instance_width); + if (pin_count() < 2) { + cerr << get_fileline() << ": error: the NOT " + "primitive must have an input." << endl; + des->errors += 1; + } else { + gate = new NetLogic(scope, gate_name, 2, + NetLogic::NOT, instance_width); + } break; case NOTIF0: