Get rid of the STL vector template.

This commit is contained in:
steve 1999-06-15 03:44:53 +00:00
parent 430d7b22e4
commit d0afc9adee
8 changed files with 76 additions and 38 deletions

View File

@ -19,12 +19,12 @@
* 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.3 1999/02/21 17:01:57 steve Exp $" #ident "$Id: Module.h,v 1.4 1999/06/15 03:44:53 steve Exp $"
#endif #endif
# include <list> # include <list>
# include <map> # include <map>
# include <vector> # include "svector.h"
# include <string> # include <string>
class PExpr; class PExpr;
class PGate; class PGate;
@ -43,7 +43,7 @@ class Module {
explicit Module(const string&name, unsigned nports) explicit Module(const string&name, unsigned nports)
: ports(nports), name_(name) { } : ports(nports), name_(name) { }
vector<PWire*> ports; svector<PWire*> ports;
/* The module has parameters that are evaluated when the /* The module has parameters that are evaluated when the
module is elaborated. During parsing, I put the parameters module is elaborated. During parsing, I put the parameters
@ -81,6 +81,9 @@ class Module {
/* /*
* $Log: Module.h,v $ * $Log: Module.h,v $
* Revision 1.4 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.3 1999/02/21 17:01:57 steve * Revision 1.3 1999/02/21 17:01:57 steve
* Add support for module parameters. * Add support for module parameters.
* *

20
PUdp.h
View File

@ -19,14 +19,19 @@
* 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: PUdp.h,v 1.2 1998/12/01 00:42:13 steve Exp $" #ident "$Id: PUdp.h,v 1.3 1999/06/15 03:44:53 steve Exp $"
#endif #endif
# include <map> # include <map>
# include <vector> # include "svector.h"
# include <string> # include <string>
# include "verinum.h" # include "verinum.h"
svector<string>::svector<string>(unsigned size)
: nitems_(size), items_(new string[size])
{
}
/* /*
* This class represents a parsed UDP. This is a much simpler object * This class represents a parsed UDP. This is a much simpler object
* then a module or macromodule. * then a module or macromodule.
@ -54,12 +59,12 @@ class PUdp {
explicit PUdp(const string&n, unsigned nports) explicit PUdp(const string&n, unsigned nports)
: ports(nports), sequential(false), initial(verinum::Vx), name_(n) { } : ports(nports), sequential(false), initial(verinum::Vx), name_(n) { }
vector<string>ports; svector<string>ports;
bool sequential; bool sequential;
vector<string>tinput; svector<string>tinput;
vector<char> tcurrent; svector<char> tcurrent;
vector<char> toutput; svector<char> toutput;
verinum::V initial; verinum::V initial;
@ -77,6 +82,9 @@ class PUdp {
/* /*
* $Log: PUdp.h,v $ * $Log: PUdp.h,v $
* Revision 1.3 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.2 1998/12/01 00:42:13 steve * Revision 1.2 1998/12/01 00:42:13 steve
* Elaborate UDP devices, * Elaborate UDP devices,
* Support UDP type attributes, and * Support UDP type attributes, and

View File

@ -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.43 1999/06/13 23:51:16 steve Exp $" #ident "$Id: elaborate.cc,v 1.44 1999/06/15 03:44:53 steve Exp $"
#endif #endif
/* /*
@ -360,7 +360,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
// ports. If this is simply positional binding in the first // ports. If this is simply positional binding in the first
// place, then get the binding from the base class. // place, then get the binding from the base class.
if (pins_) { if (pins_) {
unsigned nexp = rmod->ports.size(); unsigned nexp = rmod->ports.count();
svector<PExpr*>*exp = new svector<PExpr*>(nexp); svector<PExpr*>*exp = new svector<PExpr*>(nexp);
// Scan the bindings, matching them with port names. // Scan the bindings, matching them with port names.
@ -401,9 +401,9 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
} else { } else {
if (pin_count() != rmod->ports.size()) { if (pin_count() != rmod->ports.count()) {
cerr << get_line() << ": Wrong number " cerr << get_line() << ": Wrong number "
"of parameters. Expecting " << rmod->ports.size() << "of parameters. Expecting " << rmod->ports.count() <<
", got " << pin_count() << "." ", got " << pin_count() << "."
<< endl; << endl;
des->errors += 1; des->errors += 1;
@ -412,7 +412,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
// No named bindings, just use the positional list I // No named bindings, just use the positional list I
// already have. // already have.
assert(pin_count() == rmod->ports.size()); assert(pin_count() == rmod->ports.count());
pins = get_pins(); pins = get_pins();
} }
@ -488,7 +488,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
void PGModule::elaborate_udp_(Design*des, PUdp*udp, const string&path) const void PGModule::elaborate_udp_(Design*des, PUdp*udp, const string&path) const
{ {
const string my_name = path+"."+get_name(); const string my_name = path+"."+get_name();
NetUDP*net = new NetUDP(my_name, udp->ports.size(), udp->sequential); NetUDP*net = new NetUDP(my_name, udp->ports.count(), udp->sequential);
net->set_attributes(udp->attributes); net->set_attributes(udp->attributes);
/* Run through the pins, making netlists for the pin /* Run through the pins, making netlists for the pin
@ -514,7 +514,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, const string&path) const
/* Build up the truth table for the netlist from the input /* Build up the truth table for the netlist from the input
strings. */ strings. */
for (unsigned idx = 0 ; idx < udp->tinput.size() ; idx += 1) { for (unsigned idx = 0 ; idx < udp->tinput.count() ; idx += 1) {
string input = udp->sequential string input = udp->sequential
? (string("") + udp->tcurrent[idx] + udp->tinput[idx]) ? (string("") + udp->tcurrent[idx] + udp->tinput[idx])
: udp->tinput[idx]; : udp->tinput[idx];
@ -1527,6 +1527,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.44 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.43 1999/06/13 23:51:16 steve * Revision 1.43 1999/06/13 23:51:16 steve
* l-value part select for procedural assignments. * l-value part select for procedural assignments.
* *

View File

@ -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: main.cc,v 1.15 1999/05/05 03:27:15 steve Exp $" #ident "$Id: main.cc,v 1.16 1999/06/15 03:44:53 steve Exp $"
#endif #endif
# include <stdio.h> # include <stdio.h>
@ -186,7 +186,7 @@ int main(int argc, char*argv[])
; mod != modules.end() ; mod != modules.end()
; mod ++ ) { ; mod ++ ) {
Module*cur = (*mod).second; Module*cur = (*mod).second;
if (cur->ports.size() == 0) if (cur->ports.count() == 0)
if (start_module == "") { if (start_module == "") {
start_module = cur->get_name(); start_module = cur->get_name();
} else { } else {
@ -249,6 +249,9 @@ int main(int argc, char*argv[])
/* /*
* $Log: main.cc,v $ * $Log: main.cc,v $
* Revision 1.16 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.15 1999/05/05 03:27:15 steve * Revision 1.15 1999/05/05 03:27:15 steve
* More intelligent selection of module to elaborate. * More intelligent selection of module to elaborate.
* *

View File

@ -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.cc,v 1.26 1999/06/13 23:51:16 steve Exp $" #ident "$Id: pform.cc,v 1.27 1999/06/15 03:44:53 steve Exp $"
#endif #endif
# include "compiler.h" # include "compiler.h"
@ -123,7 +123,7 @@ void pform_make_udp(string*name, list<string>*parms,
/* Put the parameters into a vector of wire descriptions. Look /* Put the parameters into a vector of wire descriptions. Look
in the map for the definitions of the name. */ in the map for the definitions of the name. */
vector<PWire*> pins (parms->size()); svector<PWire*> pins (parms->size());
{ list<string>::iterator cur; { list<string>::iterator cur;
unsigned idx; unsigned idx;
for (cur = parms->begin(), idx = 0 for (cur = parms->begin(), idx = 0
@ -136,10 +136,10 @@ void pform_make_udp(string*name, list<string>*parms,
/* Check that the output is an output and the inputs are /* Check that the output is an output and the inputs are
inputs. I can also make sure that only the single output is inputs. I can also make sure that only the single output is
declared a register, if anything. */ declared a register, if anything. */
assert(pins.size() > 0); assert(pins.count() > 0);
assert(pins[0]); assert(pins[0]);
assert(pins[0]->port_type == NetNet::POUTPUT); assert(pins[0]->port_type == NetNet::POUTPUT);
for (unsigned idx = 1 ; idx < pins.size() ; idx += 1) { for (unsigned idx = 1 ; idx < pins.count() ; idx += 1) {
assert(pins[idx]); assert(pins[idx]);
assert(pins[idx]->port_type == NetNet::PINPUT); assert(pins[idx]->port_type == NetNet::PINPUT);
assert(pins[idx]->type != NetNet::REG); assert(pins[idx]->type != NetNet::REG);
@ -149,18 +149,18 @@ void pform_make_udp(string*name, list<string>*parms,
they correspond to the inputs, output and output type. Make they correspond to the inputs, output and output type. Make
up vectors for the fully interpreted result that can be up vectors for the fully interpreted result that can be
placed in the PUdp object. */ placed in the PUdp object. */
vector<string> input (table->size()); svector<string> input (table->size());
vector<char> current (table->size()); svector<char> current (table->size());
vector<char> output (table->size()); svector<char> output (table->size());
{ unsigned idx = 0; { unsigned idx = 0;
for (list<string>::iterator cur = table->begin() for (list<string>::iterator cur = table->begin()
; cur != table->end() ; cur != table->end()
; cur ++, idx += 1) { ; cur ++, idx += 1) {
string tmp = *cur; string tmp = *cur;
assert(tmp.find(':') == (pins.size() - 1)); assert(tmp.find(':') == (pins.count() - 1));
input[idx] = tmp.substr(0, pins.size()-1); input[idx] = tmp.substr(0, pins.count()-1);
tmp = tmp.substr(pins.size()-1); tmp = tmp.substr(pins.count()-1);
if (pins[0]->type == NetNet::REG) { if (pins[0]->type == NetNet::REG) {
assert(tmp[0] == ':'); assert(tmp[0] == ':');
@ -210,7 +210,7 @@ void pform_make_udp(string*name, list<string>*parms,
udp->sequential = true; udp->sequential = true;
// Make the port list for the UDP // Make the port list for the UDP
for (unsigned idx = 0 ; idx < pins.size() ; idx += 1) for (unsigned idx = 0 ; idx < pins.count() ; idx += 1)
udp->ports[idx] = pins[idx]->name; udp->ports[idx] = pins[idx]->name;
udp->tinput = input; udp->tinput = input;
@ -590,6 +590,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.27 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.26 1999/06/13 23:51:16 steve * Revision 1.26 1999/06/13 23:51:16 steve
* l-value part select for procedural assignments. * l-value part select for procedural assignments.
* *

View File

@ -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: pform.h,v 1.19 1999/06/12 20:35:27 steve Exp $" #ident "$Id: pform.h,v 1.20 1999/06/15 03:44:53 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -33,7 +33,6 @@
# include <iostream.h> # include <iostream.h>
# include <string> # include <string>
# include <list> # include <list>
# include <vector>
# include <stdio.h> # include <stdio.h>
/* /*
@ -152,6 +151,9 @@ extern void pform_dump(ostream&out, Module*mod);
/* /*
* $Log: pform.h,v $ * $Log: pform.h,v $
* Revision 1.20 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.19 1999/06/12 20:35:27 steve * Revision 1.19 1999/06/12 20:35:27 steve
* parse more verilog. * parse more verilog.
* *

View File

@ -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.20 1999/06/13 23:51:16 steve Exp $" #ident "$Id: pform_dump.cc,v 1.21 1999/06/15 03:44:53 steve Exp $"
#endif #endif
/* /*
@ -441,7 +441,7 @@ void pform_dump(ostream&out, Module*mod)
void PUdp::dump(ostream&out) const void PUdp::dump(ostream&out) const
{ {
out << "primitive " << name_ << "(" << ports[0]; out << "primitive " << name_ << "(" << ports[0];
for (unsigned idx = 1 ; idx < ports.size() ; idx += 1) for (unsigned idx = 1 ; idx < ports.count() ; idx += 1)
out << ", " << ports[idx]; out << ", " << ports[idx];
out << ");" << endl; out << ");" << endl;
@ -449,7 +449,7 @@ void PUdp::dump(ostream&out) const
out << " reg " << ports[0] << ";" << endl; out << " reg " << ports[0] << ";" << endl;
out << " table" << endl; out << " table" << endl;
for (unsigned idx = 0 ; idx < tinput.size() ; idx += 1) { for (unsigned idx = 0 ; idx < tinput.count() ; idx += 1) {
out << " "; out << " ";
for (unsigned chr = 0 ; chr < tinput[idx].length() ; chr += 1) for (unsigned chr = 0 ; chr < tinput[idx].length() ; chr += 1)
out << " " << tinput[idx][chr]; out << " " << tinput[idx][chr];
@ -480,6 +480,9 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $Log: pform_dump.cc,v $
* Revision 1.21 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.20 1999/06/13 23:51:16 steve * Revision 1.20 1999/06/13 23:51:16 steve
* l-value part select for procedural assignments. * l-value part select for procedural assignments.
* *

View File

@ -21,7 +21,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: svector.h,v 1.3 1999/05/06 04:37:17 steve Exp $" #ident "$Id: svector.h,v 1.4 1999/06/15 03:44:53 steve Exp $"
#endif #endif
# include <assert.h> # include <assert.h>
@ -35,6 +35,8 @@
template <class TYPE> class svector { template <class TYPE> class svector {
public: public:
explicit svector() : nitems_(0), items_(0) { }
explicit svector(unsigned size) : nitems_(size), items_(new TYPE[size]) explicit svector(unsigned size) : nitems_(size), items_(new TYPE[size])
{ for (unsigned idx = 0 ; idx < size ; idx += 1) { for (unsigned idx = 0 ; idx < size ; idx += 1)
items_[idx] = 0; items_[idx] = 0;
@ -64,6 +66,17 @@ template <class TYPE> class svector {
~svector() { delete[]items_; } ~svector() { delete[]items_; }
svector<TYPE>& operator= (const svector<TYPE>&that)
{ if (&that == this) return *this;
delete[]items_;
nitems_ = that.nitems_;
items_ = new TYPE[nitems_];
for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
items_[idx] = that.items_[idx];
}
return *this;
}
unsigned count() const { return nitems_; } unsigned count() const { return nitems_; }
TYPE&operator[] (unsigned idx) TYPE&operator[] (unsigned idx)
@ -80,13 +93,13 @@ template <class TYPE> class svector {
unsigned nitems_; unsigned nitems_;
TYPE* items_; TYPE* items_;
private: // not implemented
svector<TYPE>& operator= (const svector<TYPE>&);
}; };
/* /*
* $Log: svector.h,v $ * $Log: svector.h,v $
* Revision 1.4 1999/06/15 03:44:53 steve
* Get rid of the STL vector template.
*
* Revision 1.3 1999/05/06 04:37:17 steve * Revision 1.3 1999/05/06 04:37:17 steve
* Get rid of list<lgate> types. * Get rid of list<lgate> types.
* *