Allow constant concat expressions.
This commit is contained in:
parent
5cf64dfa70
commit
101b373293
6
PExpr.h
6
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.74 2005/11/27 17:01:56 steve Exp $"
|
||||
#ident "$Id: PExpr.h,v 1.75 2005/12/07 04:04:23 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <string>
|
||||
|
|
@ -122,6 +122,7 @@ class PEConcat : public PExpr {
|
|||
PEConcat(const svector<PExpr*>&p, PExpr*r =0);
|
||||
~PEConcat();
|
||||
|
||||
virtual verinum* eval_const(const Design*des, NetScope*sc) const;
|
||||
virtual void dump(ostream&) const;
|
||||
|
||||
virtual NetNet* elaborate_lnet(Design*des, NetScope*scope,
|
||||
|
|
@ -545,6 +546,9 @@ class PECallFunction : public PExpr {
|
|||
|
||||
/*
|
||||
* $Log: PExpr.h,v $
|
||||
* Revision 1.75 2005/12/07 04:04:23 steve
|
||||
* Allow constant concat expressions.
|
||||
*
|
||||
* Revision 1.74 2005/11/27 17:01:56 steve
|
||||
* Fix for stubborn compiler.
|
||||
*
|
||||
|
|
|
|||
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.38 2005/11/27 17:01:57 steve Exp $"
|
||||
#ident "$Id: eval.cc,v 1.39 2005/12/07 04:04:23 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -143,6 +143,22 @@ verinum* PEBinary::eval_const(const Design*des, NetScope*scope) const
|
|||
delete r;
|
||||
return res;
|
||||
}
|
||||
verinum* PEConcat::eval_const(const Design*des, 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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -247,6 +263,9 @@ verinum* PEUnary::eval_const(const Design*des, NetScope*scope) const
|
|||
|
||||
/*
|
||||
* $Log: eval.cc,v $
|
||||
* Revision 1.39 2005/12/07 04:04:23 steve
|
||||
* Allow constant concat expressions.
|
||||
*
|
||||
* Revision 1.38 2005/11/27 17:01:57 steve
|
||||
* Fix for stubborn compiler.
|
||||
*
|
||||
|
|
|
|||
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 2004/05/18 18:43:15 steve Exp $"
|
||||
#ident "$Id: verinum.cc,v 1.44 2005/12/07 04:04:24 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.44 2005/12/07 04:04:24 steve
|
||||
* Allow constant concat expressions.
|
||||
*
|
||||
* Revision 1.43 2004/05/18 18:43:15 steve
|
||||
* Handle null string as a single nul character.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.27 2005/06/14 19:13:43 steve Exp $"
|
||||
#ident "$Id: verinum.h,v 1.28 2005/12/07 04:04:24 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.28 2005/12/07 04:04:24 steve
|
||||
* Allow constant concat expressions.
|
||||
*
|
||||
* Revision 1.27 2005/06/14 19:13:43 steve
|
||||
* gcc3/4 compile errors.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue