Permalink
Browse files

Scope/module names are char* instead of string.

  • Loading branch information...
steve
steve committed Oct 20, 2001
1 parent acf3a4e commit 7a149a694319549f241ae099559c7379fb3f7ce1
Showing with 104 additions and 60 deletions.
  1. +11 −3 Module.cc
  2. +8 −4 Module.h
  3. +12 −9 elab_scope.cc
  4. +6 −3 elaborate.cc
  5. +20 −8 expr_synth.cc
  6. +10 −7 main.cc
  7. +6 −9 net_design.cc
  8. +7 −4 net_scope.cc
  9. +6 −4 netlist.h
  10. +7 −4 pform.cc
  11. +6 −3 pform.h
  12. +5 −2 xnfio.cc
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.15 2001/07/25 03:10:48 steve Exp $"
+#ident "$Id: Module.cc,v 1.16 2001/10/20 05:21:51 steve Exp $"
#endif
# include "config.h"
@@ -27,14 +27,19 @@
# include "PWire.h"
# include <assert.h>
-Module::Module(const string&name, const svector<Module::port_t*>*pp)
-: name_(name)
+Module::Module(const char*name, const svector<Module::port_t*>*pp)
+: name_(strdup(name))
{
if (pp)
ports_ = *pp;
}
+Module::~Module()
+{
+ free(name_);
+}
+
void Module::add_gate(PGate*gate)
{
gates_.push_back(gate);
@@ -137,6 +142,9 @@ const list<PProcess*>& Module::get_behaviors() const
/*
* $Log: Module.cc,v $
+ * Revision 1.16 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.15 2001/07/25 03:10:48 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)
View
@@ -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.21 2000/11/05 06:05:59 steve Exp $"
+#ident "$Id: Module.h,v 1.22 2001/10/20 05:21:51 steve Exp $"
#endif
# include <list>
@@ -58,7 +58,8 @@ class Module {
};
public:
- explicit Module(const string&name, const svector<port_t*>*);
+ explicit Module(const char*name, const svector<port_t*>*);
+ ~Module();
/* The module has parameters that are evaluated when the
@@ -88,7 +89,7 @@ class Module {
set by the `timescale directive. */
int time_unit, time_precision;
- const string&get_name() const { return name_; }
+ const char*mod_name() const { return name_; }
void add_gate(PGate*gate);
@@ -122,7 +123,7 @@ class Module {
bool elaborate_sig(Design*, NetScope*scope) const;
private:
- const string name_;
+ char* name_;
/* This is an array of port descriptors, which is in turn a
named array of PEident pointers. */
@@ -142,6 +143,9 @@ class Module {
/*
* $Log: Module.h,v $
+ * Revision 1.22 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.21 2000/11/05 06:05:59 steve
* Handle connectsion to internally unconnected modules (PR#38)
*
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.10 2001/10/09 02:01:04 steve Exp $"
+#ident "$Id: elab_scope.cc,v 1.11 2001/10/20 05:21:51 steve Exp $"
#endif
# include "config.h"
@@ -134,7 +134,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
for (tasks_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++ ) {
- NetScope*task_scope = new NetScope(scope, (*cur).first,
+ NetScope*task_scope = new NetScope(scope, (*cur).first.c_str(),
NetScope::TASK);
(*cur).second->elaborate_scope(des, task_scope);
}
@@ -149,7 +149,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
for (funcs_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++ ) {
- NetScope*func_scope = new NetScope(scope, (*cur).first,
+ NetScope*func_scope = new NetScope(scope, (*cur).first.c_str(),
NetScope::FUNC);
(*cur).second->elaborate_scope(des, func_scope);
}
@@ -197,7 +197,7 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
{
if (get_name() == "") {
cerr << get_line() << ": error: Instantiation of module "
- << mod->get_name() << " requires an instance name." << endl;
+ << mod->mod_name() << " requires an instance name." << endl;
des->errors += 1;
return;
}
@@ -227,11 +227,11 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
if (scn->type() != NetScope::MODULE)
continue;
- if (mod->get_name() != scn->module_name())
+ if (strcmp(mod->mod_name(), scn->module_name()) != 0)
continue;
cerr << get_line() << ": error: You cannot instantiate "
- << "module " << mod->get_name() << " within itself." << endl;
+ << "module " << mod->mod_name() << " within itself." << endl;
cerr << get_line() << ": : The offending instance is "
<< sc->name() << "." << get_name() << " within "
@@ -242,8 +242,8 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
}
// Create the new scope as a MODULE with my name.
- NetScope*my_scope = new NetScope(sc, get_name(), NetScope::MODULE);
- my_scope->set_module_name(mod->get_name().c_str());
+ NetScope*my_scope = new NetScope(sc, get_name().c_str(), NetScope::MODULE);
+ my_scope->set_module_name(mod->mod_name());
// Set time units and precision.
my_scope->time_unit(mod->time_unit);
@@ -349,7 +349,7 @@ void PBlock::elaborate_scope(Design*des, NetScope*scope) const
NetScope*my_scope = scope;
if (name_ != "") {
- my_scope = new NetScope(scope, name_, bl_type_==BL_PAR
+ my_scope = new NetScope(scope, name_.c_str(), bl_type_==BL_PAR
? NetScope::FORK_JOIN
: NetScope::BEGIN_END);
}
@@ -458,6 +458,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
/*
* $Log: elab_scope.cc,v $
+ * Revision 1.11 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.10 2001/10/09 02:01:04 steve
* Tasks can have sub-scopes.
*
View
@@ -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.221 2001/10/19 21:53:24 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.222 2001/10/20 05:21:51 steve Exp $"
#endif
# include "config.h"
@@ -2285,7 +2285,7 @@ struct root_elem {
Design* elaborate(const map<string,Module*>&modules,
const map<string,PUdp*>&primitives,
- list<string>roots)
+ list<const char*>roots)
{
svector<root_elem*> root_elems(roots.size());
bool rc = true;
@@ -2298,7 +2298,7 @@ Design* elaborate(const map<string,Module*>&modules,
modlist = &modules;
udplist = &primitives;
- for (list<string>::const_iterator root = roots.begin();
+ for (list<const char*>::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);
@@ -2372,6 +2372,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
+ * Revision 1.222 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.221 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: expr_synth.cc,v 1.26 2001/08/31 22:59:48 steve Exp $"
+#ident "$Id: expr_synth.cc,v 1.27 2001/10/20 05:21:51 steve Exp $"
#endif
# include "config.h"
@@ -353,27 +353,36 @@ NetNet* NetEBLogic::synthesize(Design*des)
NetNet* NetEConcat::synthesize(Design*des)
{
- NetScope*scope = des->find_root_scope();
+ /* First, synthesize the operands. */
+ NetNet**tmp = new NetNet*[parms_.count()];
+ for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
+ tmp[idx] = parms_[idx]->synthesize(des);
+
+ assert(tmp[0]);
+ NetScope*scope = tmp[0]->scope();
assert(scope);
- assert(repeat_ == 1);
+ /* Make a NetNet object to carry the output vector. */
string path = scope->name() + "." + scope->local_symbol();
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, expr_width());
osig->local_flag(true);
+ /* Connect the output vector to the operands. */
unsigned obit = 0;
for (unsigned idx = parms_.count() ; idx > 0 ; idx -= 1) {
- NetNet*tmp = parms_[idx-1]->synthesize(des);
- for (unsigned bit = 0 ; bit < tmp->pin_count() ; bit += 1) {
- connect(osig->pin(obit), tmp->pin(bit));
+ assert(tmp[idx-1]);
+
+ for (unsigned bit = 0; bit < tmp[idx-1]->pin_count(); bit += 1) {
+ connect(osig->pin(obit), tmp[idx-1]->pin(bit));
obit += 1;
}
- if (tmp->local_flag() && tmp->get_eref() == 0)
- delete tmp;
+ if (tmp[idx-1]->local_flag() && tmp[idx-1]->get_eref() == 0)
+ delete tmp[idx-1];
}
+ delete[]tmp;
return osig;
}
@@ -553,6 +562,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
+ * Revision 1.27 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.26 2001/08/31 22:59:48 steve
* synthesize the special case of compare with 0.
*
View
17 main.cc
@@ -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.48 2001/10/19 21:53:24 steve Exp $"
+#ident "$Id: main.cc,v 1.49 2001/10/20 05:21:51 steve Exp $"
#endif
# include "config.h"
@@ -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,
- list <string>root);
+ list <const char*>root);
extern void cprop(Design*des);
extern void synth(Design*des);
@@ -175,7 +175,7 @@ int main(int argc, char*argv[])
int opt;
unsigned flag_errors = 0;
queue<net_func> net_func_queue;
- list<string> roots;
+ list<const char*> roots;
struct tms cycles[5];
@@ -218,7 +218,7 @@ int main(int argc, char*argv[])
parm_to_flagmap(optarg);
break;
case 's':
- roots.push_back(string(optarg));
+ roots.push_back(optarg);
break;
case 'T':
if (strcmp(optarg,"min") == 0) {
@@ -359,10 +359,10 @@ int main(int argc, char*argv[])
}
for (mod = modules.begin(); mod != modules.end(); mod++) {
- if (mentioned_p[(*mod).second->get_name()] == false) {
+ if (mentioned_p[(*mod).second->mod_name()] == false) {
if (verbose_flag)
- cout << " " << (*mod).second->get_name();
- roots.push_back((*mod).second->get_name());
+ cout << " " << (*mod).second->mod_name();
+ roots.push_back((*mod).second->mod_name());
}
}
if (verbose_flag)
@@ -455,6 +455,9 @@ int main(int argc, char*argv[])
/*
* $Log: main.cc,v $
+ * Revision 1.49 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.48 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
View
@@ -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.21 2001/10/19 21:53:24 steve Exp $"
+#ident "$Id: net_design.cc,v 1.22 2001/10/20 05:21:51 steve Exp $"
#endif
# include "config.h"
@@ -77,11 +77,11 @@ unsigned long Design::scale_to_precision(unsigned long val,
return val;
}
-NetScope* Design::make_root_scope(const string&root)
+NetScope* Design::make_root_scope(const char*root)
{
NetScope *root_scope_;
root_scope_ = new NetScope(0, root, NetScope::MODULE);
- root_scope_->set_module_name(root.c_str());
+ root_scope_->set_module_name(root);
root_scopes_.push_back(root_scope_);
return root_scope_;
}
@@ -92,12 +92,6 @@ NetScope* Design::find_root_scope()
return root_scopes_.front();
}
-const NetScope* Design::find_root_scope() const
-{
- assert(root_scopes_.front());
- return root_scopes_.front();
-}
-
list<NetScope*> Design::find_root_scopes()
{
return root_scopes_;
@@ -495,6 +489,9 @@ void Design::delete_process(NetProcTop*top)
/*
* $Log: net_design.cc,v $
+ * Revision 1.22 2001/10/20 05:21:51 steve
+ * Scope/module names are char* instead of string.
+ *
* Revision 1.21 2001/10/19 21:53:24 steve
* Support multiple root modules (Philip Blundell)
*
Oops, something went wrong.

0 comments on commit 7a149a6

Please sign in to comment.