Permalink
Browse files

Elaborate UDP devices,

 Support UDP type attributes, and
 pass those attributes to nodes that
 are instantiated by elaboration,
 Put modules into a map instead of
 a simple list.
  • Loading branch information...
1 parent 91aad30 commit e097c999d5354328385607a8b0c0d4dfff705058 steve committed Dec 1, 1998
Showing with 339 additions and 103 deletions.
  1. +16 −2 PGate.h
  2. +13 −1 PUdp.h
  3. +10 −0 README.txt
  4. +20 −16 design_dump.cc
  5. +63 −33 elaborate.cc
  6. +14 −1 emit.cc
  7. +19 −10 main.cc
  8. +53 −1 netlist.cc
  9. +27 −1 netlist.h
  10. +7 −1 parse.y
  11. +31 −7 pform.cc
  12. +13 −2 pform.h
  13. +19 −12 pform_dump.cc
  14. +9 −14 t-verilog.cc
  15. +15 −1 target.cc
  16. +10 −1 target.h
View
18 PGate.h
@@ -19,11 +19,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
-#ident "$Id: PGate.h,v 1.1 1998/11/03 23:28:54 steve Exp $"
+#ident "$Id: PGate.h,v 1.2 1998/12/01 00:42:13 steve Exp $"
#endif
# include <vector>
class PExpr;
+class PUdp;
class Design;
/*
@@ -111,7 +112,9 @@ class PGBuiltin : public PGate {
/*
* This kind of gate is an instantiation of a module. The stored type
- * is the name of a module definition somewhere in the pform.
+ * is the name of a module definition somewhere in the pform. This
+ * type als handles UDP devices, because it is generally not known at
+ * parse time whether a name belongs to a module or a UDP.
*/
class PGModule : public PGate {
@@ -125,10 +128,21 @@ class PGModule : public PGate {
private:
string type_;
+
+ void elaborate_mod_(Design*, Module*mod, const string&path) const;
+ void elaborate_udp_(Design*, PUdp *udp, const string&path) const;
};
/*
* $Log: PGate.h,v $
+ * Revision 1.2 1998/12/01 00:42:13 steve
+ * Elaborate UDP devices,
+ * Support UDP type attributes, and
+ * pass those attributes to nodes that
+ * are instantiated by elaboration,
+ * Put modules into a map instead of
+ * a simple list.
+ *
* Revision 1.1 1998/11/03 23:28:54 steve
* Introduce verilog to CVS.
*
View
14 PUdp.h
@@ -19,10 +19,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
-#ident "$Id: PUdp.h,v 1.1 1998/11/25 02:35:53 steve Exp $"
+#ident "$Id: PUdp.h,v 1.2 1998/12/01 00:42:13 steve Exp $"
#endif
+# include <map>
# include <vector>
+# include <string>
# include "verinum.h"
/*
@@ -61,6 +63,8 @@ class PUdp {
verinum::V initial;
+ map<string,string> attributes;
+
void dump(ostream&out) const;
private:
@@ -73,6 +77,14 @@ class PUdp {
/*
* $Log: PUdp.h,v $
+ * Revision 1.2 1998/12/01 00:42:13 steve
+ * Elaborate UDP devices,
+ * Support UDP type attributes, and
+ * pass those attributes to nodes that
+ * are instantiated by elaboration,
+ * Put modules into a map instead of
+ * a simple list.
+ *
* Revision 1.1 1998/11/25 02:35:53 steve
* Parse UDP primitives all the way to pform.
*
View
@@ -69,6 +69,16 @@ Attributes are [<key> <value>] pairs and are used to communicate with
the various processing steps. See the documentation for the processing
step for a list of the pertinent attributes.
+Attributes can also be applied to gate types. When this is done, the
+attribute is given to every instantiation of the primitive. The syntax
+for the attribute statement is the same, except that the <identifier>
+names a primitive earlier in the compilation unit and the statement is
+placed in global scope, instead of within a module. The semicolon is
+not part of a type attribute.
+
+Currently, type attributes are only supported for UDP types.
+
+
HOW IT WORKS -- STAGES OF PROCESSING
* Parse
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.4 1998/11/23 00:20:22 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.5 1998/12/01 00:42:13 steve Exp $"
#endif
/*
@@ -28,21 +28,6 @@
# include <iomanip>
# include "netlist.h"
-static ostream& operator<< (ostream&o, NetNet::Type t)
-{
- switch (t) {
- case NetNet::IMPLICIT:
- o << "implicit wire";
- break;
- case NetNet::WIRE:
- o << "wire";
- break;
- case NetNet::REG:
- o << "reg";
- break;
- }
- return o;
-}
static ostream& operator<< (ostream&o, NetBlock::Type t)
{
@@ -164,6 +149,17 @@ void NetLogic::dump_node(ostream&o, unsigned ind) const
<< endl;
dump_node_pins(o, ind+4);
+ dump_obj_attr(o, ind+4);
+}
+
+void NetUDP::dump_node(ostream&o, unsigned ind) const
+{
+ o << setw(ind) << "" << "UDP: ";
+ o << " #(" << delay1() << "," << delay2() << "," << delay3() <<
+ ") " << name() << endl;
+
+ dump_node_pins(o, ind+4);
+ dump_obj_attr(o, ind+4);
}
void NetPEvent::dump_node(ostream&o, unsigned ind) const
@@ -396,6 +392,14 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.5 1998/12/01 00:42:13 steve
+ * Elaborate UDP devices,
+ * Support UDP type attributes, and
+ * pass those attributes to nodes that
+ * are instantiated by elaboration,
+ * Put modules into a map instead of
+ * a simple list.
+ *
* Revision 1.4 1998/11/23 00:20:22 steve
* NetAssign handles lvalues as pin links
* instead of a signal pointer,
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.6 1998/11/23 00:20:22 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.7 1998/12/01 00:42:14 steve Exp $"
#endif
/*
@@ -89,7 +89,8 @@ static void do_assign(Design*des, const string&path,
// Urff, I don't like this global variable. I *will* figure out a
// way to get rid of it. But, for now the PGModule::elaborate method
// needs it to find the module definition.
-static const list<Module*>* modlist = 0;
+static const map<string,Module*>* modlist = 0;
+static const map<string,PUdp*>* udplist = 0;
/* Elaborate a source wire. Generally pretty easy. */
void PWire::elaborate(Design*des, const string&path) const
@@ -201,25 +202,8 @@ void PGBuiltin::elaborate(Design*des, const string&path) const
* the parameters. This is done with BUFZ gates so that they look just
* like continuous assignment connections.
*/
-void PGModule::elaborate(Design*des, const string&path) const
+void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
{
- // Look for the module type
- Module*rmod = 0;
- for (list<Module*>::const_iterator mod = modlist->begin()
- ; mod != modlist->end()
- ; mod ++ ) {
-
- if ((*mod)->get_name() == type_) {
- rmod = *mod;
- break;
- }
- }
-
- if (rmod == 0) {
- cerr << "Unknown module: " << type_ << endl;
- return;
- }
-
string my_name;
if (get_name() == "")
my_name = local_symbol(path);
@@ -269,6 +253,48 @@ void PGModule::elaborate(Design*des, const string&path) const
}
}
+void PGModule::elaborate_udp_(Design*des, PUdp*udp, const string&path) const
+{
+ const string my_name = path+"."+get_name();
+ NetUDP*net = new NetUDP(my_name, udp->ports.size());
+ net->set_attributes(udp->attributes);
+
+ for (unsigned idx = 0 ; idx < net->pin_count() ; idx += 1) {
+ NetNet*sig = pin(idx)->elaborate_net(des, path);
+ if (sig == 0) {
+ cerr << "Expression too complicated for elaboration:"
+ << *pin(idx) << endl;
+ continue;
+ }
+
+ connect(sig->pin(0), net->pin(idx));
+
+ if (NetTmp*tmp = dynamic_cast<NetTmp*>(sig))
+ delete tmp;
+ }
+
+ des->add_node(net);
+}
+
+void PGModule::elaborate(Design*des, const string&path) const
+{
+ // Look for the module type
+ map<string,Module*>::const_iterator mod = modlist->find(type_);
+ if (mod != modlist->end()) {
+ elaborate_mod_(des, (*mod).second, path);
+ return;
+ }
+
+ // Try a primitive type
+ map<string,PUdp*>::const_iterator udp = udplist->find(type_);
+ if (udp != udplist->end()) {
+ elaborate_udp_(des, (*udp).second, path);
+ return;
+ }
+
+ cerr << "Unknown module: " << type_ << endl;
+}
+
NetNet* PExpr::elaborate_net(Design*des, const string&path) const
{
cerr << "Don't know how to elaborate `" << *this << "' as gates." << endl;
@@ -676,37 +702,41 @@ void Module::elaborate(Design*des, const string&path) const
}
}
-Design* elaborate(const list<Module*>&modules, const string&root)
+Design* elaborate(const map<string,Module*>&modules,
+ const map<string,PUdp*>&primitives,
+ const string&root)
{
// Look for the root module in the list.
- Module*rmod = 0;
- for (list<Module*>::const_iterator mod = modules.begin()
- ; mod != modules.end()
- ; mod ++ ) {
-
- if ((*mod)->get_name() == root) {
- rmod = *mod;
- break;
- }
- }
-
- if (rmod == 0)
+ map<string,Module*>::const_iterator mod = modules.find(root);
+ if (mod == modules.end())
return 0;
+ Module*rmod = (*mod).second;
+
// This is the output design. I fill it in as I scan the root
// module and elaborate what I find.
Design*des = new Design;
modlist = &modules;
+ udplist = &primitives;
rmod->elaborate(des, root);
modlist = 0;
+ udplist = 0;
return des;
}
/*
* $Log: elaborate.cc,v $
+ * Revision 1.7 1998/12/01 00:42:14 steve
+ * Elaborate UDP devices,
+ * Support UDP type attributes, and
+ * pass those attributes to nodes that
+ * are instantiated by elaboration,
+ * Put modules into a map instead of
+ * a simple list.
+ *
* Revision 1.6 1998/11/23 00:20:22 steve
* NetAssign handles lvalues as pin links
* instead of a signal pointer,
View
15 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.3 1998/11/09 18:55:34 steve Exp $"
+#ident "$Id: emit.cc,v 1.4 1998/12/01 00:42:14 steve Exp $"
#endif
/*
@@ -40,6 +40,11 @@ void NetLogic::emit_node(ostream&o, struct target_t*tgt) const
tgt->logic(o, this);
}
+void NetUDP::emit_node(ostream&o, struct target_t*tgt) const
+{
+ tgt->udp(o, this);
+}
+
void NetAssign::emit_node(ostream&o, struct target_t*tgt) const
{
tgt->net_assign(o, this);
@@ -218,6 +223,14 @@ void emit(ostream&o, const Design*des, const char*type)
/*
* $Log: emit.cc,v $
+ * Revision 1.4 1998/12/01 00:42:14 steve
+ * Elaborate UDP devices,
+ * Support UDP type attributes, and
+ * pass those attributes to nodes that
+ * are instantiated by elaboration,
+ * Put modules into a map instead of
+ * a simple list.
+ *
* Revision 1.3 1998/11/09 18:55:34 steve
* Add procedural while loops,
* Parse procedural for loops,
Oops, something went wrong.

0 comments on commit e097c99

Please sign in to comment.