Careful with wires connected to multiple ports.
This commit is contained in:
parent
bed47a4ab4
commit
9125a4c451
47
Module.cc
47
Module.cc
|
|
@ -17,24 +17,37 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: Module.cc,v 1.8 1999/12/11 05:45:41 steve Exp $"
|
||||
#ident "$Id: Module.cc,v 1.9 2000/01/09 20:37:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "Module.h"
|
||||
# include "PGate.h"
|
||||
# include "PWire.h"
|
||||
# include <assert.h>
|
||||
|
||||
Module::Module(const string&name, const svector<Module::port_t*>*pp)
|
||||
: name_(name)
|
||||
{
|
||||
if (pp) {
|
||||
// Save the list of ports, then scan the list to make
|
||||
// the implicit wires. Add those wires to the wire map.
|
||||
ports_ = *pp;
|
||||
for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
|
||||
port_t*cur = ports_[idx];
|
||||
if (cur == 0)
|
||||
continue;
|
||||
for (unsigned jdx = 0 ; jdx < cur->wires.count() ; jdx += 1)
|
||||
add_wire(cur->wires[jdx]);
|
||||
|
||||
// The port can actually be a list of wires, to
|
||||
// remember to scan the set. Also note the case
|
||||
// where a wire may be connected to multiple
|
||||
// ports, and reuse the link if that happens.
|
||||
for (unsigned jdx = 0; jdx < cur->wires.count(); jdx += 1) {
|
||||
PWire*tmp = add_wire(cur->wires[jdx]);
|
||||
if (tmp != cur->wires[jdx]) {
|
||||
delete cur->wires[jdx];
|
||||
cur->wires[jdx] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,9 +67,14 @@ void Module::add_function(const string &name, PFunction *func)
|
|||
funcs_[name] = func;
|
||||
}
|
||||
|
||||
void Module::add_wire(PWire*wire)
|
||||
PWire* Module::add_wire(PWire*wire)
|
||||
{
|
||||
wires_.push_back(wire);
|
||||
PWire*&ep = wires_[wire->name()];
|
||||
if (ep) return ep;
|
||||
|
||||
assert(ep == 0);
|
||||
ep = wire;
|
||||
return wire;
|
||||
}
|
||||
|
||||
void Module::add_behavior(PProcess*b)
|
||||
|
|
@ -86,17 +104,13 @@ unsigned Module::find_port(const string&name) const
|
|||
}
|
||||
|
||||
|
||||
PWire* Module::get_wire(const string&name)
|
||||
PWire* Module::get_wire(const string&name) const
|
||||
{
|
||||
for (list<PWire*>::iterator cur = wires_.begin()
|
||||
; cur != wires_.end()
|
||||
; cur ++ ) {
|
||||
|
||||
if ((*cur)->name() == name)
|
||||
return *cur;
|
||||
}
|
||||
|
||||
return 0;
|
||||
map<string,PWire*>::const_iterator obj = wires_.find(name);
|
||||
if (obj == wires_.end())
|
||||
return 0;
|
||||
else
|
||||
return (*obj).second;
|
||||
}
|
||||
|
||||
PGate* Module::get_gate(const string&name)
|
||||
|
|
@ -115,6 +129,9 @@ PGate* Module::get_gate(const string&name)
|
|||
|
||||
/*
|
||||
* $Log: Module.cc,v $
|
||||
* Revision 1.9 2000/01/09 20:37:57 steve
|
||||
* Careful with wires connected to multiple ports.
|
||||
*
|
||||
* Revision 1.8 1999/12/11 05:45:41 steve
|
||||
* Fix support for attaching attributes to primitive gates.
|
||||
*
|
||||
|
|
|
|||
18
Module.h
18
Module.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: Module.h,v 1.12 2000/01/09 05:50:48 steve Exp $"
|
||||
#ident "$Id: Module.h,v 1.13 2000/01/09 20:37:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <list>
|
||||
|
|
@ -77,7 +77,12 @@ class Module {
|
|||
const string&get_name() const { return name_; }
|
||||
|
||||
void add_gate(PGate*gate);
|
||||
void add_wire(PWire*wire);
|
||||
|
||||
// The add_wire method adds a wire by name, but only if the
|
||||
// wire name doesn't already exist. Either way, the result is
|
||||
// the existing wire or the pointer passed in.
|
||||
PWire* add_wire(PWire*wire);
|
||||
|
||||
void add_behavior(PProcess*behave);
|
||||
void add_task(const string&name, PTask*def);
|
||||
void add_function(const string&name, PFunction*def);
|
||||
|
|
@ -88,10 +93,10 @@ class Module {
|
|||
|
||||
// Find a wire by name. This is used for connecting gates to
|
||||
// existing wires, etc.
|
||||
PWire* get_wire(const string&name);
|
||||
PWire* get_wire(const string&name) const;
|
||||
PGate* get_gate(const string&name);
|
||||
|
||||
const list<PWire*>& get_wires() const { return wires_; }
|
||||
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_; }
|
||||
|
||||
|
|
@ -104,7 +109,7 @@ class Module {
|
|||
const string name_;
|
||||
|
||||
svector<port_t*> ports_;
|
||||
list<PWire*> wires_;
|
||||
map<string,PWire*> wires_;
|
||||
list<PGate*> gates_;
|
||||
list<PProcess*> behaviors_;
|
||||
map<string,PTask*> tasks_;
|
||||
|
|
@ -118,6 +123,9 @@ class Module {
|
|||
|
||||
/*
|
||||
* $Log: Module.h,v $
|
||||
* Revision 1.13 2000/01/09 20:37:57 steve
|
||||
* Careful with wires connected to multiple ports.
|
||||
*
|
||||
* Revision 1.12 2000/01/09 05:50:48 steve
|
||||
* Support named parameter override lists.
|
||||
*
|
||||
|
|
|
|||
11
elaborate.cc
11
elaborate.cc
|
|
@ -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.139 2000/01/09 05:50:48 steve Exp $"
|
||||
#ident "$Id: elaborate.cc,v 1.140 2000/01/09 20:37:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -1863,13 +1863,13 @@ bool Module::elaborate(Design*des, NetScope*scope,
|
|||
|
||||
// Get all the explicitly declared wires of the module and
|
||||
// start the signals list with them.
|
||||
const list<PWire*>&wl = get_wires();
|
||||
const map<string,PWire*>&wl = get_wires();
|
||||
|
||||
for (list<PWire*>::const_iterator wt = wl.begin()
|
||||
for (map<string,PWire*>::const_iterator wt = wl.begin()
|
||||
; wt != wl.end()
|
||||
; wt ++ ) {
|
||||
|
||||
(*wt)->elaborate(des, scope);
|
||||
(*wt).second->elaborate(des, scope);
|
||||
}
|
||||
|
||||
// Elaborate functions.
|
||||
|
|
@ -1981,6 +1981,9 @@ Design* elaborate(const map<string,Module*>&modules,
|
|||
|
||||
/*
|
||||
* $Log: elaborate.cc,v $
|
||||
* Revision 1.140 2000/01/09 20:37:57 steve
|
||||
* Careful with wires connected to multiple ports.
|
||||
*
|
||||
* Revision 1.139 2000/01/09 05:50:48 steve
|
||||
* Support named parameter override lists.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: pform_dump.cc,v 1.46 2000/01/09 05:50:49 steve Exp $"
|
||||
#ident "$Id: pform_dump.cc,v 1.47 2000/01/09 20:37:57 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -599,11 +599,11 @@ void Module::dump(ostream&out) const
|
|||
}
|
||||
|
||||
// Iterate through and display all the wires.
|
||||
for (list<PWire*>::const_iterator wire = wires_.begin()
|
||||
for (map<string,PWire*>::const_iterator wire = wires_.begin()
|
||||
; wire != wires_.end()
|
||||
; wire ++ ) {
|
||||
|
||||
(*wire)->dump(out);
|
||||
(*wire).second->dump(out);
|
||||
}
|
||||
|
||||
// Dump the task definitions.
|
||||
|
|
@ -691,6 +691,9 @@ void PUdp::dump(ostream&out) const
|
|||
|
||||
/*
|
||||
* $Log: pform_dump.cc,v $
|
||||
* Revision 1.47 2000/01/09 20:37:57 steve
|
||||
* Careful with wires connected to multiple ports.
|
||||
*
|
||||
* Revision 1.46 2000/01/09 05:50:49 steve
|
||||
* Support named parameter override lists.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue