Skip to content

Commit

Permalink
Handle procedural conditional, and some
Browse files Browse the repository at this point in the history
 of the conditional expressions.

 Elaborate signals and identifiers differently,
 allowing the netlist to hold signal information.
  • Loading branch information
steve committed Nov 7, 1998
1 parent 5836c8a commit b118634
Show file tree
Hide file tree
Showing 18 changed files with 496 additions and 41 deletions.
10 changes: 9 additions & 1 deletion PExpr.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: PExpr.h,v 1.1 1998/11/03 23:28:54 steve Exp $" #ident "$Id: PExpr.h,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


# include <string> # include <string>
Expand Down Expand Up @@ -128,6 +128,7 @@ class PEBinary : public PExpr {


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


private: private:
char op_; char op_;
Expand All @@ -137,6 +138,13 @@ class PEBinary : public PExpr {


/* /*
* $Log: PExpr.h,v $ * $Log: PExpr.h,v $
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:54 steve * Revision 1.1 1998/11/03 23:28:54 steve
* Introduce verilog to CVS. * Introduce verilog to CVS.
* *
Expand Down
16 changes: 15 additions & 1 deletion Statement.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: Statement.cc,v 1.1 1998/11/03 23:28:55 steve Exp $" #ident "$Id: Statement.cc,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


# include "Statement.h" # include "Statement.h"
Expand Down Expand Up @@ -57,9 +57,23 @@ PCallTask::PCallTask(const string&n, const list<PExpr*>&p)


} }


PCondit::~PCondit()
{
delete expr_;
delete if_;
delete else_;
}



/* /*
* $Log: Statement.cc,v $ * $Log: Statement.cc,v $
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:55 steve * Revision 1.1 1998/11/03 23:28:55 steve
* Introduce verilog to CVS. * Introduce verilog to CVS.
* *
Expand Down
29 changes: 28 additions & 1 deletion Statement.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: Statement.h,v 1.1 1998/11/03 23:28:56 steve Exp $" #ident "$Id: Statement.h,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


# include <string> # include <string>
Expand Down Expand Up @@ -146,6 +146,26 @@ class PCallTask : public Statement {
PExpr**const parms_; PExpr**const parms_;
}; };


class PCondit : public Statement {

public:
PCondit(PExpr*ex, Statement*i, Statement*e)
: expr_(ex), if_(i), else_(e) { }
~PCondit();

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

private:
PExpr*expr_;
Statement*if_;
Statement*else_;

private: // not implemented
PCondit(const PCondit&);
PCondit& operator= (const PCondit&);
};

class PDelayStatement : public Statement { class PDelayStatement : public Statement {


public: public:
Expand Down Expand Up @@ -186,6 +206,13 @@ class PNoop : public Statement {


/* /*
* $Log: Statement.h,v $ * $Log: Statement.h,v $
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:56 steve * Revision 1.1 1998/11/03 23:28:56 steve
* Introduce verilog to CVS. * Introduce verilog to CVS.
* *
Expand Down
44 changes: 43 additions & 1 deletion design_dump.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.1 1998/11/03 23:28:56 steve Exp $" #ident "$Id: design_dump.cc,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


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


void NetCondit::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "if (";
expr_->dump(o);
o << ")" << endl;
if_->dump(o, ind+4);
if (else_) {
o << setw(ind) << "" << "else" << endl;
else_->dump(o, ind+4);
}
}

void NetPDelay::dump(ostream&o, unsigned ind) const void NetPDelay::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "#" << delay_ << endl; o << setw(ind) << "" << "#" << delay_ << endl;
Expand Down Expand Up @@ -261,6 +273,24 @@ void NetExpr::dump(ostream&o) const
o << "(?)"; o << "(?)";
} }


void NetEBinary::dump(ostream&o) const
{
o << "(";
left_->dump(o);
o << ")";
switch (op_) {
default:
o << op_;
break;
case 'e':
o << "==";
break;
}
o << "(";
right_->dump(o);
o << ")";
}

void NetEConst::dump(ostream&o) const void NetEConst::dump(ostream&o) const
{ {
if (value_.is_string()) if (value_.is_string())
Expand All @@ -274,6 +304,11 @@ void NetEIdent::dump(ostream&o) const
o << name_; o << name_;
} }


void NetESignal::dump(ostream&o) const
{
o << sig_->name();
}

void NetEUnary::dump(ostream&o) const void NetEUnary::dump(ostream&o) const
{ {
o << op_ << "("; o << op_ << "(";
Expand Down Expand Up @@ -316,6 +351,13 @@ void Design::dump(ostream&o) const


/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:56 steve * Revision 1.1 1998/11/03 23:28:56 steve
* Introduce verilog to CVS. * Introduce verilog to CVS.
* *
Expand Down
37 changes: 32 additions & 5 deletions elaborate.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.1 1998/11/03 23:28:56 steve Exp $" #ident "$Id: elaborate.cc,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -54,7 +54,7 @@ static void do_assign(Design*des, const string&path,
connect(lval->pin(idx), tmp->pin(idx)); connect(lval->pin(idx), tmp->pin(idx));
delete tmp; delete tmp;


if (tmp = dynamic_cast<NetTmp*>(lval)) if ((tmp = dynamic_cast<NetTmp*>(lval)))
delete tmp; delete tmp;


} else if (NetTmp* tmp = dynamic_cast<NetTmp*>(lval)) { } else if (NetTmp* tmp = dynamic_cast<NetTmp*>(lval)) {
Expand Down Expand Up @@ -407,6 +407,12 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path) const
return sig; return sig;
} }


NetExpr* PEBinary::elaborate_expr(Design*des, const string&path) const
{
return new NetEBinary(op_, left_->elaborate_expr(des, path),
right_->elaborate_expr(des, path));
}

NetExpr* PENumber::elaborate_expr(Design*des, const string&path) const NetExpr* PENumber::elaborate_expr(Design*des, const string&path) const
{ {
assert(value_); assert(value_);
Expand All @@ -421,9 +427,13 @@ NetExpr* PEString::elaborate_expr(Design*des, const string&path) const
NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const
{ {
if (text_[0] == '$') if (text_[0] == '$')
return new NetEIdent(text_); return new NetEIdent(text_, 64);
else else {
return new NetEIdent(path+"."+text_); string name = path+"."+text_;
NetNet*net = des->find_signal(name);
assert(net);
return new NetESignal(net);
}
} }


NetExpr* PExpr::elaborate_expr(Design*des, const string&path) const NetExpr* PExpr::elaborate_expr(Design*des, const string&path) const
Expand Down Expand Up @@ -474,6 +484,16 @@ NetProc* PBlock::elaborate(Design*des, const string&path) const
return cur; return cur;
} }


NetProc* PCondit::elaborate(Design*des, const string&path) const
{
NetExpr*expr = expr_->elaborate_expr(des, path);
NetProc*i = if_->elaborate(des, path);
NetProc*e = else_->elaborate(des, path);

NetCondit*res = new NetCondit(expr, i, e);
return res;
}

NetProc* PCallTask::elaborate(Design*des, const string&path) const NetProc* PCallTask::elaborate(Design*des, const string&path) const
{ {
NetTask*cur = new NetTask(name(), nparms()); NetTask*cur = new NetTask(name(), nparms());
Expand Down Expand Up @@ -598,6 +618,13 @@ Design* elaborate(const list<Module*>&modules, const string&root)


/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:56 steve * Revision 1.1 1998/11/03 23:28:56 steve
* Introduce verilog to CVS. * Introduce verilog to CVS.
* *
Expand Down
36 changes: 35 additions & 1 deletion emit.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: emit.cc,v 1.1 1998/11/03 23:28:57 steve Exp $" #ident "$Id: emit.cc,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


/* /*
Expand Down Expand Up @@ -79,6 +79,11 @@ void NetBlock::emit_proc(ostream&o, struct target_t*tgt) const
tgt->proc_block(o, this); tgt->proc_block(o, this);
} }


void NetCondit::emit_proc(ostream&o, struct target_t*tgt) const
{
tgt->proc_condit(o, this);
}

void NetPDelay::emit_proc(ostream&o, struct target_t*tgt) const void NetPDelay::emit_proc(ostream&o, struct target_t*tgt) const
{ {
tgt->proc_delay(o, this); tgt->proc_delay(o, this);
Expand Down Expand Up @@ -116,6 +121,18 @@ void NetBlock::emit_recurse(ostream&o, struct target_t*tgt) const
} while (cur != last_); } while (cur != last_);
} }


void NetCondit::emit_recurse_if(ostream&o, struct target_t*tgt) const
{
if (if_)
if_->emit_proc(o, tgt);
}

void NetCondit::emit_recurse_else(ostream&o, struct target_t*tgt) const
{
if (else_)
else_->emit_proc(o, tgt);
}

void Design::emit(ostream&o, struct target_t*tgt) const void Design::emit(ostream&o, struct target_t*tgt) const
{ {
tgt->start_design(o, this); tgt->start_design(o, this);
Expand Down Expand Up @@ -147,6 +164,11 @@ void Design::emit(ostream&o, struct target_t*tgt) const
tgt->end_design(o, this); tgt->end_design(o, this);
} }


void NetEBinary::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_binary(this);
}

void NetEConst::expr_scan(struct expr_scan_t*tgt) const void NetEConst::expr_scan(struct expr_scan_t*tgt) const
{ {
tgt->expr_const(this); tgt->expr_const(this);
Expand All @@ -157,6 +179,11 @@ void NetEIdent::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_ident(this); tgt->expr_ident(this);
} }


void NetESignal::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_signal(this);
}

void NetEUnary::expr_scan(struct expr_scan_t*tgt) const void NetEUnary::expr_scan(struct expr_scan_t*tgt) const
{ {
tgt->expr_unary(this); tgt->expr_unary(this);
Expand All @@ -176,6 +203,13 @@ void emit(ostream&o, const Design*des, const char*type)


/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:57 steve * Revision 1.1 1998/11/03 23:28:57 steve
* Introduce verilog to CVS. * Introduce verilog to CVS.
* *
Expand Down
6 changes: 5 additions & 1 deletion lexor.lex
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.1 1998/11/03 23:28:59 steve Exp $" #ident "$Id: lexor.lex,v 1.2 1998/11/07 17:05:05 steve Exp $"
#endif #endif


//# define YYSTYPE lexval //# define YYSTYPE lexval
Expand Down Expand Up @@ -63,6 +63,10 @@ static verinum*make_sized_hex(const char*txt);


"<=" { return K_LE; } "<=" { return K_LE; }
">=" { return K_GE; } ">=" { return K_GE; }
"==" { return K_EQ; }
"!=" { return K_NE; }
"===" { return K_CEQ; }
"!==" { return K_CNE; }


[;:\[\],()#=.@&!<|^~+-] { return yytext[0]; } [;:\[\],()#=.@&!<|^~+-] { return yytext[0]; }


Expand Down
Loading

0 comments on commit b118634

Please sign in to comment.