From b6d5a0675e71a1d9e95a5c6fe53bd1c9fa2192d0 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 7 Dec 2005 03:28:44 +0000 Subject: [PATCH] Support constant concatenation of constants. --- PExpr.h | 7 ++++++- eval.cc | 21 ++++++++++++++++++++- verinum.cc | 23 ++++++++++++++++++++++- verinum.h | 7 ++++++- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/PExpr.h b/PExpr.h index 04f7c1265..b6a6ca3c8 100644 --- a/PExpr.h +++ b/PExpr.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PExpr.h,v 1.66 2004/10/04 01:10:51 steve Exp $" +#ident "$Id: PExpr.h,v 1.66.2.1 2005/12/07 03:28:44 steve Exp $" #endif # include @@ -115,6 +115,8 @@ class PEConcat : public PExpr { PEConcat(const svector&p, PExpr*r =0); ~PEConcat(); + virtual verinum* eval_const(const Design*des, const NetScope*sc) const; + virtual void dump(ostream&) const; // Concatenated Regs can be on the left of procedural @@ -492,6 +494,9 @@ class PECallFunction : public PExpr { /* * $Log: PExpr.h,v $ + * Revision 1.66.2.1 2005/12/07 03:28:44 steve + * Support constant concatenation of constants. + * * Revision 1.66 2004/10/04 01:10:51 steve * Clean up spurious trailing white space. * diff --git a/eval.cc b/eval.cc index f4742f846..c8a6fe955 100644 --- a/eval.cc +++ b/eval.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: eval.cc,v 1.36 2003/06/21 01:21:43 steve Exp $" +#ident "$Id: eval.cc,v 1.36.2.1 2005/12/07 03:28:44 steve Exp $" #endif # include "config.h" @@ -143,6 +143,22 @@ verinum* PEBinary::eval_const(const Design*des, const NetScope*scope) const return res; } +verinum* PEConcat::eval_const(const Design*des, const NetScope*scope) const +{ + verinum*accum = parms_[0]->eval_const(des, scope); + if (accum == 0) + return 0; + + for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { + verinum*tmp = parms_[idx]->eval_const(des, scope); + assert(tmp); + + *accum = concat(*accum, *tmp); + delete tmp; + } + + return accum; +} /* * Evaluate an identifier as a constant expression. This is only @@ -240,6 +256,9 @@ verinum* PEUnary::eval_const(const Design*des, const NetScope*scope) const /* * $Log: eval.cc,v $ + * Revision 1.36.2.1 2005/12/07 03:28:44 steve + * Support constant concatenation of constants. + * * Revision 1.36 2003/06/21 01:21:43 steve * Harmless fixup of warnings. * diff --git a/verinum.cc b/verinum.cc index bd672a20c..262875183 100644 --- a/verinum.cc +++ b/verinum.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: verinum.cc,v 1.43.2.1 2005/08/13 00:45:55 steve Exp $" +#ident "$Id: verinum.cc,v 1.43.2.2 2005/12/07 03:28:44 steve Exp $" #endif # include "config.h" @@ -902,6 +902,24 @@ verinum operator % (const verinum&left, const verinum&right) return result; } +verinum concat(const verinum&left, const verinum&right) +{ + if (left.is_string() && right.is_string()) { + std::string tmp = left.as_string() + right.as_string(); + verinum res (tmp); + return res; + } + + verinum res (verinum::V0, left.len() + right.len()); + for (unsigned idx = 0 ; idx < right.len() ; idx += 1) + res.set(idx, right.get(idx)); + + for (unsigned idx = 0 ; idx < left.len() ; idx += 1) + res.set(idx+right.len(), left.get(idx)); + + return res; +} + verinum::V operator | (verinum::V l, verinum::V r) { if (l == verinum::V1) @@ -942,6 +960,9 @@ verinum::V operator ^ (verinum::V l, verinum::V r) /* * $Log: verinum.cc,v $ + * Revision 1.43.2.2 2005/12/07 03:28:44 steve + * Support constant concatenation of constants. + * * Revision 1.43.2.1 2005/08/13 00:45:55 steve * Fix compilation warnings/errors with newer compilers. * diff --git a/verinum.h b/verinum.h index cf48f9ad6..40b095ced 100644 --- a/verinum.h +++ b/verinum.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: verinum.h,v 1.26.2.2 2005/08/13 00:45:55 steve Exp $" +#ident "$Id: verinum.h,v 1.26.2.3 2005/12/07 03:28:45 steve Exp $" #endif # include @@ -144,11 +144,16 @@ extern verinum operator % (const verinum&left, const verinum&right); extern verinum operator<< (const verinum&left, unsigned shift); extern verinum operator>> (const verinum&left, unsigned shift); +extern verinum concat(const verinum&left, const verinum&right); + /* Bitwise not returns the ones complement. */ extern verinum v_not(const verinum&left); /* * $Log: verinum.h,v $ + * Revision 1.26.2.3 2005/12/07 03:28:45 steve + * Support constant concatenation of constants. + * * Revision 1.26.2.2 2005/08/13 00:45:55 steve * Fix compilation warnings/errors with newer compilers. *