From 4288f3c6d05ddfd566910e36eff5a26a568de38a Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 15 Feb 2004 17:48:28 +0000 Subject: [PATCH] Better error checking of primitive tables. --- pform.cc | 72 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/pform.cc b/pform.cc index cf4b697e0..cac443eb0 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.cc,v 1.118 2003/07/04 03:57:19 steve Exp $" +#ident "$Id: pform.cc,v 1.119 2004/02/15 17:48:28 steve Exp $" #endif # include "config.h" @@ -423,18 +423,34 @@ void pform_make_udp(const char*name, list*parms, } if (pins[idx]->get_port_type() != NetNet::PINPUT) { cerr << file<<":"<get_wire_type() == NetNet::REG) { + cerr << file<<":"<get_wire_type() != NetNet::REG); } + if (local_errors > 0) { delete parms; delete decl; @@ -443,10 +459,21 @@ void pform_make_udp(const char*name, list*parms, return; } + bool synchronous_flag = pins[0]->get_wire_type() == NetNet::REG; + /* Interpret and check the table entry strings, to make sure they correspond to the inputs, output and output type. Make up vectors for the fully interpreted result that can be - placed in the PUdp object. */ + placed in the PUdp object. + + The table strings are made up by the parser to be two or + three substrings seperated by ';', i.e.: + + 0101:1:1 (synchronous device entry) + 0101:0 (combinational device entry) + + The parser doesn't check that we got the right kind here, + so this loop must watch out. */ svector input (table->size()); svector current (table->size()); svector output (table->size()); @@ -455,19 +482,39 @@ void pform_make_udp(const char*name, list*parms, ; cur != table->end() ; cur ++, idx += 1) { string tmp = *cur; - assert(tmp.find(':') == (pins.count() - 1)); + /* Pull the input values from the string. */ + assert(tmp.find(':') == (pins.count() - 1)); input[idx] = tmp.substr(0, pins.count()-1); tmp = tmp.substr(pins.count()-1); - if (pins[0]->get_wire_type() == NetNet::REG) { - assert(tmp[0] == ':'); + assert(tmp[0] == ':'); + + /* If this is a synchronous device, get the current + output string. */ + if (synchronous_flag) { + if (tmp.size() != 4) { + cerr << file<<":"<