Permalink
Browse files

Handle procedural conditional, and some

 of the conditional expressions.

 Elaborate signals and identifiers differently,
 allowing the netlist to hold signal information.
  • Loading branch information...
1 parent 5836c8a commit b118634189abb5845e4c02f5b956a32c965b4cfc steve committed Nov 7, 1998
Showing with 496 additions and 41 deletions.
  1. +9 −1 PExpr.h
  2. +15 −1 Statement.cc
  3. +28 −1 Statement.h
  4. +43 −1 design_dump.cc
  5. +32 −5 elaborate.cc
  6. +35 −1 emit.cc
  7. +5 −1 lexor.lex
  8. +8 −2 main.cc
  9. +26 −1 netlist.cc
  10. +82 −9 netlist.h
  11. +31 −2 parse.y
  12. +13 −1 parse_misc.cc
  13. +9 −1 parse_misc.h
  14. +14 −2 pform.cc
  15. +36 −2 pform_dump.cc
  16. +72 −8 t-vvm.cc
  17. +27 −1 target.cc
  18. +11 −1 target.h
View
10 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.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
# include <string>
@@ -128,6 +128,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;
private:
char op_;
@@ -137,6 +138,13 @@ class PEBinary : public PExpr {
/*
* $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
* Introduce verilog to CVS.
*
View
@@ -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.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
# include "Statement.h"
@@ -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 $
+ * 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
* Introduce verilog to CVS.
*
View
@@ -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.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
# include <string>
@@ -146,6 +146,26 @@ class PCallTask : public Statement {
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 {
public:
@@ -186,6 +206,13 @@ class PNoop : public Statement {
/*
* $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
* Introduce verilog to CVS.
*
View
@@ -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.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
/*
@@ -202,6 +202,18 @@ void NetBlock::dump(ostream&o, unsigned ind) const
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
{
o << setw(ind) << "" << "#" << delay_ << endl;
@@ -261,6 +273,24 @@ void NetExpr::dump(ostream&o) const
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
{
if (value_.is_string())
@@ -274,6 +304,11 @@ void NetEIdent::dump(ostream&o) const
o << name_;
}
+void NetESignal::dump(ostream&o) const
+{
+ o << sig_->name();
+}
+
void NetEUnary::dump(ostream&o) const
{
o << op_ << "(";
@@ -316,6 +351,13 @@ void Design::dump(ostream&o) const
/*
* $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
* Introduce verilog to CVS.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
/*
@@ -54,7 +54,7 @@ static void do_assign(Design*des, const string&path,
connect(lval->pin(idx), tmp->pin(idx));
delete tmp;
- if (tmp = dynamic_cast<NetTmp*>(lval))
+ if ((tmp = dynamic_cast<NetTmp*>(lval)))
delete tmp;
} else if (NetTmp* tmp = dynamic_cast<NetTmp*>(lval)) {
@@ -407,6 +407,12 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path) const
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
{
assert(value_);
@@ -421,9 +427,13 @@ NetExpr* PEString::elaborate_expr(Design*des, const string&path) const
NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const
{
if (text_[0] == '$')
- return new NetEIdent(text_);
- else
- return new NetEIdent(path+"."+text_);
+ return new NetEIdent(text_, 64);
+ else {
+ 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
@@ -474,6 +484,16 @@ NetProc* PBlock::elaborate(Design*des, const string&path) const
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
{
NetTask*cur = new NetTask(name(), nparms());
@@ -598,6 +618,13 @@ Design* elaborate(const list<Module*>&modules, const string&root)
/*
* $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
* Introduce verilog to CVS.
*
View
36 emit.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
/*
@@ -79,6 +79,11 @@ void NetBlock::emit_proc(ostream&o, struct target_t*tgt) const
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
{
tgt->proc_delay(o, this);
@@ -116,6 +121,18 @@ void NetBlock::emit_recurse(ostream&o, struct target_t*tgt) const
} 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
{
tgt->start_design(o, this);
@@ -147,6 +164,11 @@ void Design::emit(ostream&o, struct target_t*tgt) const
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
{
tgt->expr_const(this);
@@ -157,6 +179,11 @@ void NetEIdent::expr_scan(struct expr_scan_t*tgt) const
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
{
tgt->expr_unary(this);
@@ -176,6 +203,13 @@ void emit(ostream&o, const Design*des, const char*type)
/*
* $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
* Introduce verilog to CVS.
*
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#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
//# define YYSTYPE lexval
@@ -63,6 +63,10 @@ static verinum*make_sized_hex(const char*txt);
"<=" { return K_LE; }
">=" { return K_GE; }
+"==" { return K_EQ; }
+"!=" { return K_NE; }
+"===" { return K_CEQ; }
+"!==" { return K_CNE; }
[;:\[\],()#=.@&!<|^~+-] { return yytext[0]; }
Oops, something went wrong.

0 comments on commit b118634

Please sign in to comment.