mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-22 05:47:31 +02:00
Careful with wires connected to multiple ports.
This commit is contained in:
@@ -17,24 +17,37 @@
|
|||||||
* 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: 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
|
#endif
|
||||||
|
|
||||||
# include "Module.h"
|
# include "Module.h"
|
||||||
# include "PGate.h"
|
# include "PGate.h"
|
||||||
# include "PWire.h"
|
# include "PWire.h"
|
||||||
|
# include <assert.h>
|
||||||
|
|
||||||
Module::Module(const string&name, const svector<Module::port_t*>*pp)
|
Module::Module(const string&name, const svector<Module::port_t*>*pp)
|
||||||
: name_(name)
|
: name_(name)
|
||||||
{
|
{
|
||||||
if (pp) {
|
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;
|
ports_ = *pp;
|
||||||
for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
|
for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
|
||||||
port_t*cur = ports_[idx];
|
port_t*cur = ports_[idx];
|
||||||
if (cur == 0)
|
if (cur == 0)
|
||||||
continue;
|
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;
|
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)
|
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()
|
map<string,PWire*>::const_iterator obj = wires_.find(name);
|
||||||
; cur != wires_.end()
|
if (obj == wires_.end())
|
||||||
; cur ++ ) {
|
return 0;
|
||||||
|
else
|
||||||
if ((*cur)->name() == name)
|
return (*obj).second;
|
||||||
return *cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PGate* Module::get_gate(const string&name)
|
PGate* Module::get_gate(const string&name)
|
||||||
@@ -115,6 +129,9 @@ PGate* Module::get_gate(const string&name)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: Module.cc,v $
|
* $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
|
* Revision 1.8 1999/12/11 05:45:41 steve
|
||||||
* Fix support for attaching attributes to primitive gates.
|
* Fix support for attaching attributes to primitive gates.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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: 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
|
#endif
|
||||||
|
|
||||||
# include <list>
|
# include <list>
|
||||||
@@ -77,7 +77,12 @@ class Module {
|
|||||||
const string&get_name() const { return name_; }
|
const string&get_name() const { return name_; }
|
||||||
|
|
||||||
void add_gate(PGate*gate);
|
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_behavior(PProcess*behave);
|
||||||
void add_task(const string&name, PTask*def);
|
void add_task(const string&name, PTask*def);
|
||||||
void add_function(const string&name, PFunction*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
|
// Find a wire by name. This is used for connecting gates to
|
||||||
// existing wires, etc.
|
// existing wires, etc.
|
||||||
PWire* get_wire(const string&name);
|
PWire* get_wire(const string&name) const;
|
||||||
PGate* get_gate(const string&name);
|
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<PGate*>& get_gates() const { return gates_; }
|
||||||
const list<PProcess*>& get_behaviors() const { return behaviors_; }
|
const list<PProcess*>& get_behaviors() const { return behaviors_; }
|
||||||
|
|
||||||
@@ -104,7 +109,7 @@ class Module {
|
|||||||
const string name_;
|
const string name_;
|
||||||
|
|
||||||
svector<port_t*> ports_;
|
svector<port_t*> ports_;
|
||||||
list<PWire*> wires_;
|
map<string,PWire*> wires_;
|
||||||
list<PGate*> gates_;
|
list<PGate*> gates_;
|
||||||
list<PProcess*> behaviors_;
|
list<PProcess*> behaviors_;
|
||||||
map<string,PTask*> tasks_;
|
map<string,PTask*> tasks_;
|
||||||
@@ -118,6 +123,9 @@ class Module {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: Module.h,v $
|
* $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
|
* Revision 1.12 2000/01/09 05:50:48 steve
|
||||||
* Support named parameter override lists.
|
* Support named parameter override lists.
|
||||||
*
|
*
|
||||||
|
|||||||
+7
-4
@@ -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.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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1863,13 +1863,13 @@ bool Module::elaborate(Design*des, NetScope*scope,
|
|||||||
|
|
||||||
// Get all the explicitly declared wires of the module and
|
// Get all the explicitly declared wires of the module and
|
||||||
// start the signals list with them.
|
// 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 != wl.end()
|
||||||
; wt ++ ) {
|
; wt ++ ) {
|
||||||
|
|
||||||
(*wt)->elaborate(des, scope);
|
(*wt).second->elaborate(des, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elaborate functions.
|
// Elaborate functions.
|
||||||
@@ -1981,6 +1981,9 @@ Design* elaborate(const map<string,Module*>&modules,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elaborate.cc,v $
|
* $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
|
* Revision 1.139 2000/01/09 05:50:48 steve
|
||||||
* Support named parameter override lists.
|
* Support named parameter override lists.
|
||||||
*
|
*
|
||||||
|
|||||||
+6
-3
@@ -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: 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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -599,11 +599,11 @@ void Module::dump(ostream&out) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through and display all the wires.
|
// 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 != wires_.end()
|
||||||
; wire ++ ) {
|
; wire ++ ) {
|
||||||
|
|
||||||
(*wire)->dump(out);
|
(*wire).second->dump(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump the task definitions.
|
// Dump the task definitions.
|
||||||
@@ -691,6 +691,9 @@ void PUdp::dump(ostream&out) const
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: pform_dump.cc,v $
|
* $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
|
* Revision 1.46 2000/01/09 05:50:49 steve
|
||||||
* Support named parameter override lists.
|
* Support named parameter override lists.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user