Permalink
Browse files

Support localparam.

  • Loading branch information...
steve
steve committed Mar 12, 2000
1 parent 79f7722 commit 6eef54595f0441257ba7eeee487065359eaf08ed
Showing with 218 additions and 259 deletions.
  1. +1 −0 .cvsignore
  2. +7 −1 Makefile.in
  3. +19 −1 Module.cc
  4. +9 −5 Module.h
  5. +6 −0 README.txt
  6. +10 −1 design_dump.cc
  7. +23 −1 elab_scope.cc
  8. +6 −4 lexor.lex
  9. +0 −230 lexor_keyword.cc
  10. +14 −5 lexor_keyword.gperf
  11. +33 −0 lexor_keyword.h
  12. +22 −5 netlist.cc
  13. +6 −1 netlist.h
  14. +34 −2 parse.y
  15. +10 −1 pform.cc
  16. +5 −1 pform.h
  17. +13 −1 pform_dump.cc
View
@@ -1,3 +1,4 @@
+lexor_keyword.cc
parse.h
parse.cc
parse.cc.output
View
@@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.37 2000/03/08 04:36:53 steve Exp $"
+#ident "$Id: Makefile.in,v 1.38 2000/03/12 17:09:40 steve Exp $"
#
#
SHELL = /bin/sh
@@ -119,6 +119,12 @@ parse.h parse.cc: $(srcdir)/parse.y
lexor.cc: $(srcdir)/lexor.lex
flex -PVL -s -olexor.cc $(srcdir)/lexor.lex
+lexor_keyword.o dep/lexor_keyword.d: lexor_keyword.cc
+
+lexor_keyword.cc: lexor_keyword.gperf
+ gperf -o -i 1 -C -k 1-3,$$ -L ANSI-C -H keyword_hash -N check_identifier -t lexor_keyword.gperf > lexor_keyword.cc
+
+
install: all installdirs $(bindir)/verilog $(bindir)/gverilog $(libdir)/ivl/ivl $(mandir)/man1/verilog.1
cd vpi ; $(MAKE) install
cd vvm ; $(MAKE) install
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: Module.cc,v 1.10 2000/02/23 02:56:53 steve Exp $"
+#ident "$Id: Module.cc,v 1.11 2000/03/12 17:09:40 steve Exp $"
#endif
# include "Module.h"
@@ -126,9 +126,27 @@ PGate* Module::get_gate(const string&name)
return 0;
}
+const map<string,PWire*>& Module::get_wires() const
+{
+ return wires_;
+}
+
+const list<PGate*>& Module::get_gates() const
+{
+ return gates_;
+}
+
+const list<PProcess*>& Module::get_behaviors() const
+{
+ return behaviors_;
+}
+
/*
* $Log: Module.cc,v $
+ * Revision 1.11 2000/03/12 17:09:40 steve
+ * Support localparam.
+ *
* Revision 1.10 2000/02/23 02:56:53 steve
* Macintosh compilers do not support ident.
*
View
@@ -1,7 +1,7 @@
#ifndef __Module_H
#define __Module_H
/*
- * Copyright (c) 1998 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: Module.h,v 1.15 2000/03/08 04:36:53 steve Exp $"
+#ident "$Id: Module.h,v 1.16 2000/03/12 17:09:40 steve Exp $"
#endif
# include <list>
@@ -65,6 +65,7 @@ class Module {
module is elaborated. During parsing, I put the parameters
into this map. */
map<string,PExpr*>parameters;
+ map<string,PExpr*>localparams;
/* The module also has defparam assignments which don't create
new parameters within the module, but may be used to set
@@ -102,9 +103,9 @@ class Module {
PWire* get_wire(const string&name) const;
PGate* get_gate(const string&name);
- const map<string,PWire*>& get_wires() const { return wires_; }
- const list<PGate*>& get_gates() const { return gates_; }
- const list<PProcess*>& get_behaviors() const { return behaviors_; }
+ const map<string,PWire*>& get_wires() const;
+ const list<PGate*>& get_gates() const;
+ const list<PProcess*>& get_behaviors() const;
void dump(ostream&out) const;
bool elaborate(Design*, NetScope*scope) const;
@@ -129,6 +130,9 @@ class Module {
/*
* $Log: Module.h,v $
+ * Revision 1.16 2000/03/12 17:09:40 steve
+ * Support localparam.
+ *
* Revision 1.15 2000/03/08 04:36:53 steve
* Redesign the implementation of scopes and parameters.
* I now generate the scopes and notice the parameters
View
@@ -42,6 +42,12 @@ on a UNIX-like system:
- bison
+ - gperf 2.7
+ The lexical analyzer doesn't recognize keywords directly,
+ but instead matches symbols and looks them up in a hash
+ table in order to get the proper lexical code. The gperf
+ program generates the lookup table.
+
2.2 Compilation
Unpack the tar-ball and cd into the verilog-######### directory
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: design_dump.cc,v 1.68 2000/03/08 04:36:53 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.69 2000/03/12 17:09:40 steve Exp $"
#endif
/*
@@ -616,6 +616,12 @@ void NetScope::dump(ostream&o) const
o << " parameter " << (*pp).first << " = " <<
*(*pp).second << ";" << endl;
}
+
+ for (pp = localparams_.begin()
+ ; pp != localparams_.end() ; pp ++) {
+ o << " localparam " << (*pp).first << " = " <<
+ *(*pp).second << ";" << endl;
+ }
}
/* Dump the saved defparam assignments here. */
@@ -886,6 +892,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.69 2000/03/12 17:09:40 steve
+ * Support localparam.
+ *
* Revision 1.68 2000/03/08 04:36:53 steve
* Redesign the implementation of scopes and parameters.
* I now generate the scopes and notice the parameters
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: elab_scope.cc,v 1.2 2000/03/11 03:25:52 steve Exp $"
+#ident "$Id: elab_scope.cc,v 1.3 2000/03/12 17:09:41 steve Exp $"
#endif
/*
@@ -60,6 +60,13 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
scope->set_parameter((*cur).first, new NetEParam);
}
+ for (mparm_it_t cur = localparams.begin()
+ ; cur != localparams.end() ; cur ++) {
+
+ scope->set_parameter((*cur).first, new NetEParam);
+ }
+
+
// Now scan the parameters again, this time elaborating them
// for use as parameter values. This is after the previous
// scan so that local parameter names can be used in the
@@ -77,6 +84,18 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
delete val;
}
+ for (mparm_it_t cur = localparams.begin()
+ ; cur != localparams.end() ; cur ++) {
+
+ PExpr*ex = (*cur).second;
+ assert(ex);
+
+ NetExpr*val = ex->elaborate_pexpr(des, scope);
+ val = scope->set_parameter((*cur).first, val);
+ assert(val);
+ delete val;
+ }
+
// Run through the defparams for this module, elaborate the
// expressions in this context and save the result is a table
// for later final override.
@@ -372,6 +391,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
/*
* $Log: elab_scope.cc,v $
+ * Revision 1.3 2000/03/12 17:09:41 steve
+ * Support localparam.
+ *
* Revision 1.2 2000/03/11 03:25:52 steve
* Locate scopes in statements.
*
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: lexor.lex,v 1.43 2000/03/05 06:14:10 steve Exp $"
+#ident "$Id: lexor.lex,v 1.44 2000/03/12 17:09:41 steve Exp $"
#endif
//# define YYSTYPE lexval
@@ -30,6 +30,7 @@
# include "parse.h"
# include <ctype.h>
# include <string.h>
+# include "lexor_keyword.h"
extern FILE*vl_input;
extern string vl_file;
@@ -42,7 +43,6 @@ static void reset_lexor();
static void line_directive();
static void line_directive2();
-extern int check_identifier(const char*str, int len);
static verinum*make_sized_binary(const char*txt);
static verinum*make_sized_dec(const char*txt);
static verinum*make_unsized_dec(const char*txt);
@@ -131,13 +131,15 @@ W [ \t\b\f\r]+
<UDPTABLE>[pPnN01\?\*\-] { return yytext[0]; }
[a-zA-Z_][a-zA-Z0-9$_]* {
- int rc = check_identifier(yytext, yyleng);
+ int rc = lexor_keyword_code(yytext, yyleng);
if (rc == IDENTIFIER)
yylval.text = strdup(yytext);
else
yylval.text = 0;
- return rc; }
+ return rc;
+ }
+
[a-zA-Z_][a-zA-Z0-9$_]*(\.[a-zA-Z_][a-zA-Z0-9$_]*)+ {
yylval.text = strdup(yytext);
Oops, something went wrong.

0 comments on commit 6eef545

Please sign in to comment.