Skip to content

Commit

Permalink
Get rid of list<lgate> types.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed May 6, 1999
1 parent b2b9097 commit a568e52
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
18 changes: 10 additions & 8 deletions parse.y
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.21 1999/05/06 04:09:28 steve Exp $"
#ident "$Id: parse.y,v 1.22 1999/05/06 04:37:17 steve Exp $"
#endif

# include "parse_misc.h"
Expand All @@ -38,7 +38,7 @@ extern void lex_end_table();
list<PCase::Item*>*citems;

lgate*gate;
list<lgate>*gates;
svector<lgate>*gates;

PExpr*expr;
list<PExpr*>*exprs;
Expand Down Expand Up @@ -446,14 +446,16 @@ gate_instance

gate_instance_list
: gate_instance_list ',' gate_instance
{ list<lgate>*tmp = $1;
tmp->push_back(*$3);
delete $3;
$$ = tmp;
{ svector<lgate>*tmp1 = $1;
lgate*tmp2 = $3;
svector<lgate>*out = new svector<lgate> (*tmp1, *tmp2);
delete tmp1;
delete tmp2;
$$ = out;
}
| gate_instance
{ list<lgate>*tmp = new list<lgate>;
tmp->push_back(*$1);
{ svector<lgate>*tmp = new svector<lgate>(1);
(*tmp)[0] = *$1;
delete $1;
$$ = tmp;
}
Expand Down
21 changes: 10 additions & 11 deletions pform.cc
Expand Up @@ -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.13 1999/05/06 04:09:28 steve Exp $"
#ident "$Id: pform.cc,v 1.14 1999/05/06 04:37:17 steve Exp $"
#endif

# include "pform.h"
Expand Down Expand Up @@ -254,16 +254,13 @@ void pform_makegate(PGBuiltin::Type type,
}

void pform_makegates(PGBuiltin::Type type,
PExpr*delay, list<lgate>*gates)
PExpr*delay, svector<lgate>*gates)
{
unsigned long delay_val = delay? evaluate_delay(delay) : 0;
delete delay;

while (! gates->empty()) {
lgate cur = gates->front();
gates->pop_front();

pform_makegate(type, delay_val, cur);
for (unsigned idx = 0 ; idx < gates->count() ; idx += 0) {
pform_makegate(type, delay_val, (*gates)[idx]);
}

delete gates;
Expand All @@ -287,11 +284,10 @@ void pform_make_modgate(const string&type,
cur_module->add_gate(cur);
}

void pform_make_modgates(const string&type, list<lgate>*gates)
void pform_make_modgates(const string&type, svector<lgate>*gates)
{
while (! gates->empty()) {
lgate cur = gates->front();
gates->pop_front();
for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) {
lgate cur = (*gates)[idx];

vector<PExpr*>wires (cur.parms->size());
for (unsigned idx = 0 ; idx < wires.size() ; idx += 1) {
Expand Down Expand Up @@ -548,6 +544,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,

/*
* $Log: pform.cc,v $
* Revision 1.14 1999/05/06 04:37:17 steve
* Get rid of list<lgate> types.
*
* Revision 1.13 1999/05/06 04:09:28 steve
* Parse more constant expressions.
*
Expand Down
11 changes: 7 additions & 4 deletions pform.h
Expand Up @@ -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.10 1999/05/06 04:09:28 steve Exp $"
#ident "$Id: pform.h,v 1.11 1999/05/06 04:37:17 steve Exp $"
#endif

# include "netlist.h"
Expand Down Expand Up @@ -63,7 +63,7 @@ class PExpr;
*/

struct lgate {
lgate()
lgate(int =0)
: parms(0), lineno(0)
{ range[0] = 0;
range[1] = 0;
Expand Down Expand Up @@ -121,9 +121,9 @@ extern list<PWire*>* pform_make_udp_input_ports(list<string>*);
*/
extern void pform_makegates(PGBuiltin::Type type,
PExpr*delay,
list<lgate>*gates);
svector<lgate>*gates);

extern void pform_make_modgates(const string&type, list<lgate>*gates);
extern void pform_make_modgates(const string&type, svector<lgate>*gates);

/* Make a continuous assignment node, with optional bit- or part- select. */
extern void pform_make_pgassign(const string&lval, PExpr*rval);
Expand All @@ -141,6 +141,9 @@ extern void pform_dump(ostream&out, Module*mod);

/*
* $Log: pform.h,v $
* Revision 1.11 1999/05/06 04:37:17 steve
* Get rid of list<lgate> types.
*
* Revision 1.10 1999/05/06 04:09:28 steve
* Parse more constant expressions.
*
Expand Down
14 changes: 12 additions & 2 deletions svector.h
Expand Up @@ -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.2 1999/05/01 02:57:53 steve Exp $"
#ident "$Id: svector.h,v 1.3 1999/05/06 04:37:17 steve Exp $"
#endif

# include <assert.h>
Expand All @@ -35,7 +35,7 @@
template <class TYPE> class svector {

public:
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)
items_[idx] = 0;
}
Expand All @@ -55,6 +55,13 @@ template <class TYPE> class svector {
items_[l.nitems_+idx] = r[idx];
}

svector(const svector<TYPE>&l, TYPE r)
: nitems_(l.nitems_ + 1), items_(new TYPE[nitems_])
{ for (unsigned idx = 0 ; idx < l.nitems_ ; idx += 1)
items_[idx] = l[idx];
items_[nitems_-1] = r;
}

~svector() { delete[]items_; }

unsigned count() const { return nitems_; }
Expand All @@ -80,6 +87,9 @@ template <class TYPE> class svector {

/*
* $Log: svector.h,v $
* Revision 1.3 1999/05/06 04:37:17 steve
* Get rid of list<lgate> types.
*
* Revision 1.2 1999/05/01 02:57:53 steve
* Handle much more complex event expressions.
*
Expand Down

0 comments on commit a568e52

Please sign in to comment.