Skip to content

Commit

Permalink
Check net ranges in declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Nov 11, 1998
1 parent 7859de1 commit d27f260
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 12 deletions.
20 changes: 19 additions & 1 deletion PExpr.cc
Expand Up @@ -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.
*
Expand Down
12 changes: 11 additions & 1 deletion PExpr.h
Expand Up @@ -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>
Expand Down Expand Up @@ -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&);
Expand Down Expand Up @@ -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_;
};
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions parse.y
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
;
Expand Down
14 changes: 12 additions & 2 deletions pform.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 16 additions & 1 deletion verinum.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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<<
*
Expand Down
11 changes: 8 additions & 3 deletions verinum.h
Expand Up @@ -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>
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d27f260

Please sign in to comment.