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
*/
#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
# include <list>
# include <map>
# include <vector>
# include "svector.h"
# include <string>
class PExpr;
class PGate;
@ -43,7 +43,7 @@ class Module {
explicit Module(const string&name, unsigned nports)
: ports(nports), name_(name) { }
vector<PWire*> ports;
svector<PWire*> ports;
/* The module has parameters that are evaluated when the
module is elaborated. During parsing, I put the parameters
@ -81,6 +81,9 @@ class Module {
/*
* $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
* 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
*/
#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
# include <map>
# include <vector>
# include "svector.h"
# include <string>
# 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
* then a module or macromodule.
@ -54,12 +59,12 @@ class PUdp {
explicit PUdp(const string&n, unsigned nports)
: ports(nports), sequential(false), initial(verinum::Vx), name_(n) { }
vector<string>ports;
svector<string>ports;
bool sequential;
vector<string>tinput;
vector<char> tcurrent;
vector<char> toutput;
svector<string>tinput;
svector<char> tcurrent;
svector<char> toutput;
verinum::V initial;
@ -77,6 +82,9 @@ class PUdp {
/*
* $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
* Elaborate UDP devices,
* Support UDP type attributes, and

View File

@ -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.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
/*
@ -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
// place, then get the binding from the base class.
if (pins_) {
unsigned nexp = rmod->ports.size();
unsigned nexp = rmod->ports.count();
svector<PExpr*>*exp = new svector<PExpr*>(nexp);
// 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 {
if (pin_count() != rmod->ports.size()) {
if (pin_count() != rmod->ports.count()) {
cerr << get_line() << ": Wrong number "
"of parameters. Expecting " << rmod->ports.size() <<
"of parameters. Expecting " << rmod->ports.count() <<
", got " << pin_count() << "."
<< endl;
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
// already have.
assert(pin_count() == rmod->ports.size());
assert(pin_count() == rmod->ports.count());
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
{
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);
/* 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
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("") + udp->tcurrent[idx] + udp->tinput[idx])
: udp->tinput[idx];
@ -1527,6 +1527,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $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
* 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
*/
#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
# include <stdio.h>
@ -186,7 +186,7 @@ int main(int argc, char*argv[])
; mod != modules.end()
; mod ++ ) {
Module*cur = (*mod).second;
if (cur->ports.size() == 0)
if (cur->ports.count() == 0)
if (start_module == "") {
start_module = cur->get_name();
} else {
@ -249,6 +249,9 @@ int main(int argc, char*argv[])
/*
* $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
* 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
*/
#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
# 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
in the map for the definitions of the name. */
vector<PWire*> pins (parms->size());
svector<PWire*> pins (parms->size());
{ list<string>::iterator cur;
unsigned idx;
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
inputs. I can also make sure that only the single output is
declared a register, if anything. */
assert(pins.size() > 0);
assert(pins.count() > 0);
assert(pins[0]);
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]->port_type == NetNet::PINPUT);
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
up vectors for the fully interpreted result that can be
placed in the PUdp object. */
vector<string> input (table->size());
vector<char> current (table->size());
vector<char> output (table->size());
svector<string> input (table->size());
svector<char> current (table->size());
svector<char> output (table->size());
{ unsigned idx = 0;
for (list<string>::iterator cur = table->begin()
; cur != table->end()
; cur ++, idx += 1) {
string tmp = *cur;
assert(tmp.find(':') == (pins.size() - 1));
assert(tmp.find(':') == (pins.count() - 1));
input[idx] = tmp.substr(0, pins.size()-1);
tmp = tmp.substr(pins.size()-1);
input[idx] = tmp.substr(0, pins.count()-1);
tmp = tmp.substr(pins.count()-1);
if (pins[0]->type == NetNet::REG) {
assert(tmp[0] == ':');
@ -210,7 +210,7 @@ void pform_make_udp(string*name, list<string>*parms,
udp->sequential = true;
// 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->tinput = input;
@ -590,6 +590,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/*
* $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
* 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
*/
#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
# include "netlist.h"
@ -33,7 +33,6 @@
# include <iostream.h>
# include <string>
# include <list>
# include <vector>
# include <stdio.h>
/*
@ -152,6 +151,9 @@ extern void pform_dump(ostream&out, Module*mod);
/*
* $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
* parse more verilog.
*

View File

@ -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.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
/*
@ -441,7 +441,7 @@ void pform_dump(ostream&out, Module*mod)
void PUdp::dump(ostream&out) const
{
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 << ");" << endl;
@ -449,7 +449,7 @@ void PUdp::dump(ostream&out) const
out << " reg " << ports[0] << ";" << endl;
out << " table" << endl;
for (unsigned idx = 0 ; idx < tinput.size() ; idx += 1) {
for (unsigned idx = 0 ; idx < tinput.count() ; idx += 1) {
out << " ";
for (unsigned chr = 0 ; chr < tinput[idx].length() ; chr += 1)
out << " " << tinput[idx][chr];
@ -480,6 +480,9 @@ void PUdp::dump(ostream&out) const
/*
* $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
* 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
*/
#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
# include <assert.h>
@ -35,6 +35,8 @@
template <class TYPE> class svector {
public:
explicit svector() : nitems_(0), items_(0) { }
explicit svector(unsigned size) : nitems_(size), items_(new TYPE[size])
{ for (unsigned idx = 0 ; idx < size ; idx += 1)
items_[idx] = 0;
@ -64,6 +66,17 @@ template <class TYPE> class svector {
~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_; }
TYPE&operator[] (unsigned idx)
@ -80,13 +93,13 @@ template <class TYPE> class svector {
unsigned nitems_;
TYPE* items_;
private: // not implemented
svector<TYPE>& operator= (const svector<TYPE>&);
};
/*
* $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
* Get rid of list<lgate> types.
*