diff --git a/PExpr.cc b/PExpr.cc index db1e00a6b..f5b8f94ea 100644 --- a/PExpr.cc +++ b/PExpr.cc @@ -17,17 +17,35 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: PExpr.cc,v 1.1 1998/11/03 23:28:53 steve Exp $" +#ident "$Id: PExpr.cc,v 1.2 1998/11/11 00:01:51 steve Exp $" #endif # include "PExpr.h" +# include PExpr::~PExpr() { } +bool PExpr::is_the_same(const PExpr*that) const +{ + return typeid(this) == typeid(that); +} + +bool PENumber::is_the_same(const PExpr*that) const +{ + const PENumber*obj = dynamic_cast(that); + if (obj == 0) + return false; + + return *value_ == *obj->value_; +} + /* * $Log: PExpr.cc,v $ + * Revision 1.2 1998/11/11 00:01:51 steve + * Check net ranges in declarations. + * * Revision 1.1 1998/11/03 23:28:53 steve * Introduce verilog to CVS. * diff --git a/PExpr.h b/PExpr.h index 7e21d88b5..e2e84c272 100644 --- a/PExpr.h +++ b/PExpr.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: PExpr.h,v 1.3 1998/11/09 18:55:33 steve Exp $" +#ident "$Id: PExpr.h,v 1.4 1998/11/11 00:01:51 steve Exp $" #endif # include @@ -50,6 +50,11 @@ class PExpr { // a verinum as a result. If the expression cannot be // evaluated, return 0. virtual verinum* eval_const() const; + + // This method returns true if that expression is the same as + // this expression. This method is used for comparing + // expressions that must be structurally "identical". + virtual bool is_the_same(const PExpr*that) const; }; ostream& operator << (ostream&, const PExpr&); @@ -88,6 +93,8 @@ class PENumber : public PExpr { virtual NetExpr*elaborate_expr(Design*des, const string&path) const; virtual verinum* eval_const() const; + virtual bool is_the_same(const PExpr*that) const; + private: verinum*const value_; }; @@ -139,6 +146,9 @@ class PEBinary : public PExpr { /* * $Log: PExpr.h,v $ + * Revision 1.4 1998/11/11 00:01:51 steve + * Check net ranges in declarations. + * * Revision 1.3 1998/11/09 18:55:33 steve * Add procedural while loops, * Parse procedural for loops, diff --git a/parse.y b/parse.y index 77e0435ee..6ed8d0a51 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: parse.y,v 1.3 1998/11/09 18:55:34 steve Exp $" +#ident "$Id: parse.y,v 1.4 1998/11/11 00:01:51 steve Exp $" #endif # include "parse_misc.h" @@ -486,10 +486,10 @@ primitive ; range - : '[' NUMBER ':' NUMBER ']' + : '[' const_expression ':' const_expression ']' { list*tmp = new list; - tmp->push_back(new PENumber($2)); - tmp->push_back(new PENumber($4)); + tmp->push_back($2); + tmp->push_back($4); $$ = tmp; } ; diff --git a/pform.cc b/pform.cc index 357a60cdb..cb6538537 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: pform.cc,v 1.2 1998/11/07 17:05:06 steve Exp $" +#ident "$Id: pform.cc,v 1.3 1998/11/11 00:01:51 steve Exp $" #endif # include "pform.h" @@ -211,7 +211,14 @@ static void pform_set_net_range(const string&name, list*range) idx ++; cur->lsb = *idx; } else { - VLwarn(yylloc, "net ranges not checked."); + list::const_iterator idx = range->begin(); + PExpr*msb = *idx; + idx ++; + PExpr*lsb = *idx; + if (! (cur->msb->is_the_same(msb) && cur->lsb->is_the_same(lsb))) + VLerror(yylloc, "net ranges are not identical."); + delete msb; + delete lsb; } } @@ -286,6 +293,9 @@ int pform_parse(FILE*input, list&modules) /* * $Log: pform.cc,v $ + * Revision 1.3 1998/11/11 00:01:51 steve + * Check net ranges in declarations. + * * Revision 1.2 1998/11/07 17:05:06 steve * Handle procedural conditional, and some * of the conditional expressions. diff --git a/verinum.cc b/verinum.cc index 316b0d944..391e1b28f 100644 --- a/verinum.cc +++ b/verinum.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: verinum.cc,v 1.4 1998/11/09 19:03:26 steve Exp $" +#ident "$Id: verinum.cc,v 1.5 1998/11/11 00:01:51 steve Exp $" #endif # include "verinum.h" @@ -207,8 +207,23 @@ ostream& operator<< (ostream&o, const verinum&v) return o; } +bool operator == (const verinum&left, const verinum&right) +{ + if (left.len() != right.len()) + return false; + + for (unsigned idx = 0 ; idx < left.len() ; idx += 1) + if (left[idx] != right[idx]) + return false; + + return true; +} + /* * $Log: verinum.cc,v $ + * Revision 1.5 1998/11/11 00:01:51 steve + * Check net ranges in declarations. + * * Revision 1.4 1998/11/09 19:03:26 steve * Oops, forgot return from operator<< * diff --git a/verinum.h b/verinum.h index d25655356..a42162846 100644 --- a/verinum.h +++ b/verinum.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: verinum.h,v 1.2 1998/11/09 18:55:35 steve Exp $" +#ident "$Id: verinum.h,v 1.3 1998/11/11 00:01:51 steve Exp $" #endif # include @@ -73,11 +73,16 @@ class verinum { class ostream; -ostream& operator<< (ostream&, const verinum&); -ostream& operator<< (ostream&, verinum::V); +extern ostream& operator<< (ostream&, const verinum&); +extern ostream& operator<< (ostream&, verinum::V); + +extern bool operator == (const verinum&left, const verinum&right); /* * $Log: verinum.h,v $ + * Revision 1.3 1998/11/11 00:01:51 steve + * Check net ranges in declarations. + * * Revision 1.2 1998/11/09 18:55:35 steve * Add procedural while loops, * Parse procedural for loops,