Skip to content

Commit

Permalink
Parse and elaborate the concatenate operator
Browse files Browse the repository at this point in the history
 in structural contexts, Replace vector<PExpr*>
 and list<PExpr*> with svector<PExpr*>, evaluate
 constant expressions with parameters, handle
 memories as lvalues.

 Parse task declarations, integer types.
  • Loading branch information
steve committed May 10, 1999
1 parent a416b1b commit 5de9b7c
Show file tree
Hide file tree
Showing 13 changed files with 468 additions and 154 deletions.
31 changes: 28 additions & 3 deletions 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.7 1999/05/01 02:57:52 steve Exp $"
#ident "$Id: PExpr.h,v 1.8 1999/05/10 00:16:57 steve Exp $"
#endif

# include <string>
Expand Down Expand Up @@ -51,7 +51,7 @@ class PExpr : public LineInfo {
// This attempts to evaluate a constant expression, and return
// a verinum as a result. If the expression cannot be
// evaluated, return 0.
virtual verinum* eval_const() const;
virtual verinum* eval_const(const Design*des, const string&path) const;

// This method returns true if that expression is the same as
// this expression. This method is used for comparing
Expand All @@ -61,6 +61,18 @@ class PExpr : public LineInfo {

ostream& operator << (ostream&, const PExpr&);

class PEConcat : public PExpr {

public:
PEConcat(const svector<PExpr*>&p) : parms_(p) { }

virtual void dump(ostream&) const;
virtual NetNet* elaborate_net(Design*des, const string&path) const;

private:
svector<PExpr*>parms_;
};

class PEEvent : public PExpr {

public:
Expand All @@ -87,7 +99,10 @@ class PEIdent : public PExpr {
virtual void dump(ostream&) const;
virtual NetNet* elaborate_net(Design*des, const string&path) const;
virtual NetExpr*elaborate_expr(Design*des, const string&path) const;
verinum* eval_const(const Design*des, const string&path) const;

// XXXX
string name() const { return text_; }

private:
string text_;
Expand All @@ -114,7 +129,7 @@ class PENumber : public PExpr {
virtual void dump(ostream&) const;
virtual NetNet* elaborate_net(Design*des, const string&path) const;
virtual NetExpr*elaborate_expr(Design*des, const string&path) const;
virtual verinum* eval_const() const;
virtual verinum* eval_const(const Design*des, const string&path) const;

virtual bool is_the_same(const PExpr*that) const;

Expand Down Expand Up @@ -160,6 +175,7 @@ class PEBinary : public PExpr {
virtual void dump(ostream&out) const;
virtual NetNet* elaborate_net(Design*des, const string&path) const;
virtual NetExpr*elaborate_expr(Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const string&path) const;

private:
char op_;
Expand All @@ -169,6 +185,15 @@ class PEBinary : public PExpr {

/*
* $Log: PExpr.h,v $
* Revision 1.8 1999/05/10 00:16:57 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.7 1999/05/01 02:57:52 steve
* Handle much more complex event expressions.
*
Expand Down
27 changes: 18 additions & 9 deletions PGate.h
Expand Up @@ -19,10 +19,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: PGate.h,v 1.4 1999/02/15 02:06:15 steve Exp $"
#ident "$Id: PGate.h,v 1.5 1999/05/10 00:16:58 steve Exp $"
#endif

# include <vector>
# include "svector.h"
# include "LineInfo.h"
class PExpr;
class PUdp;
Expand All @@ -41,7 +41,7 @@ class Module;
class PGate : public LineInfo {

public:
explicit PGate(const string&name, const vector<PExpr*>&pins, long del)
explicit PGate(const string&name, const svector<PExpr*>&pins, long del)
: name_(name), delay_(del), pins_(pins) { }

virtual ~PGate() { }
Expand All @@ -50,7 +50,7 @@ class PGate : public LineInfo {

long get_delay() const { return delay_; }

unsigned pin_count() const { return pins_.size(); }
unsigned pin_count() const { return pins_.count(); }
const PExpr*pin(unsigned idx) const { return pins_[idx]; }

virtual void dump(ostream&out) const;
Expand All @@ -62,7 +62,7 @@ class PGate : public LineInfo {
private:
const string name_;
const unsigned long delay_;
const vector<PExpr*> pins_;
svector<PExpr*> pins_;

private: // not implemented
PGate(const PGate&);
Expand All @@ -76,8 +76,8 @@ class PGate : public LineInfo {
class PGAssign : public PGate {

public:
explicit PGAssign(const vector<PExpr*>&pins)
: PGate("", pins, 0) { assert(pins.size() == 2); }
explicit PGAssign(const svector<PExpr*>&pins)
: PGate("", pins, 0) { assert(pins.count() == 2); }

void dump(ostream&out) const;
virtual void elaborate(Design*des, const string&path) const;
Expand Down Expand Up @@ -106,7 +106,7 @@ class PGBuiltin : public PGate {

public:
explicit PGBuiltin(Type t, const string&name,
const vector<PExpr*>&pins, long del = 0)
const svector<PExpr*>&pins, long del = 0)
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
{ }

Expand All @@ -133,7 +133,7 @@ class PGModule : public PGate {

public:
explicit PGModule(const string&type, const string&name,
const vector<PExpr*>&pins)
const svector<PExpr*>&pins)
: PGate(name, pins, 0), type_(type) { }

virtual void dump(ostream&out) const;
Expand All @@ -148,6 +148,15 @@ class PGModule : public PGate {

/*
* $Log: PGate.h,v $
* Revision 1.5 1999/05/10 00:16:58 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.4 1999/02/15 02:06:15 steve
* Elaborate gate ranges.
*
Expand Down
20 changes: 12 additions & 8 deletions Statement.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: Statement.cc,v 1.5 1999/02/03 04:20:11 steve Exp $"
#ident "$Id: Statement.cc,v 1.6 1999/05/10 00:16:58 steve Exp $"
#endif

# include "Statement.h"
Expand Down Expand Up @@ -47,14 +47,9 @@ PBlock::~PBlock()
delete[]list_;
}

PCallTask::PCallTask(const string&n, const list<PExpr*>&p)
: name_(n), nparms_(p.size()), parms_(nparms_?new PExpr*[nparms_]:0)
PCallTask::PCallTask(const string&n, const svector<PExpr*>&p)
: name_(n), parms_(p)
{
list<PExpr*>::const_iterator s = p.begin();
for (unsigned idx = 0 ; s != p.end() ; s++, idx += 1) {
parms_[idx] = *s;
}

}

PCase::PCase(PExpr*ex, list<PCase::Item*>*l)
Expand Down Expand Up @@ -104,6 +99,15 @@ PWhile::~PWhile()

/*
* $Log: Statement.cc,v $
* Revision 1.6 1999/05/10 00:16:58 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.5 1999/02/03 04:20:11 steve
* Parse and elaborate the Verilog CASE statement.
*
Expand Down
43 changes: 27 additions & 16 deletions Statement.h
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: Statement.h,v 1.7 1999/04/29 02:16:26 steve Exp $"
#ident "$Id: Statement.h,v 1.8 1999/05/10 00:16:58 steve Exp $"
#endif

# include <string>
Expand Down Expand Up @@ -79,18 +79,21 @@ class Statement : public LineInfo {
class PAssign : public Statement {

public:
explicit PAssign(const string&name, PExpr*ex)
: to_name_(name), expr_(ex) { }
explicit PAssign(PExpr*lval, PExpr*ex)
: lval_(lval), expr_(ex) { }

string lval() const { return to_name_; }
const PExpr* lval() const { return lval_; }
const PExpr* get_expr() const { return expr_; }

virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, const string&path) const;

private:
const string to_name_;
PExpr*const expr_;
PExpr* lval_;
PExpr* expr_;

NetProc*assign_to_memory_(class NetMemory*, PExpr*,
Design*des, const string&path) const;
};

/*
Expand Down Expand Up @@ -125,19 +128,19 @@ class PBlock : public Statement {
class PCallTask : public Statement {

public:
explicit PCallTask(const string&n, const list<PExpr*>&parms);
explicit PCallTask(const string&n, const svector<PExpr*>&parms);

string name() const { return name_; }

unsigned nparms() const { return nparms_; }
unsigned nparms() const { return parms_.count(); }

PExpr*&parm(unsigned idx)
{ assert(idx < nparms_);
{ assert(idx < parms_.count());
return parms_[idx];
}

PExpr* parm(unsigned idx) const
{ assert(idx < nparms_);
{ assert(idx < parms_.count());
return parms_[idx];
}

Expand All @@ -146,8 +149,7 @@ class PCallTask : public Statement {

private:
const string name_;
const unsigned nparms_;
PExpr**const parms_;
svector<PExpr*> parms_;
};

class PCase : public Statement {
Expand Down Expand Up @@ -232,8 +234,8 @@ class PEventStatement : public Statement {
class PForStatement : public Statement {

public:
PForStatement(const string&n1, PExpr*e1, PExpr*cond,
const string&n2, PExpr*e2, Statement*st)
PForStatement(PExpr*n1, PExpr*e1, PExpr*cond,
PExpr*n2, PExpr*e2, Statement*st)
: name1_(n1), expr1_(e1), cond_(cond), name2_(n2), expr2_(e2),
statement_(st)
{ }
Expand All @@ -242,12 +244,12 @@ class PForStatement : public Statement {
virtual void dump(ostream&out, unsigned ind) const;

private:
string name1_;
PExpr* name1_;
PExpr* expr1_;

PExpr*cond_;

string name2_;
PExpr* name2_;
PExpr* expr2_;

Statement*statement_;
Expand Down Expand Up @@ -276,6 +278,15 @@ class PWhile : public Statement {

/*
* $Log: Statement.h,v $
* Revision 1.8 1999/05/10 00:16:58 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.7 1999/04/29 02:16:26 steve
* Parse OR of event expressions.
*
Expand Down
23 changes: 22 additions & 1 deletion design_dump.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.22 1999/05/06 02:29:32 steve Exp $"
#ident "$Id: design_dump.cc,v 1.23 1999/05/10 00:16:58 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -300,6 +300,18 @@ void NetAssign::dump(ostream&o, unsigned ind) const
o << ";" << endl;
}

void NetAssignMem::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "";
o << "/* " << get_line() << " */" << endl;
o << setw(ind) << "";
o << mem_->name() << "[";
index_->dump(o);
o << "] = ";
rval_->dump(o);
o << ";" << endl;
}

/* Dump a block statement */
void NetBlock::dump(ostream&o, unsigned ind) const
{
Expand Down Expand Up @@ -568,6 +580,15 @@ void Design::dump(ostream&o) const

/*
* $Log: design_dump.cc,v $
* Revision 1.23 1999/05/10 00:16:58 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.22 1999/05/06 02:29:32 steve
* Excesss endl.
*
Expand Down

0 comments on commit 5de9b7c

Please sign in to comment.