Support multiple root modules (Philip Blundell)

This commit is contained in:
steve 2001-10-19 21:53:24 +00:00
parent 6fc556cefc
commit d350620315
14 changed files with 312 additions and 167 deletions

View File

@ -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.117 2001/08/25 23:50:02 steve Exp $"
#ident "$Id: design_dump.cc,v 1.118 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -945,7 +945,9 @@ void Design::dump(ostream&o) const
{
o << "DESIGN TIME PRECISION: 10e" << get_precision() << endl;
o << "SCOPES:" << endl;
root_scope_->dump(o);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++)
(*scope)->dump(o);
o << "ELABORATED NODES:" << endl;
@ -968,6 +970,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
* Revision 1.118 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.117 2001/08/25 23:50:02 steve
* Change the NetAssign_ class to refer to the signal
* instead of link into the netlist. This is faster

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elaborate.cc,v 1.220 2001/08/25 23:50:02 steve Exp $"
#ident "$Id: elaborate.cc,v 1.221 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -31,6 +31,7 @@
# include <typeinfo>
# include <strstream>
# include <list>
# include "pform.h"
# include "PEvent.h"
# include "netlist.h"
@ -2277,16 +2278,18 @@ bool Module::elaborate(Design*des, NetScope*scope) const
return result_flag;
}
struct root_elem {
Module *mod;
NetScope *scope;
};
Design* elaborate(const map<string,Module*>&modules,
const map<string,PUdp*>&primitives,
const string&root)
list<string>roots)
{
// Look for the root module in the list.
map<string,Module*>::const_iterator mod = modules.find(root);
if (mod == modules.end())
return 0;
Module*rmod = (*mod).second;
svector<root_elem*> root_elems(roots.size());
bool rc = true;
unsigned i = 0;
// This is the output design. I fill it in as I scan the root
// module and elaborate what I find.
@ -2295,9 +2298,21 @@ Design* elaborate(const map<string,Module*>&modules,
modlist = &modules;
udplist = &primitives;
for (list<string>::const_iterator root = roots.begin();
root != roots.end(); root++) {
// Look for the root module in the list.
map<string,Module*>::const_iterator mod = modules.find(*root);
if (mod == modules.end()) {
cerr << "Unable to find root module \"" << (*root) << "\"." << endl;
des->errors++;
continue;
}
Module *rmod = (*mod).second;
// Make the root scope, then scan the pform looking for scopes
// and parameters.
NetScope*scope = des->make_root_scope(root);
NetScope*scope = des->make_root_scope(*root);
scope->time_unit(rmod->time_unit);
scope->time_precision(rmod->time_precision);
des->set_precision(rmod->time_precision);
@ -2306,6 +2321,12 @@ Design* elaborate(const map<string,Module*>&modules,
return 0;
}
struct root_elem *r = new struct root_elem;
r->mod = rmod;
r->scope = scope;
root_elems[i++] = r;
}
// This method recurses through the scopes, looking for
// defparam assignments to apply to the parameters in the
// various scopes. This needs to be done after all the scopes
@ -2319,6 +2340,9 @@ Design* elaborate(const map<string,Module*>&modules,
// constants.
des->evaluate_parameters();
for (i = 0; i < root_elems.count(); i++) {
Module *rmod = root_elems[i]->mod;
NetScope *scope = root_elems[i]->scope;
// With the parameters evaluated down to constants, we have
// what we need to elaborate signals and memories. This pass
@ -2328,10 +2352,10 @@ Design* elaborate(const map<string,Module*>&modules,
delete des;
return 0;
}
// Now that the structure and parameters are taken care of,
// run through the pform again and generate the full netlist.
bool rc = rmod->elaborate(des, scope);
rc &= rmod->elaborate(des, scope);
}
modlist = 0;
@ -2348,6 +2372,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.221 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.220 2001/08/25 23:50:02 steve
* Change the NetAssign_ class to refer to the signal
* instead of link into the netlist. This is faster

13
emit.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: emit.cc,v 1.62 2001/08/25 23:50:02 steve Exp $"
#ident "$Id: emit.cc,v 1.63 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -369,7 +369,9 @@ bool Design::emit(struct target_t*tgt) const
return false;
// enumerate the scopes
root_scope_->emit_scope(tgt);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++)
(*scope)->emit_scope(tgt);
// emit nodes
@ -383,7 +385,9 @@ bool Design::emit(struct target_t*tgt) const
// emit task and function definitions
root_scope_->emit_defs(tgt);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++)
(*scope)->emit_defs(tgt);
// emit the processes
@ -470,6 +474,9 @@ bool emit(const Design*des, const char*type)
/*
* $Log: emit.cc,v $
* Revision 1.63 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.62 2001/08/25 23:50:02 steve
* Change the NetAssign_ class to refer to the signal
* instead of link into the netlist. This is faster

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: functor.cc,v 1.25 2001/07/25 03:10:49 steve Exp $"
#ident "$Id: functor.cc,v 1.26 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -114,7 +114,9 @@ void NetScope::run_functor(Design*des, functor_t*fun)
void Design::functor(functor_t*fun)
{
// Scan the scopes
root_scope_->run_functor(this, fun);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++)
(*scope)->run_functor(this, fun);
// apply to processes
procs_idx_ = procs_;
@ -286,6 +288,9 @@ int proc_match_t::event_wait(NetEvWait*)
/*
* $Log: functor.cc,v $
* Revision 1.26 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.25 2001/07/25 03:10:49 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: ivl_target.h,v 1.84 2001/10/16 02:19:27 steve Exp $"
#ident "$Id: ivl_target.h,v 1.85 2001/10/19 21:53:24 steve Exp $"
#endif
#ifdef __cplusplus
@ -332,6 +332,9 @@ extern const char* ivl_design_flag(ivl_design_t des, const char*key);
extern int ivl_design_process(ivl_design_t des,
ivl_process_f fun, void*cd);
extern ivl_scope_t ivl_design_root(ivl_design_t des);
extern void ivl_design_roots(ivl_design_t des,
ivl_scope_t **scopes,
unsigned int *nscopes);
extern int ivl_design_time_precision(ivl_design_t des);
extern unsigned ivl_design_consts(ivl_design_t des);
@ -964,6 +967,9 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.85 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.84 2001/10/16 02:19:27 steve
* Support IVL_LPM_DIVIDE for structural divide.
*

72
main.cc
View File

@ -19,7 +19,7 @@ const char COPYRIGHT[] =
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: main.cc,v 1.47 2001/07/30 02:44:05 steve Exp $"
#ident "$Id: main.cc,v 1.48 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -44,6 +44,7 @@ const char NOTICE[] =
# include <iostream.h>
# include <fstream>
# include <queue>
# include <list>
# include <map>
# include <unistd.h>
# include <stdlib.h>
@ -73,7 +74,6 @@ extern "C" const char*optarg;
const char VERSION[] = "$Name: $ $State: Exp $";
const char*target = "null";
string start_module = "";
map<string,string> flags;
@ -102,7 +102,7 @@ static void parm_to_flagmap(const string&flag)
extern Design* elaborate(const map<string,Module*>&modules,
const map<string,PUdp*>&primitives,
const string&root);
list <string>root);
extern void cprop(Design*des);
extern void synth(Design*des);
@ -175,6 +175,7 @@ int main(int argc, char*argv[])
int opt;
unsigned flag_errors = 0;
queue<net_func> net_func_queue;
list<string> roots;
struct tms cycles[5];
@ -217,7 +218,7 @@ int main(int argc, char*argv[])
parm_to_flagmap(optarg);
break;
case 's':
start_module = optarg;
roots.push_back(string(optarg));
break;
case 'T':
if (strcmp(optarg,"min") == 0) {
@ -337,40 +338,41 @@ int main(int argc, char*argv[])
}
/* If the user did not give a specific module to start with,
then look for the single module that has no ports. If there
are multiple modules with no ports, then give up. */
/* If the user did not give specific module(s) to start with,
then look for modules that are not instantiated anywhere. */
if (start_module == "") {
for (map<string,Module*>::iterator mod = modules.begin()
; mod != modules.end()
; mod ++ ) {
Module*cur = (*mod).second;
if (cur->port_count() == 0)
if (start_module == "") {
start_module = cur->get_name();
} else {
cerr << "More then 1 top level module."
<< endl;
return 1;
if (roots.empty()) {
map<string,bool> mentioned_p;
map<string,Module*>::iterator mod;
if (verbose_flag)
cout << "LOCATING TOP-LEVEL MODULES..." << endl << " ";
for (mod = modules.begin(); mod != modules.end(); mod++) {
list<PGate*> gates = (*mod).second->get_gates();
list<PGate*>::const_iterator gate;
for (gate = gates.begin(); gate != gates.end(); gate++) {
PGModule *mod = dynamic_cast<PGModule*>(*gate);
if (mod) {
// Note that this module has been instantiated
mentioned_p[mod->get_type()] = true;
}
}
}
/* If the previous attempt to find a start module failed, but
there is only one module, then just let the user get away
with it. */
if ((start_module == "") && (modules.size() == 1)) {
map<string,Module*>::iterator mod = modules.begin();
Module*cur = (*mod).second;
start_module = cur->get_name();
for (mod = modules.begin(); mod != modules.end(); mod++) {
if (mentioned_p[(*mod).second->get_name()] == false) {
if (verbose_flag)
cout << " " << (*mod).second->get_name();
roots.push_back((*mod).second->get_name());
}
}
if (verbose_flag)
cout << endl;
}
/* If there is *still* no guess for the root module, then give
up completely, and complain. */
if (start_module == "") {
if (roots.empty()) {
cerr << "No top level modules, and no -s option." << endl;
return 1;
}
@ -382,20 +384,19 @@ int main(int argc, char*argv[])
cerr<<" ... done, "
<<cycles_diff(cycles+1, cycles+0)<<" seconds."<<endl;
}
cout << "ELABORATING DESIGN -s "<<start_module<<" ..." << endl;
cout << "ELABORATING DESIGN" << endl;
}
/* On with the process of elaborating the module. */
Design*des = elaborate(modules, primitives, start_module);
Design*des = elaborate(modules, primitives, roots);
if (des == 0) {
cerr << start_module << ": error: "
<< "Unable to elaborate module." << endl;
cerr << "Elaboration failed" << endl;
return 1;
}
if (des->errors) {
cerr << start_module << ": error: " << des->errors
<< " elaborating module." << endl;
cerr << des->errors
<< " error(s) during elaboration." << endl;
return des->errors;
}
@ -454,6 +455,9 @@ int main(int argc, char*argv[])
/*
* $Log: main.cc,v $
* Revision 1.48 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.47 2001/07/30 02:44:05 steve
* Cleanup defines and types for mingw compile.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: net_design.cc,v 1.20 2001/07/25 03:10:49 steve Exp $"
#ident "$Id: net_design.cc,v 1.21 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -34,7 +34,7 @@
# include <strstream>
Design:: Design()
: errors(0), root_scope_(0), nodes_(0), procs_(0), lcounter_(0)
: errors(0), nodes_(0), procs_(0), lcounter_(0)
{
procs_idx_ = 0;
des_precision_ = 0;
@ -79,22 +79,33 @@ unsigned long Design::scale_to_precision(unsigned long val,
NetScope* Design::make_root_scope(const string&root)
{
assert(root_scope_ == 0);
NetScope *root_scope_;
root_scope_ = new NetScope(0, root, NetScope::MODULE);
root_scope_->set_module_name(root.c_str());
root_scopes_.push_back(root_scope_);
return root_scope_;
}
NetScope* Design::find_root_scope()
{
assert(root_scope_);
return root_scope_;
assert(root_scopes_.front());
return root_scopes_.front();
}
const NetScope* Design::find_root_scope() const
{
assert(root_scope_);
return root_scope_;
assert(root_scopes_.front());
return root_scopes_.front();
}
list<NetScope*> Design::find_root_scopes()
{
return root_scopes_;
}
const list<NetScope*> Design::find_root_scopes() const
{
return root_scopes_;
}
/*
@ -105,23 +116,26 @@ const NetScope* Design::find_root_scope() const
*/
NetScope* Design::find_scope(const string&key) const
{
if (key == root_scope_->name())
return root_scope_;
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++) {
if (key == (*scope)->name())
return *scope;
string path = key;
string root = parse_first_name(path);
NetScope*cur = root_scope_;
NetScope*cur = *scope;
if (root != cur->name())
return 0;
continue;
while (cur) {
string next = parse_first_name(path);
cur = cur->child(next);
if (path == "") return cur;
}
return cur;
}
return 0;
}
/*
@ -194,7 +208,9 @@ const NetExpr* Design::find_parameter(const NetScope*scope,
*/
void Design::run_defparams()
{
root_scope_->run_defparams(this);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++)
(*scope)->run_defparams(this);
}
void NetScope::run_defparams(Design*des)
@ -231,7 +247,9 @@ void NetScope::run_defparams(Design*des)
void Design::evaluate_parameters()
{
root_scope_->evaluate_parameters(this);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); scope++)
(*scope)->evaluate_parameters(this);
}
void NetScope::evaluate_parameters(Design*des)
@ -477,6 +495,9 @@ void Design::delete_process(NetProcTop*top)
/*
* $Log: net_design.cc,v $
* Revision 1.21 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.20 2001/07/25 03:10:49 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.216 2001/10/16 02:19:27 steve Exp $"
#ident "$Id: netlist.h,v 1.217 2001/10/19 21:53:24 steve Exp $"
#endif
/*
@ -30,6 +30,7 @@
*/
# include <string>
# include <map>
# include <list>
# include "verinum.h"
# include "LineInfo.h"
# include "svector.h"
@ -2710,9 +2711,10 @@ class Design {
NetScope* make_root_scope(const string&name);
NetScope* find_root_scope();
list<NetScope*> find_root_scopes();
const NetScope* find_root_scope() const;
const list<NetScope*> find_root_scopes() const;
/* Attempt to set the precision to the specified value. If the
precision is already more precise, the keep the precise
@ -2789,7 +2791,7 @@ class Design {
private:
// Keep a tree of scopes. The NetScope class handles the wide
// tree and per-hop searches for me.
NetScope*root_scope_;
list<NetScope*>root_scopes_;
// List the nodes in the design
NetNode*nodes_;
@ -2849,6 +2851,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.217 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.216 2001/10/16 02:19:27 steve
* Support IVL_LPM_DIVIDE for structural divide.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-api.cc,v 1.68 2001/10/16 02:19:27 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.69 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -46,7 +46,16 @@ extern "C" int ivl_design_process(ivl_design_t des,
extern "C" ivl_scope_t ivl_design_root(ivl_design_t des)
{
return des->root_;
assert (des->nroots_);
return des->roots_[0];
}
extern "C" void ivl_design_roots(ivl_design_t des, ivl_scope_t **scopes,
unsigned int *nscopes)
{
assert (nscopes && scopes);
*scopes = &des->roots_[0];
*nscopes = des->nroots_;
}
extern "C" int ivl_design_time_precision(ivl_design_t des)
@ -1389,6 +1398,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.69 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.68 2001/10/16 02:19:27 steve
* Support IVL_LPM_DIVIDE for structural divide.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) & !defined(macintosh)
#ident "$Id: t-dll-expr.cc,v 1.18 2001/09/15 18:27:04 steve Exp $"
#ident "$Id: t-dll-expr.cc,v 1.19 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -225,7 +225,7 @@ void dll_target::expr_signal(const NetESignal*net)
expr_->type_ = IVL_EX_SIGNAL;
expr_->width_= net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;
expr_->u_.signal_.sig = find_signal(des_.root_, net->sig());
expr_->u_.signal_.sig = find_signal(des_, net->sig());
expr_->u_.signal_.lsi = net->lsi();
expr_->u_.signal_.msi = net->msi();
}
@ -237,7 +237,7 @@ void dll_target::expr_subsignal(const NetEBitSel*net)
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr);
if (net->sig()->lsb() != 0) {
if (0/*net->sig()->lsb() != 0*/) {
cerr << net->get_line() << ": sorry: LSB for signal "
<< "is not zero." << endl;
}
@ -245,7 +245,7 @@ void dll_target::expr_subsignal(const NetEBitSel*net)
expr->type_ = IVL_EX_BITSEL;
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
expr->u_.bitsel_.sig = find_signal(des_.root_, net->sig());
expr->u_.bitsel_.sig = find_signal(des_, net->sig());
net->index()->expr_scan(this);
assert(expr_);
@ -301,6 +301,9 @@ void dll_target::expr_unary(const NetEUnary*net)
/*
* $Log: t-dll-expr.cc,v $
* Revision 1.19 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.18 2001/09/15 18:27:04 steve
* Make configure detect malloc.h
*

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll-proc.cc,v 1.35 2001/09/15 18:27:04 steve Exp $"
#ident "$Id: t-dll-proc.cc,v 1.36 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -115,7 +115,7 @@ void dll_target::func_def(const NetScope*net)
if (scope->ports > 0) {
scope->port = new ivl_signal_t[scope->ports];
for (unsigned idx = 0 ; idx < scope->ports ; idx += 1)
scope->port[idx] = find_signal(des_.root_, def->port(idx));
scope->port[idx] = find_signal(des_, def->port(idx));
}
}
@ -141,7 +141,7 @@ void dll_target::proc_assign(const NetAssign*net)
cur->width_ = asn->lwidth();
cur->loff_ = asn->get_loff();
cur->type_ = IVL_LVAL_REG;
cur->n.sig = find_signal(des_.root_, asn->sig());
cur->n.sig = find_signal(des_, asn->sig());
cur->idx = 0;
if (asn->bmux()) {
@ -181,7 +181,7 @@ void dll_target::proc_assign_nb(const NetAssignNB*net)
cur->type_ = IVL_LVAL_REG;
cur->width_ = asn->lwidth();
cur->loff_ = asn->get_loff();
cur->n.sig = find_signal(des_.root_, asn->sig());
cur->n.sig = find_signal(des_, asn->sig());
cur->idx = 0;
if (asn->bmux()) {
@ -669,6 +669,9 @@ void dll_target::proc_while(const NetWhile*net)
/*
* $Log: t-dll-proc.cc,v $
* Revision 1.36 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.35 2001/09/15 18:27:04 steve
* Make configure detect malloc.h
*

140
t-dll.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.cc,v 1.66 2001/10/16 02:19:27 steve Exp $"
#ident "$Id: t-dll.cc,v 1.67 2001/10/19 21:53:24 steve Exp $"
#endif
# include "config.h"
@ -101,37 +101,46 @@ static struct dll_target dll_target_obj;
* NetScope object. The search works by looking for the parent scope,
* then scanning the parent scope for the NetScope object.
*/
ivl_scope_t dll_target::find_scope(ivl_scope_t root, const NetScope*cur)
static ivl_scope_t find_scope_from_root(ivl_scope_t root, const NetScope*cur)
{
ivl_scope_t parent, tmp;
if (const NetScope*par = cur->parent()) {
parent = find_scope(root, par);
} else {
assert(strcmp(root->name_, cur->name().c_str()) == 0);
return root;
}
parent = find_scope_from_root(root, par);
for (tmp = parent->child_ ; tmp ; tmp = tmp->sibling_)
if (strcmp(tmp->name_, cur->name().c_str()) == 0)
return tmp;
} else {
if (strcmp(root->name_, cur->name().c_str()) == 0)
return root;
}
return 0;
}
ivl_scope_t dll_target::find_scope(ivl_design_s &des, const NetScope*cur)
{
unsigned i;
ivl_scope_t scope = NULL;
for (i = 0; i < des.nroots_ && scope == NULL; i++)
scope = find_scope_from_root(des.roots_[i], cur);
return scope;
}
ivl_scope_t dll_target::lookup_scope_(const NetScope*cur)
{
return find_scope(des_.root_, cur);
return find_scope(des_, cur);
}
/*
* This is a convenience function to locate an ivl_signal_t object
* given the NetESignal that has the signal name.
*/
ivl_signal_t dll_target::find_signal(ivl_scope_t root, const NetNet*net)
ivl_signal_t dll_target::find_signal(ivl_design_s &des, const NetNet*net)
{
ivl_scope_t scope = find_scope(root, net->scope());
ivl_scope_t scope = find_scope(des, net->scope());
assert(scope);
const char*nname = net->name();
@ -177,7 +186,11 @@ static ivl_memory_t find_memory(ivl_scope_t root, const NetMemory*cur)
ivl_memory_t dll_target::lookup_memory_(const NetMemory*cur)
{
return find_memory(des_.root_, cur);
unsigned i;
ivl_memory_t mem = NULL;
for (i = 0; i < des_.nroots_ && mem == NULL; i++)
mem = find_memory(des_.roots_[i], cur);
return mem;
}
static ivl_nexus_t nexus_sig_make(ivl_signal_t net, unsigned pin)
@ -334,8 +347,37 @@ static void scope_add_mem(ivl_scope_t scope, ivl_memory_t net)
scope->mem_[scope->nmem_-1] = net;
}
void dll_target::add_root(ivl_design_s &des_, const NetScope *s)
{
ivl_scope_t root_ = new struct ivl_scope_s;
const char *name = s->name().c_str();
root_->name_ = strdup(name);
root_->child_ = 0;
root_->sibling_ = 0;
root_->parent = 0;
root_->nsigs_ = 0;
root_->sigs_ = 0;
root_->nlog_ = 0;
root_->log_ = 0;
root_->nevent_ = 0;
root_->event_ = 0;
root_->nlpm_ = 0;
root_->lpm_ = 0;
root_->nmem_ = 0;
root_->mem_ = 0;
root_->type_ = IVL_SCT_MODULE;
root_->tname_ = root_->name_;
des_.nroots_++;
if (des_.roots_)
des_.roots_ = (ivl_scope_t *)realloc(des_.roots_, des_.nroots_ * sizeof(ivl_scope_t));
else
des_.roots_ = (ivl_scope_t *)malloc(des_.nroots_ * sizeof(ivl_scope_t));
des_.roots_[des_.nroots_ - 1] = root_;
}
bool dll_target::start_design(const Design*des)
{
list<NetScope *> root_scopes;
dll_path_ = des->get_flag("DLL");
dll_ = ivl_dlopen(dll_path_.c_str());
if (dll_ == 0) {
@ -348,23 +390,13 @@ bool dll_target::start_design(const Design*des)
// Initialize the design object.
des_.self = des;
des_.time_precision = des->get_precision();
des_.root_ = new struct ivl_scope_s;
des_.root_->name_ = strdup(des->find_root_scope()->name().c_str());
des_.root_->child_ = 0;
des_.root_->sibling_ = 0;
des_.root_->parent = 0;
des_.root_->nsigs_ = 0;
des_.root_->sigs_ = 0;
des_.root_->nlog_ = 0;
des_.root_->log_ = 0;
des_.root_->nevent_ = 0;
des_.root_->event_ = 0;
des_.root_->nlpm_ = 0;
des_.root_->lpm_ = 0;
des_.root_->nmem_ = 0;
des_.root_->mem_ = 0;
des_.root_->type_ = IVL_SCT_MODULE;
des_.root_->tname_ = des_.root_->name_;
des_.nroots_ = 0;
des_.roots_ = NULL;
root_scopes = des->find_root_scopes();
for (list<NetScope*>::const_iterator scope = root_scopes.begin();
scope != root_scopes.end(); scope++)
add_root(des_, *scope);
des_.consts = (ivl_net_const_t*)
malloc(sizeof(ivl_net_const_t));
@ -446,7 +478,7 @@ bool dll_target::bufz(const NetBUFZ*net)
/* Attach the logic device to the scope that contains it. */
assert(net->scope());
ivl_scope_t scope = find_scope(des_.root_, net->scope());
ivl_scope_t scope = find_scope(des_, net->scope());
assert(scope);
obj->scope_ = scope;
@ -463,7 +495,7 @@ void dll_target::event(const NetEvent*net)
{
struct ivl_event_s *obj = new struct ivl_event_s;
ivl_scope_t scope = find_scope(des_.root_, net->scope());
ivl_scope_t scope = find_scope(des_, net->scope());
obj->name = strdup(net->full_name().c_str());
obj->scope = scope;
scope_add_event(scope, obj);
@ -576,7 +608,7 @@ void dll_target::logic(const NetLogic*net)
}
assert(net->scope());
ivl_scope_t scope = find_scope(des_.root_, net->scope());
ivl_scope_t scope = find_scope(des_, net->scope());
assert(scope);
obj->scope_= scope;
@ -605,10 +637,10 @@ void dll_target::net_case_cmp(const NetCaseCmp*net)
nexus_log_add(obj->pins_[idx], obj, idx);
}
// assert(net->scope());
// ivl_scope_t scope = find_scope(des_.root_, net->scope());
// assert(scope);
ivl_scope_t scope = des_.root_;
//assert(net->scope());
//ivl_scope_t scope = find_scope(des_, net->scope());
//assert(scope);
ivl_scope_t scope = des_.roots_[0];
obj->scope_= scope;
obj->name_ = strdup(net->name());
@ -672,7 +704,7 @@ void dll_target::udp(const NetUDP*net)
}
assert(net->scope());
ivl_scope_t scope = find_scope(des_.root_, net->scope());
ivl_scope_t scope = find_scope(des_, net->scope());
assert(scope);
obj->scope_= scope;
@ -685,7 +717,7 @@ void dll_target::memory(const NetMemory*net)
{
ivl_memory_t obj = new struct ivl_memory_s;
obj->name_ = strdup(net->name().c_str());
obj->scope_ = find_scope(des_.root_, net->scope());
obj->scope_ = find_scope(des_, net->scope());
obj->width_ = net->width();
obj->signed_ = 0;
obj->size_ = net->count();
@ -703,7 +735,7 @@ void dll_target::lpm_add_sub(const NetAddSub*net)
obj->type = IVL_LPM_ADD;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
/* Choose the width of the adder. If the carry bit is
@ -772,7 +804,7 @@ void dll_target::lpm_clshift(const NetCLShift*net)
obj->type = IVL_LPM_SHIFTL;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
/* Look at the direction input of the device, and select the
@ -848,7 +880,7 @@ void dll_target::lpm_compare(const NetCompare*net)
ivl_lpm_t obj = new struct ivl_lpm_s;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
bool swap_operands = false;
@ -960,7 +992,7 @@ void dll_target::lpm_divide(const NetDivide*net)
obj->type = IVL_LPM_DIVIDE;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
unsigned wid = net->width_r();
@ -1017,7 +1049,7 @@ void dll_target::lpm_ff(const NetFF*net)
ivl_lpm_t obj = new struct ivl_lpm_s;
obj->type = IVL_LPM_FF;
obj->name = strdup(net->name());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
obj->u_.ff.width = net->width();
@ -1085,7 +1117,7 @@ void dll_target::lpm_ram_dq(const NetRamDq*net)
obj->name = strdup(net->name());
obj->u_.ff.mem = lookup_memory_(net->mem());
assert(obj->u_.ff.mem);
obj->scope = find_scope(des_.root_, net->mem()->scope());
obj->scope = find_scope(des_, net->mem()->scope());
assert(obj->scope);
obj->u_.ff.width = net->width();
@ -1198,7 +1230,7 @@ void dll_target::lpm_mult(const NetMult*net)
obj->type = IVL_LPM_MULT;
obj->name = strdup(net->name());
assert(net->scope());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
unsigned wid = net->width_r();
@ -1255,7 +1287,7 @@ void dll_target::lpm_mux(const NetMux*net)
ivl_lpm_t obj = new struct ivl_lpm_s;
obj->type = IVL_LPM_MUX;
obj->name = strdup(net->name());
obj->scope = find_scope(des_.root_, net->scope());
obj->scope = find_scope(des_, net->scope());
assert(obj->scope);
obj->u_.mux.width = net->width();
@ -1399,15 +1431,20 @@ void dll_target::scope(const NetScope*net)
ivl_scope_t scope;
if (net->parent() == 0) {
assert(strcmp(des_.root_->name_, net->name().c_str()) == 0);
scope = des_.root_;
unsigned i;
scope = NULL;
for (i = 0; i < des_.nroots_ && scope == NULL; i++) {
if (strcmp(des_.roots_[i]->name_, net->name().c_str()) == 0)
scope = des_.roots_[i];
}
assert(scope);
} else {
scope = new struct ivl_scope_s;
scope->name_ = strdup(net->name().c_str());
scope->child_ = 0;
scope->sibling_ = 0;
scope->parent = find_scope(des_.root_, net->parent());
scope->parent = find_scope(des_, net->parent());
scope->nsigs_ = 0;
scope->sigs_ = 0;
scope->nlog_ = 0;
@ -1459,7 +1496,7 @@ void dll_target::signal(const NetNet*net)
it. This involves growing the sigs_ array in the scope
object, or creating the sigs_ array if this is the first
signal. */
obj->scope_ = find_scope(des_.root_, net->scope());
obj->scope_ = find_scope(des_, net->scope());
assert(obj->scope_);
if (obj->scope_->nsigs_ == 0) {
@ -1617,6 +1654,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
* Revision 1.67 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.66 2001/10/16 02:19:27 steve
* Support IVL_LPM_DIVIDE for structural divide.
*

13
t-dll.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.65 2001/10/16 02:19:27 steve Exp $"
#ident "$Id: t-dll.h,v 1.66 2001/10/19 21:53:24 steve Exp $"
#endif
# include "target.h"
@ -40,7 +40,8 @@ struct ivl_design_s {
int time_precision;
ivl_scope_t root_;
ivl_scope_t *roots_;
unsigned nroots_;
ivl_process_t threads_;
@ -132,8 +133,9 @@ struct dll_target : public target_t, public expr_scan_t {
ivl_memory_t lookup_memory_(const NetMemory*mem);
private:
static ivl_scope_t find_scope(ivl_scope_t root, const NetScope*cur);
static ivl_signal_t find_signal(ivl_scope_t root, const NetNet*net);
static ivl_scope_t find_scope(ivl_design_s &des, const NetScope*cur);
static ivl_signal_t find_signal(ivl_design_s &des, const NetNet*net);
void add_root(ivl_design_s &des_, const NetScope *s);
};
/*
@ -570,6 +572,9 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
* Revision 1.66 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
* Revision 1.65 2001/10/16 02:19:27 steve
* Support IVL_LPM_DIVIDE for structural divide.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvp.c,v 1.12 2001/09/30 16:45:10 steve Exp $"
#ident "$Id: vvp.c,v 1.13 2001/10/19 21:53:24 steve Exp $"
#endif
/*
@ -67,7 +67,8 @@ int target_design(ivl_design_t des)
{
int rc;
ivl_scope_t root;
ivl_scope_t *roots;
unsigned nroots, i;
const char*path = ivl_design_flag(des, "-o");
assert(path);
@ -90,8 +91,9 @@ int target_design(ivl_design_t des)
draw_module_declarations(des);
root = ivl_design_root(des);
draw_scope(root, 0);
ivl_design_roots(des, &roots, &nroots);
for (i = 0; i < nroots; i++)
draw_scope(roots[i], 0);
rc = ivl_design_process(des, draw_process, 0);