Support constant concatenation of constants.
This commit is contained in:
parent
e63e830d62
commit
b6d5a0675e
7
PExpr.h
7
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 <string>
|
||||
|
|
@ -115,6 +115,8 @@ class PEConcat : public PExpr {
|
|||
PEConcat(const svector<PExpr*>&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.
|
||||
*
|
||||
|
|
|
|||
21
eval.cc
21
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.
|
||||
*
|
||||
|
|
|
|||
23
verinum.cc
23
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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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 <string>
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue