Check net ranges in declarations.
This commit is contained in:
parent
7859de1e4e
commit
d27f260bc1
20
PExpr.cc
20
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 <typeinfo>
|
||||
|
||||
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<const PENumber*>(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.
|
||||
*
|
||||
|
|
|
|||
12
PExpr.h
12
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 <string>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
8
parse.y
8
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<PExpr*>*tmp = new list<PExpr*>;
|
||||
tmp->push_back(new PENumber($2));
|
||||
tmp->push_back(new PENumber($4));
|
||||
tmp->push_back($2);
|
||||
tmp->push_back($4);
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
|
|
|||
14
pform.cc
14
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<PExpr*>*range)
|
|||
idx ++;
|
||||
cur->lsb = *idx;
|
||||
} else {
|
||||
VLwarn(yylloc, "net ranges not checked.");
|
||||
list<PExpr*>::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<Module*>&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.
|
||||
|
|
|
|||
17
verinum.cc
17
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<<
|
||||
*
|
||||
|
|
|
|||
11
verinum.h
11
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 <string>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue