diff --git a/PDelays.cc b/PDelays.cc index c51c1f5df..40ea8b262 100644 --- a/PDelays.cc +++ b/PDelays.cc @@ -55,12 +55,14 @@ void PDelays::set_delay(PExpr*del) } -void PDelays::set_delays(const svector*del, bool df) +void PDelays::set_delays(const list*del, bool df) { assert(del); - assert(del->count() <= 3); - for (unsigned idx = 0 ; idx < del->count() ; idx += 1) - delay_[idx] = (*del)[idx]; + assert(del->size() <= 3); + + list::const_iterator cur = del->begin(); + for (unsigned idx = 0 ; cur != del->end() ; idx += 1, ++cur) + delay_[idx] = *cur; delete_flag_ = df; } diff --git a/PDelays.h b/PDelays.h index 78a764f36..00e061807 100644 --- a/PDelays.h +++ b/PDelays.h @@ -21,6 +21,7 @@ # include "svector.h" # include +# include # include #ifdef __GNUC__ @@ -48,7 +49,7 @@ class PDelays { this object takes ownership of the expressions, and will delete it in the destructor. */ void set_delay(PExpr*); - void set_delays(const svector*del, bool delete_flag=true); + void set_delays(const list*del, bool delete_flag=true); unsigned delay_count() const; diff --git a/PExpr.cc b/PExpr.cc index 98617deff..35ec1b336 100644 --- a/PExpr.cc +++ b/PExpr.cc @@ -26,6 +26,7 @@ # include "PWire.h" # include "Module.h" # include "netmisc.h" +# include "util.h" # include PExpr::PExpr() @@ -161,14 +162,24 @@ PECallFunction::PECallFunction(perm_string n) } // NOTE: Anachronism. Try to work all use of svector out. -PECallFunction::PECallFunction(const pform_name_t&n, const svector &parms) -: path_(n), parms_(vector_from_svector(parms)) +PECallFunction::PECallFunction(const pform_name_t&n, const list &parms) +: path_(n), parms_(parms.size()) { + int tmp_idx = 0; + assert(parms_.size() == parms.size()); + for (list::const_iterator idx = parms.begin() + ; idx != parms.end() ; ++idx) + parms_[tmp_idx++] = *idx; } -PECallFunction::PECallFunction(perm_string n, const svector&parms) -: path_(pn_from_ps(n)), parms_(vector_from_svector(parms)) +PECallFunction::PECallFunction(perm_string n, const list&parms) +: path_(pn_from_ps(n)), parms_(parms.size()) { + int tmp_idx = 0; + assert(parms_.size() == parms.size()); + for (list::const_iterator idx = parms.begin() + ; idx != parms.end() ; ++idx) + parms_[tmp_idx++] = *idx; } PECallFunction::~PECallFunction() @@ -191,9 +202,14 @@ bool PECallFunction::has_aa_term(Design*des, NetScope*scope) const return flag; } -PEConcat::PEConcat(const svector&p, PExpr*r) -: parms_(p), tested_widths_(p.count()), repeat_(r) +PEConcat::PEConcat(const list&p, PExpr*r) +: parms_(p.size()), tested_widths_(p.size()), repeat_(r) { + int tmp_idx = 0; + assert(parms_.size() == p.size()); + for (list::const_iterator idx = p.begin() + ; idx != p.end() ; ++idx) + parms_[tmp_idx++] = *idx; } PEConcat::~PEConcat() @@ -203,7 +219,7 @@ PEConcat::~PEConcat() void PEConcat::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) { - for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { parms_[idx]->declare_implicit_nets(scope, type); } } @@ -211,7 +227,7 @@ void PEConcat::declare_implicit_nets(LexicalScope*scope, NetNet::Type type) bool PEConcat::has_aa_term(Design*des, NetScope*scope) const { bool flag = false; - for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { flag = parms_[idx]->has_aa_term(des, scope) || flag; } if (repeat_) diff --git a/PExpr.h b/PExpr.h index 6141f6cc9..6c3b68022 100644 --- a/PExpr.h +++ b/PExpr.h @@ -160,7 +160,7 @@ ostream& operator << (ostream&, const PExpr&); class PEConcat : public PExpr { public: - PEConcat(const svector&p, PExpr*r =0); + PEConcat(const list&p, PExpr*r =0); ~PEConcat(); virtual verinum* eval_const(Design*des, NetScope*sc) const; @@ -187,7 +187,7 @@ class PEConcat : public PExpr { NetNet* elaborate_lnet_common_(Design*des, NetScope*scope, bool bidirectional_flag) const; private: - svectorparms_; + vectorparms_; std::valarraytested_widths_; PExpr*repeat_; @@ -661,8 +661,8 @@ class PECallFunction : public PExpr { explicit PECallFunction(perm_string n); // svector versions. Should be removed! - explicit PECallFunction(const pform_name_t&n, const svector &parms); - explicit PECallFunction(perm_string n, const svector &parms); + explicit PECallFunction(const pform_name_t&n, const list &parms); + explicit PECallFunction(perm_string n, const list &parms); ~PECallFunction(); diff --git a/PGate.cc b/PGate.cc index ae64a4c48..9ec25d33f 100644 --- a/PGate.cc +++ b/PGate.cc @@ -24,29 +24,42 @@ # include "verinum.h" # include -PGate::PGate(perm_string name, - svector*pins, - const svector*del) -: name_(name), pins_(pins) +void PGate::set_pins_(list*pins) { + assert(pins); + assert(pins->size() == pins_.size()); + + for (size_t idx = 0 ; idx < pins_.size() ; idx += 1) { + pins_[idx] = pins->front(); + pins->pop_front(); + } + + assert(pins->empty()); + delete pins; +} + +PGate::PGate(perm_string name, list*pins, const list*del) +: name_(name), pins_(pins? pins->size() : 0) +{ + if (pins) set_pins_(pins); if (del) delay_.set_delays(del); str0_ = IVL_DR_STRONG; str1_ = IVL_DR_STRONG; } -PGate::PGate(perm_string name, - svector*pins, - PExpr*del) -: name_(name), pins_(pins) +PGate::PGate(perm_string name, list*pins, PExpr*del) +: name_(name), pins_(pins? pins->size() : 0) { + if (pins) set_pins_(pins); if (del) delay_.set_delay(del); str0_ = IVL_DR_STRONG; str1_ = IVL_DR_STRONG; } -PGate::PGate(perm_string name, svector*pins) -: name_(name), pins_(pins) +PGate::PGate(perm_string name, list*pins) +: name_(name), pins_(pins? pins->size() : 0) { + if (pins) set_pins_(pins); str0_ = IVL_DR_STRONG; str1_ = IVL_DR_STRONG; } @@ -104,16 +117,16 @@ unsigned PGate::delay_count() const return delay_.delay_count(); } -PGAssign::PGAssign(svector*pins) +PGAssign::PGAssign(list*pins) : PGate(perm_string(), pins) { - assert(pins->count() == 2); + assert(pin_count() == 2); } -PGAssign::PGAssign(svector*pins, svector*dels) +PGAssign::PGAssign(list*pins, list*dels) : PGate(perm_string(), pins, dels) { - assert(pins->count() == 2); + assert(pin_count() == 2); } PGAssign::~PGAssign() @@ -121,14 +134,14 @@ PGAssign::~PGAssign() } PGBuiltin::PGBuiltin(Type t, perm_string name, - svector*pins, - svector*del) + list*pins, + list*del) : PGate(name, pins, del), type_(t), msb_(0), lsb_(0) { } PGBuiltin::PGBuiltin(Type t, perm_string name, - svector*pins, + list*pins, PExpr*del) : PGate(name, pins, del), type_(t), msb_(0), lsb_(0) { @@ -246,7 +259,7 @@ const char* PGBuiltin::gate_name() const return ""; } -PGModule::PGModule(perm_string type, perm_string name, svector*pins) +PGModule::PGModule(perm_string type, perm_string name, list*pins) : PGate(name, pins), overrides_(0), pins_(0), npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0) { @@ -265,7 +278,7 @@ PGModule::~PGModule() { } -void PGModule::set_parameters(svector*o) +void PGModule::set_parameters(list*o) { assert(overrides_ == 0); overrides_ = o; diff --git a/PGate.h b/PGate.h index 3f4cceaf0..6de2c3f58 100644 --- a/PGate.h +++ b/PGate.h @@ -26,6 +26,8 @@ # include "PDelays.h" # include "netlist.h" # include +# include +# include # include class PExpr; class PUdp; @@ -48,13 +50,13 @@ class Module; class PGate : public LineInfo { public: - explicit PGate(perm_string name, svector*pins, - const svector*del); + explicit PGate(perm_string name, list*pins, + const list*del); - explicit PGate(perm_string name, svector*pins, + explicit PGate(perm_string name, list*pins, PExpr*del); - explicit PGate(perm_string name, svector*pins); + explicit PGate(perm_string name, list*pins); virtual ~PGate(); @@ -70,8 +72,8 @@ class PGate : public LineInfo { unsigned delay_count() const; - unsigned pin_count() const { return pins_? pins_->count() : 0; } - PExpr*pin(unsigned idx) const { return (*pins_)[idx]; } + unsigned pin_count() const { return pins_.size(); } + PExpr*pin(unsigned idx) const { return pins_[idx]; } ivl_drive_t strength0() const; ivl_drive_t strength1() const; @@ -87,7 +89,7 @@ class PGate : public LineInfo { virtual bool elaborate_sig(Design*des, NetScope*scope) const; protected: - const svector& get_pins() const { return *pins_; } + const vector& get_pins() const { return pins_; } void dump_pins(ostream&out) const; void dump_delays(ostream&out) const; @@ -95,10 +97,12 @@ class PGate : public LineInfo { private: perm_string name_; PDelays delay_; - svector*pins_; + vectorpins_; ivl_drive_t str0_, str1_; + void set_pins_(list*pins); + private: // not implemented PGate(const PGate&); PGate& operator= (const PGate&); @@ -111,8 +115,8 @@ class PGate : public LineInfo { class PGAssign : public PGate { public: - explicit PGAssign(svector*pins); - explicit PGAssign(svector*pins, svector*dels); + explicit PGAssign(list*pins); + explicit PGAssign(list*pins, list*dels); ~PGAssign(); void dump(ostream&out, unsigned ind =4) const; @@ -143,10 +147,10 @@ class PGBuiltin : public PGate { public: explicit PGBuiltin(Type t, perm_string name, - svector*pins, - svector*del); + list*pins, + list*del); explicit PGBuiltin(Type t, perm_string name, - svector*pins, + list*pins, PExpr*del); ~PGBuiltin(); @@ -189,7 +193,7 @@ class PGModule : public PGate { // If the binding of ports is by position, this constructor // builds everything all at once. explicit PGModule(perm_string type, perm_string name, - svector*pins); + list*pins); // If the binding of ports is by name, this constructor takes // the bindings and stores them for later elaboration. @@ -201,7 +205,7 @@ class PGModule : public PGate { // Parameter overrides can come as an ordered list, or a set // of named expressions. - void set_parameters(svector*o); + void set_parameters(list*o); void set_parameters(named*pa, unsigned npa); // Modules can be instantiated in ranges. The parser uses this @@ -219,7 +223,7 @@ class PGModule : public PGate { private: perm_string type_; - svector*overrides_; + list*overrides_; named*pins_; unsigned npins_; diff --git a/PTask.h b/PTask.h index 949c6d20c..df1dee628 100644 --- a/PTask.h +++ b/PTask.h @@ -24,6 +24,7 @@ # include "svector.h" # include "StringHeap.h" # include +# include class Design; class NetScope; class PWire; @@ -44,7 +45,7 @@ enum PTaskFuncEnum { struct PTaskFuncArg { PTaskFuncEnum type; - svector*range; + vector*range; }; /* diff --git a/Statement.cc b/Statement.cc index fc6670e38..88581712f 100644 --- a/Statement.cc +++ b/Statement.cc @@ -114,14 +114,26 @@ void PBlock::set_statement(const svector&st) list_ = st; } -PCallTask::PCallTask(const pform_name_t&n, const svector&p) -: path_(n), parms_(p) +PCallTask::PCallTask(const pform_name_t&n, const list&p) +: path_(n), parms_(p.size()) { + list::const_iterator cur = p.begin(); + for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) { + parms_[idx] = *cur; + ++cur; + } + assert(cur == p.end()); } -PCallTask::PCallTask(perm_string n, const svector&p) -: parms_(p) +PCallTask::PCallTask(perm_string n, const list&p) +: parms_(p.size()) { + list::const_iterator cur = p.begin(); + for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) { + parms_[idx] = *cur; + ++cur; + } + assert(cur == p.end()); path_.push_back(name_component_t(n)); } diff --git a/Statement.h b/Statement.h index f358ae7e0..ef6f2b22d 100644 --- a/Statement.h +++ b/Statement.h @@ -20,6 +20,7 @@ */ # include +# include # include "ivl_target.h" # include "svector.h" # include "StringHeap.h" @@ -181,21 +182,21 @@ class PBlock : public PScope, public Statement { class PCallTask : public Statement { public: - explicit PCallTask(const pform_name_t&n, const svector&parms); - explicit PCallTask(perm_string n, const svector&parms); + explicit PCallTask(const pform_name_t&n, const list&parms); + explicit PCallTask(perm_string n, const list&parms); ~PCallTask(); const pform_name_t& path() const; - unsigned nparms() const { return parms_.count(); } + unsigned nparms() const { return parms_.size(); } PExpr*&parm(unsigned idx) - { assert(idx < parms_.count()); + { assert(idx < parms_.size()); return parms_[idx]; } PExpr* parm(unsigned idx) const - { assert(idx < parms_.count()); + { assert(idx < parms_.size()); return parms_[idx]; } @@ -207,14 +208,14 @@ class PCallTask : public Statement { NetProc* elaborate_usr(Design*des, NetScope*scope) const; pform_name_t path_; - svector parms_; + vector parms_; }; class PCase : public Statement { public: struct Item { - svectorexpr; + listexpr; Statement*stat; }; diff --git a/elab_expr.cc b/elab_expr.cc index 4a1e1385f..bb0f97392 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1617,7 +1617,7 @@ unsigned PEConcat::test_width(Design*des, NetScope*scope, expr_type_ = IVL_VT_LOGIC; unsigned count_width = 0; - for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { tested_widths_[idx] = parms_[idx]->test_width(des, scope, 0, 0, expr_type__, unsized_flag); count_width += tested_widths_[idx]; } @@ -1730,10 +1730,10 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope, unsigned wid_sum = 0; unsigned parm_cnt = 0; - svector parms(parms_.count()); + svector parms(parms_.size()); /* Elaborate all the parameters and attach them to the concat node. */ - for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { if (parms_[idx] == 0) { cerr << get_fileline() << ": error: Missing expression " << (idx+1) << " of concatenation list." << endl; diff --git a/elab_lval.cc b/elab_lval.cc index cb7bfd2fb..5ef8f8957 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -107,7 +107,7 @@ NetAssign_* PEConcat::elaborate_lval(Design*des, NetAssign_*res = 0; - for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { if (parms_[idx] == 0) { cerr << get_fileline() << ": error: Empty expressions " diff --git a/elab_net.cc b/elab_net.cc index a9cdb25fa..8442de6e7 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -41,7 +41,7 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope, { assert(scope); - svectornets (parms_.count()); + svectornets (parms_.size()); unsigned width = 0; unsigned errors = 0; diff --git a/elab_pexpr.cc b/elab_pexpr.cc index 1231119a7..228549650 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -144,14 +144,14 @@ NetEConcat* PEConcat::elaborate_pexpr(Design*des, NetScope*scope) const } /* Make the empty concat expression. */ - NetEConcat*tmp = new NetEConcat(parms_.count(), repeat); + NetEConcat*tmp = new NetEConcat(parms_.size(), repeat); tmp->set_line(*this); /* Elaborate all the operands and attach them to the concat node. Use the elaborate_pexpr method instead of the elaborate_expr method. */ bool fail = false; - for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) { assert(parms_[idx]); NetExpr*ex = parms_[idx]->elaborate_pexpr(des, scope); if (ex == 0) continue; diff --git a/elab_scope.cc b/elab_scope.cc index 9814feabe..a805e3294 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -1321,17 +1321,17 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s assert(parms_ == 0); list::const_iterator cur = mod->param_names.begin(); - unsigned jdx = 0; + list::const_iterator jdx = overrides_->begin(); for (;;) { - if (jdx >= overrides_->count()) + if (jdx == overrides_->end()) break; if (cur == mod->param_names.end()) break; - replace[*cur] = (*overrides_)[jdx]; + replace[*cur] = *jdx; - jdx += 1; - cur ++; + ++ jdx; + ++ cur; } } diff --git a/elab_sig.cc b/elab_sig.cc index 3f393b045..98b97ddbb 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -468,15 +468,16 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const case PTF_REG: case PTF_REG_S: if (return_type_.range) { - probe_expr_width(des, scope, (*return_type_.range)[0]); - probe_expr_width(des, scope, (*return_type_.range)[1]); + ivl_assert(*this, return_type_.range->size() == 2); + probe_expr_width(des, scope, return_type_.range->at(0)); + probe_expr_width(des, scope, return_type_.range->at(1)); need_constant_expr = true; NetExpr*me = elab_and_eval(des, scope, - (*return_type_.range)[0], -1); + return_type_.range->at(0), -1); assert(me); NetExpr*le = elab_and_eval(des, scope, - (*return_type_.range)[1], -1); + return_type_.range->at(1), -1); assert(le); need_constant_expr = false; diff --git a/elaborate.cc b/elaborate.cc index 0815917c2..6e23f40a5 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -1105,7 +1105,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const // order of the declaration. If the source instantiation uses // bind by order, this is the same as the source list. Otherwise, // the source list is rearranged by name binding into this list. - svectorpins (rmod->port_count()); + vectorpins (rmod->port_count()); // If the instance has a pins_ member, then we know we are // binding by name. Therefore, make up a pins array that @@ -1204,7 +1204,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const // to a concatenation, or connected to an internally // unconnected port. - for (unsigned idx = 0 ; idx < pins.count() ; idx += 1) { + for (unsigned idx = 0 ; idx < pins.size() ; idx += 1) { // Skip unconnected module ports. This happens when a // null parameter is passed in. @@ -1748,7 +1748,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const module or primitive, it interprets them as parameter overrides. Correct that misconception here. */ if (overrides_) { - if (overrides_->count() > 2) { + if (overrides_->size() > 2) { cerr << get_fileline() << ": error: UDPs take at most two " "delay arguments." << endl; des->errors += 1; @@ -1782,7 +1782,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const // bind by order, this is the same as the source // list. Otherwise, the source list is rearranged by name // binding into this list. - svectorpins; + vectorpins; // Detect binding by name. If I am binding by name, then make // up a pins array that reflects the positions of the named @@ -1790,7 +1790,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const // place, then get the binding from the base class. if (pins_) { unsigned nexp = udp->ports.count(); - pins = svector(nexp); + pins = vector(nexp); // Scan the bindings, matching them with port names. for (unsigned idx = 0 ; idx < npins_ ; idx += 1) { @@ -2488,10 +2488,10 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const for (unsigned idx = 0 ; idx < items_->count() ; idx += 1) { PCase::Item*cur = (*items_)[idx]; - if (cur->expr.count() == 0) + if (cur->expr.empty()) icount += 1; else - icount += cur->expr.count(); + icount += cur->expr.size(); } NetCase*res = new NetCase(type_, expr, icount); @@ -2507,7 +2507,7 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const assert(inum < icount); PCase::Item*cur = (*items_)[idx]; - if (cur->expr.count() == 0) { + if (cur->expr.empty()) { /* If there are no expressions, then this is the default case. */ NetProc*st = 0; @@ -2517,17 +2517,19 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const res->set_case(inum, 0, st); inum += 1; - } else for (unsigned e = 0; e < cur->expr.count(); e += 1) { + } else for (list::iterator idx_expr = cur->expr.begin() + ; idx_expr != cur->expr.end() ; ++idx_expr) { /* If there are one or more expressions, then iterate over the guard expressions, elaborating a separate case for each. (Yes, the statement will be elaborated again for each.) */ + PExpr*cur_expr = *idx_expr; NetExpr*gu = 0; NetProc*st = 0; - assert(cur->expr[e]); - probe_expr_width(des, scope, cur->expr[e]); - gu = elab_and_eval(des, scope, cur->expr[e], -1); + assert(cur_expr); + probe_expr_width(des, scope, cur_expr); + gu = elab_and_eval(des, scope, cur_expr, -1); if (cur->stat) st = cur->stat->elaborate(des, scope); diff --git a/eval.cc b/eval.cc index 1bf506552..84dbc5aea 100644 --- a/eval.cc +++ b/eval.cc @@ -147,7 +147,7 @@ verinum* PEConcat::eval_const(Design*des, NetScope*scope) const if (accum == 0) return 0; - for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) { verinum*tmp = parms_[idx]->eval_const(des, scope); if (tmp == 0) { diff --git a/parse.y b/parse.y index 298e824b6..35b105aa4 100644 --- a/parse.y +++ b/parse.y @@ -38,7 +38,7 @@ extern void lex_end_table(); bool have_timeunit_decl = false; bool have_timeprec_decl = false; -static svector* param_active_range = 0; +static list* param_active_range = 0; static bool param_active_signed = false; static ivl_variable_type_t param_active_type = IVL_VT_LOGIC; @@ -48,7 +48,7 @@ static struct { NetNet::PortType port_type; ivl_variable_type_t var_type; bool sign_flag; - svector* range; + list* range; } port_declaration_context = {NetNet::NONE, NetNet::NOT_A_PORT, IVL_VT_NO_TYPE, false, 0}; @@ -106,16 +106,41 @@ static list >* make_port_list(list* make_range_from_width(uint64_t wid) +static list* make_range_from_width(uint64_t wid) { - svector*range = new svector(2); + list*range = new list; - (*range)[0] = new PENumber(new verinum(wid-1, integer_width)); - (*range)[1] = new PENumber(new verinum((uint64_t)0, integer_width)); + range->push_back(new PENumber(new verinum(wid-1, integer_width))); + range->push_back(new PENumber(new verinum((uint64_t)0, integer_width))); return range; } +/* + * Make a rqange vector from an existing pair of expressions. + */ +static vector* make_range_vector(list*that) +{ + assert(that->size() == 2); + vector*tmp = new vector (2); + tmp->at(0) = that->front(); + tmp->at(1) = that->back(); + delete that; + return tmp; +} + +/* + * Make a range vector from a width. Generate the msb and lsb + * expressions to get the canonical range for the given width. + */ +static vector* make_range_vector(uint64_t wid) +{ + vector*tmp = new vector (2); + tmp->at(0) = new PENumber(new verinum(wid-1, integer_width)); + tmp->at(1) = new PENumber(new verinum((uint64_t)0, integer_width)); + return tmp; +} + static list* list_from_identifier(char*id) { list*tmp = new list; @@ -131,15 +156,12 @@ static list* list_from_identifier(list*tmp, char*id) return tmp; } -static svector* copy_range(svector* orig) +static list* copy_range(list* orig) { - svector*copy = 0; + list*copy = 0; - if (orig) { - copy = new svector(2); - (*copy)[0] = (*orig)[0]; - (*copy)[1] = (*orig)[1]; - } + if (orig) + copy = new list (*orig); return copy; } @@ -156,7 +178,7 @@ template void append(vector&out, const vector&in) */ static PECallFunction*make_call_function(perm_string tn, PExpr*arg) { - svector parms(1); + vector parms(1); parms[0] = arg; PECallFunction*tmp = new PECallFunction(tn, parms); return tmp; @@ -164,7 +186,7 @@ static PECallFunction*make_call_function(perm_string tn, PExpr*arg) static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2) { - svector parms(2); + vector parms(2); parms[0] = arg1; parms[1] = arg2; PECallFunction*tmp = new PECallFunction(tn, parms); @@ -229,7 +251,7 @@ static named_number_t* make_named_number(perm_string name, const verinum&val) struct parmvalue_t*parmvalue; PExpr*expr; - svector*exprs; + list*exprs; svector*event_expr; @@ -769,39 +791,39 @@ defparam_assign_list delay1 : '#' delay_value_simple - { svector*tmp = new svector(1); - (*tmp)[0] = $2; + { list*tmp = new list; + tmp->push_back($2); $$ = tmp; } | '#' '(' delay_value ')' - { svector*tmp = new svector(1); - (*tmp)[0] = $3; + { list*tmp = new list; + tmp->push_back($3); $$ = tmp; } ; delay3 : '#' delay_value_simple - { svector*tmp = new svector(1); - (*tmp)[0] = $2; + { list*tmp = new list; + tmp->push_back($2); $$ = tmp; } | '#' '(' delay_value ')' - { svector*tmp = new svector(1); - (*tmp)[0] = $3; + { list*tmp = new list; + tmp->push_back($3); $$ = tmp; } | '#' '(' delay_value ',' delay_value ')' - { svector*tmp = new svector(2); - (*tmp)[0] = $3; - (*tmp)[1] = $5; + { list*tmp = new list; + tmp->push_back($3); + tmp->push_back($5); $$ = tmp; } | '#' '(' delay_value ',' delay_value ',' delay_value ')' - { svector*tmp = new svector(3); - (*tmp)[0] = $3; - (*tmp)[1] = $5; - (*tmp)[2] = $7; + { list*tmp = new list; + tmp->push_back($3); + tmp->push_back($5); + tmp->push_back($7); $$ = tmp; } ; @@ -812,17 +834,17 @@ delay3_opt ; delay_value_list - : delay_value - { svector*tmp = new svector(1); - (*tmp)[0] = $1; - $$ = tmp; - } - | delay_value_list ',' delay_value - { svector*tmp = new svector(*$1, $3); - delete $1; - $$ = tmp; - } - ; + : delay_value + { list*tmp = new list; + tmp->push_back($1); + $$ = tmp; + } + | delay_value_list ',' delay_value + { list*tmp = $1; + tmp->push_back($3); + $$ = tmp; + } + ; delay_value : expression @@ -1360,41 +1382,40 @@ expr_mintypmax expression list, so can be used where nul expressions are not allowed. */ expression_list_with_nuls - : expression_list_with_nuls ',' expression - { svector*tmp = new svector(*$1, $3); - delete $1; - $$ = tmp; - } - | expression - { svector*tmp = new svector(1); - (*tmp)[0] = $1; - $$ = tmp; - } - | - { svector*tmp = new svector(1); - (*tmp)[0] = 0; - $$ = tmp; - } - - | expression_list_with_nuls ',' - { svector*tmp = new svector(*$1, 0); - delete $1; - $$ = tmp; - } + : expression_list_with_nuls ',' expression + { list*tmp = $1; + tmp->push_back($3); + $$ = tmp; + } + | expression + { list*tmp = new list; + tmp->push_back($1); + $$ = tmp; + } + | + { list*tmp = new list; + tmp->push_back(0); + $$ = tmp; + } + | expression_list_with_nuls ',' + { list*tmp = $1; + tmp->push_back(0); + $$ = tmp; + } ; expression_list_proper - : expression_list_proper ',' expression - { svector*tmp = new svector(*$1, $3); - delete $1; - $$ = tmp; - } - | expression - { svector*tmp = new svector(1); - (*tmp)[0] = $1; - $$ = tmp; - } - ; + : expression_list_proper ',' expression + { list*tmp = $1; + tmp->push_back($3); + $$ = tmp; + } + | expression + { list*tmp = new list; + tmp->push_back($1); + $$ = tmp; + } + ; expr_primary : number @@ -1695,11 +1716,12 @@ gate_instance | IDENTIFIER range '(' expression_list_with_nuls ')' { lgate*tmp = new lgate; - svector*rng = $2; + list*rng = $2; tmp->name = $1; tmp->parms = $4; - tmp->range[0] = (*rng)[0]; - tmp->range[1] = (*rng)[1]; + tmp->range[0] = rng->front(); rng->pop_front(); + tmp->range[1] = rng->front(); rng->pop_front(); + assert(rng->empty()); tmp->file = @1.text; tmp->lineno = @1.first_line; delete[]$1; @@ -1719,12 +1741,13 @@ gate_instance | IDENTIFIER range { lgate*tmp = new lgate; - svector*rng = $2; + list*rng = $2; tmp->name = $1; tmp->parms = 0; tmp->parms_by_name = 0; - tmp->range[0] = (*rng)[0]; - tmp->range[1] = (*rng)[1]; + tmp->range[0] = rng->front(); rng->pop_front(); + tmp->range[1] = rng->front(); rng->pop_front(); + assert(rng->empty()); tmp->file = @1.text; tmp->lineno = @1.first_line; delete[]$1; @@ -1747,12 +1770,13 @@ gate_instance | IDENTIFIER range '(' port_name_list ')' { lgate*tmp = new lgate; - svector*rng = $2; + list*rng = $2; tmp->name = $1; tmp->parms = 0; tmp->parms_by_name = $4; - tmp->range[0] = (*rng)[0]; - tmp->range[1] = (*rng)[1]; + tmp->range[0] = rng->front(); rng->pop_front(); + tmp->range[1] = rng->front(); rng->pop_front(); + assert(rng->empty()); tmp->file = @1.text; tmp->lineno = @1.first_line; delete[]$1; @@ -2011,7 +2035,7 @@ port_declaration | attribute_list_opt K_input atom2_type signed_unsigned_opt IDENTIFIER { Module::port_t*ptmp; perm_string name = lex_strings.make($5); - svector*use_range = make_range_from_width($3); + list*use_range = make_range_from_width($3); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::PINPUT, @@ -2105,7 +2129,7 @@ port_declaration | attribute_list_opt K_output atom2_type signed_unsigned_opt IDENTIFIER { Module::port_t*ptmp; perm_string name = lex_strings.make($5); - svector*use_range = make_range_from_width($3); + list*use_range = make_range_from_width($3); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::POUTPUT, @@ -2186,24 +2210,24 @@ lpvalue /* Continuous assignments have a list of individual assignments. */ cont_assign - : lpvalue '=' expression - { svector*tmp = new svector(2); - (*tmp)[0] = $1; - (*tmp)[1] = $3; - $$ = tmp; - } - ; + : lpvalue '=' expression + { list*tmp = new list; + tmp->push_back($1); + tmp->push_back($3); + $$ = tmp; + } + ; cont_assign_list - : cont_assign_list ',' cont_assign - { svector*tmp = new svector(*$1, *$3); - delete $1; - delete $3; - $$ = tmp; - } - | cont_assign - { $$ = $1; } - ; + : cont_assign_list ',' cont_assign + { list*tmp = $1; + tmp->splice(tmp->end(), *$3); + delete $3; + $$ = tmp; + } + | cont_assign + { $$ = $1; } + ; /* We allow zero, one or two unique declarations. */ local_timeunit_prec_decl_opt @@ -2876,14 +2900,7 @@ parameter_assign_decl param_active_type = IVL_VT_LOGIC; } | K_integer - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - /* The default range is [31:0] */ - param_active_range = range_stub; + { param_active_range = make_range_from_width(integer_width); param_active_signed = true; param_active_type = IVL_VT_LOGIC; } @@ -2893,14 +2910,7 @@ parameter_assign_decl param_active_type = IVL_VT_LOGIC; } | K_time - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum((uint64_t)63, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - /* The range is [63:0] */ - param_active_range = range_stub; + { param_active_range = make_range_from_width(64); param_active_signed = false; param_active_type = IVL_VT_LOGIC; } @@ -3005,14 +3015,7 @@ localparam_assign_decl param_active_type = IVL_VT_LOGIC; } | K_integer - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - /* The default range is [31:0] */ - param_active_range = range_stub; + { param_active_range = make_range_from_width(integer_width); param_active_signed = true; param_active_type = IVL_VT_LOGIC; } @@ -3022,14 +3025,7 @@ localparam_assign_decl param_active_type = IVL_VT_LOGIC; } | K_time - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum((uint64_t)63, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - /* The range is [63:0] */ - param_active_range = range_stub; + { param_active_range = make_range_from_width(64); param_active_signed = false; param_active_type = IVL_VT_LOGIC; } @@ -3090,8 +3086,8 @@ parameter_value_opt FILE_NAME(tmp, @1); struct parmvalue_t*lst = new struct parmvalue_t; - lst->by_order = new svector(1); - (*lst->by_order)[0] = tmp; + lst->by_order = new list; + lst->by_order->push_back(tmp); lst->by_name = 0; $$ = lst; based_size = 0; @@ -3340,13 +3336,13 @@ port_type ; range - : '[' expression ':' expression ']' - { svector*tmp = new svector (2); - (*tmp)[0] = $2; - (*tmp)[1] = $4; - $$ = tmp; - } - ; + : '[' expression ':' expression ']' + { list*tmp = new list; + tmp->push_back($2); + tmp->push_back($4); + $$ = tmp; + } + ; range_opt : range @@ -3376,16 +3372,16 @@ dimensions /* This is used to express the return type of a function. */ function_range_or_type_opt - : range { $$.range = $1; $$.type = PTF_REG; } - | K_signed range { $$.range = $2; $$.type = PTF_REG_S; } - | K_unsigned range { $$.range = $2; $$.type = PTF_REG; } + : range { $$.range = make_range_vector($1); $$.type = PTF_REG; } + | K_signed range { $$.range = make_range_vector($2); $$.type = PTF_REG_S; } + | K_unsigned range { $$.range = make_range_vector($2); $$.type = PTF_REG; } | K_integer { $$.range = 0; $$.type = PTF_INTEGER; } | K_real { $$.range = 0; $$.type = PTF_REAL; } | K_realtime { $$.range = 0; $$.type = PTF_REALTIME; } | K_time { $$.range = 0; $$.type = PTF_TIME; } - | atom2_type { $$.range = make_range_from_width($1); $$.type = PTF_ATOM2_S; } - | atom2_type K_signed { $$.range = make_range_from_width($1); $$.type = PTF_ATOM2_S; } - | atom2_type K_unsigned { $$.range = make_range_from_width($1); $$.type = PTF_ATOM2; } + | atom2_type { $$.range = make_range_vector($1); $$.type = PTF_ATOM2_S; } + | atom2_type K_signed { $$.range = make_range_vector($1); $$.type = PTF_ATOM2_S; } + | atom2_type K_unsigned { $$.range = make_range_vector($1); $$.type = PTF_ATOM2; } | { $$.range = 0; $$.type = PTF_REG; } ; @@ -3619,8 +3615,8 @@ specify_edge_path_decl : specify_edge_path '=' '(' delay_value_list ')' { $$ = pform_assign_path_delay($1, $4); } | specify_edge_path '=' delay_value_simple - { svector*tmp = new svector(1); - (*tmp)[0] = $3; + { list*tmp = new list; + tmp->push_back($3); $$ = pform_assign_path_delay($1, tmp); } ; @@ -3656,8 +3652,8 @@ specify_simple_path_decl : specify_simple_path '=' '(' delay_value_list ')' { $$ = pform_assign_path_delay($1, $4); } | specify_simple_path '=' delay_value_simple - { svector*tmp = new svector(1); - (*tmp)[0] = $3; + { list*tmp = new list; + tmp->push_back($3); $$ = pform_assign_path_delay($1, tmp); } | specify_simple_path '=' '(' error ')' @@ -4044,8 +4040,9 @@ statement yyerror(@1, "error: Error in while loop condition."); } | delay1 statement_or_null - { PExpr*del = (*$1)[0]; - assert($1->count() == 1); + { PExpr*del = $1->front(); + assert($1->size() == 1); + delete $1; PDelayStatement*tmp = new PDelayStatement(del, $2); FILE_NAME(tmp, @1); $$ = tmp; @@ -4096,15 +4093,15 @@ statement $$ = new PNoop; } | lpvalue '=' delay1 expression ';' - { assert($3->count() == 1); - PExpr*del = (*$3)[0]; + { PExpr*del = $3->front(); $3->pop_front(); + assert($3->empty()); PAssign*tmp = new PAssign($1,del,$4); FILE_NAME(tmp, @1); $$ = tmp; } | lpvalue K_LE delay1 expression ';' - { assert($3->count() == 1); - PExpr*del = (*$3)[0]; + { PExpr*del = $3->front(); $3->pop_front(); + assert($3->empty()); PAssignNB*tmp = new PAssignNB($1,del,$4); FILE_NAME(tmp, @1); $$ = tmp; @@ -4146,7 +4143,7 @@ statement $$ = tmp; } | SYSTEM_IDENTIFIER ';' - { svectorpt (0); + { listpt; PCallTask*tmp = new PCallTask(lex_strings.make($1), pt); FILE_NAME(tmp,@1); delete[]$1; @@ -4165,14 +4162,14 @@ statement want it. So accept it explicitly. */ | hierarchy_identifier '(' ')' ';' - { svectorpt (0); + { listpt; PCallTask*tmp = new PCallTask(*$1, pt); FILE_NAME(tmp, @1); delete $1; $$ = tmp; } | hierarchy_identifier ';' - { svectorpt (0); + { listpt; PCallTask*tmp = new PCallTask(*$1, pt); FILE_NAME(tmp, @1); delete $1; @@ -4249,96 +4246,57 @@ task_port_item /* When the port is an integer, infer a signed vector of the integer shape. Generate a range ([31:0]) to make it work. */ - | K_input K_integer list_of_identifiers ';' - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, - integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - svector*tmp - = pform_make_task_ports(NetNet::PINPUT, + | K_input K_integer list_of_identifiers ';' + { list*range_stub = make_range_from_width(integer_width); + svector*tmp = pform_make_task_ports(NetNet::PINPUT, IVL_VT_LOGIC, true, range_stub, $3, @1.text, @1.first_line); - $$ = tmp; - } - | K_output K_integer list_of_identifiers ';' - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, - integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - svector*tmp - = pform_make_task_ports(NetNet::POUTPUT, + $$ = tmp; + } + | K_output K_integer list_of_identifiers ';' + { list*range_stub = make_range_from_width(integer_width); + svector*tmp = pform_make_task_ports(NetNet::POUTPUT, IVL_VT_LOGIC, true, range_stub, $3, @1.text, @1.first_line); - $$ = tmp; - } - | K_inout K_integer list_of_identifiers ';' - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, - integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - svector*tmp - = pform_make_task_ports(NetNet::PINOUT, + $$ = tmp; + } + | K_inout K_integer list_of_identifiers ';' + { list*range_stub = make_range_from_width(integer_width); + svector*tmp = pform_make_task_ports(NetNet::PINOUT, IVL_VT_LOGIC, true, range_stub, $3, @1.text, @1.first_line); - $$ = tmp; - } + $$ = tmp; + } /* Ports can be time with a width of [63:0] (unsigned). */ - | K_input K_time list_of_identifiers ';' - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum((uint64_t)63, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - svector*tmp - = pform_make_task_ports(NetNet::PINPUT, + | K_input K_time list_of_identifiers ';' + { list*range_stub = make_range_from_width(64); + svector*tmp = pform_make_task_ports(NetNet::PINPUT, IVL_VT_LOGIC, false, range_stub, $3, @1.text, @1.first_line); - $$ = tmp; - } - | K_output K_time list_of_identifiers ';' - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum((uint64_t)63, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - svector*tmp - = pform_make_task_ports(NetNet::POUTPUT, + $$ = tmp; + } + | K_output K_time list_of_identifiers ';' + { list*range_stub = make_range_from_width(64); + svector*tmp = pform_make_task_ports(NetNet::POUTPUT, IVL_VT_LOGIC, false, range_stub, $3, @1.text, @1.first_line); - $$ = tmp; - } - | K_inout K_time list_of_identifiers ';' - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum((uint64_t)63, integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - svector*tmp - = pform_make_task_ports(NetNet::PINOUT, + $$ = tmp; + } + | K_inout K_time list_of_identifiers ';' + { list*range_stub = make_range_from_width(64); + svector*tmp = pform_make_task_ports(NetNet::PINOUT, IVL_VT_LOGIC, false, range_stub, $3, @1.text, @1.first_line); - $$ = tmp; - } + $$ = tmp; + } /* Ports can be real or realtime. */ @@ -4431,74 +4389,53 @@ task_port_decl /* Ports can be integer with a width of [31:0]. */ - | K_input K_integer IDENTIFIER - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, - integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - port_declaration_context.port_type = NetNet::PINPUT; - port_declaration_context.var_type = IVL_VT_LOGIC; - port_declaration_context.sign_flag = true; - delete port_declaration_context.range; - port_declaration_context.range = copy_range(range_stub); - svector*tmp - = pform_make_task_ports(NetNet::PINPUT, + | K_input K_integer IDENTIFIER + { list*range_stub = make_range_from_width(integer_width); + port_declaration_context.port_type = NetNet::PINPUT; + port_declaration_context.var_type = IVL_VT_LOGIC; + port_declaration_context.sign_flag = true; + delete port_declaration_context.range; + port_declaration_context.range = copy_range(range_stub); + svector*tmp = pform_make_task_ports(NetNet::PINPUT, IVL_VT_LOGIC, true, range_stub, list_from_identifier($3), @1.text, @1.first_line); - $$ = tmp; - } - | K_output K_integer IDENTIFIER - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, - integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - port_declaration_context.port_type = NetNet::POUTPUT; - port_declaration_context.var_type = IVL_VT_LOGIC; - port_declaration_context.sign_flag = true; - delete port_declaration_context.range; - port_declaration_context.range = copy_range(range_stub); - svector*tmp - = pform_make_task_ports(NetNet::POUTPUT, + $$ = tmp; + } + | K_output K_integer IDENTIFIER + { list*range_stub = make_range_from_width(integer_width); + port_declaration_context.port_type = NetNet::POUTPUT; + port_declaration_context.var_type = IVL_VT_LOGIC; + port_declaration_context.sign_flag = true; + delete port_declaration_context.range; + port_declaration_context.range = copy_range(range_stub); + svector*tmp = pform_make_task_ports(NetNet::POUTPUT, IVL_VT_LOGIC, true, range_stub, list_from_identifier($3), @1.text, @1.first_line); - $$ = tmp; - } - | K_inout K_integer IDENTIFIER - { svector*range_stub = new svector(2); - PExpr*re; - re = new PENumber(new verinum(integer_width-1, - integer_width)); - (*range_stub)[0] = re; - re = new PENumber(new verinum((uint64_t)0, integer_width)); - (*range_stub)[1] = re; - port_declaration_context.port_type = NetNet::PINOUT; - port_declaration_context.var_type = IVL_VT_LOGIC; - port_declaration_context.sign_flag = true; - delete port_declaration_context.range; - port_declaration_context.range = copy_range(range_stub); - svector*tmp - = pform_make_task_ports(NetNet::PINOUT, + $$ = tmp; + } + | K_inout K_integer IDENTIFIER + { list*range_stub = make_range_from_width(integer_width); + port_declaration_context.port_type = NetNet::PINOUT; + port_declaration_context.var_type = IVL_VT_LOGIC; + port_declaration_context.sign_flag = true; + delete port_declaration_context.range; + port_declaration_context.range = copy_range(range_stub); + svector*tmp = pform_make_task_ports(NetNet::PINOUT, IVL_VT_LOGIC, true, range_stub, list_from_identifier($3), @1.text, @1.first_line); - $$ = tmp; - } + $$ = tmp; + } /* Ports can be time with a width of [63:0] (unsigned). */ | K_input K_time IDENTIFIER - { svector*range_stub = make_range_from_width(64); + { list*range_stub = make_range_from_width(64); port_declaration_context.port_type = NetNet::PINPUT; port_declaration_context.var_type = IVL_VT_LOGIC; port_declaration_context.sign_flag = false; @@ -4512,7 +4449,7 @@ task_port_decl $$ = tmp; } | K_output K_time IDENTIFIER - { svector*range_stub = make_range_from_width(64); + { list*range_stub = make_range_from_width(64); port_declaration_context.port_type = NetNet::POUTPUT; port_declaration_context.var_type = IVL_VT_LOGIC; port_declaration_context.sign_flag = false; @@ -4526,7 +4463,7 @@ task_port_decl $$ = tmp; } | K_inout K_time IDENTIFIER - { svector*range_stub = make_range_from_width(64); + { list*range_stub = make_range_from_width(64); port_declaration_context.port_type = NetNet::PINOUT; port_declaration_context.var_type = IVL_VT_LOGIC; port_declaration_context.sign_flag = false; @@ -4585,7 +4522,7 @@ task_port_decl /* Ports can be 2-value atom types. */ | K_input atom2_type signed_unsigned_opt IDENTIFIER - { svector*range_stub = make_range_from_width($2); + { list*range_stub = make_range_from_width($2); port_declaration_context.port_type = NetNet::PINPUT; port_declaration_context.var_type = IVL_VT_BOOL; port_declaration_context.sign_flag = $3; @@ -4599,21 +4536,21 @@ task_port_decl } | K_output atom2_type signed_unsigned_opt IDENTIFIER - { svector*range_stub = make_range_from_width($2); + { list*range_stub = make_range_from_width($2); port_declaration_context.port_type = NetNet::POUTPUT; port_declaration_context.var_type = IVL_VT_BOOL; port_declaration_context.sign_flag = $3; delete port_declaration_context.range; port_declaration_context.range = copy_range(range_stub); svector*tmp = pform_make_task_ports(NetNet::POUTPUT, - IVL_VT_BOOL, $3, - range_stub, list_from_identifier($4), - @1.text, @1.first_line); + IVL_VT_BOOL, $3, + range_stub, list_from_identifier($4), + @1.text, @1.first_line); $$ = tmp; } | K_inout atom2_type signed_unsigned_opt IDENTIFIER - { svector*range_stub = make_range_from_width($2); + { list*range_stub = make_range_from_width($2); port_declaration_context.port_type = NetNet::PINOUT; port_declaration_context.var_type = IVL_VT_BOOL; port_declaration_context.sign_flag = $3; diff --git a/pform.cc b/pform.cc index 010e8d260..953cd3a07 100644 --- a/pform.cc +++ b/pform.cc @@ -939,7 +939,7 @@ void pform_start_generate_nblock(const struct vlltype&li, char*name) * case schema can only instantiate exactly one item, so the items * need not have a unique number. */ -void pform_generate_case_item(const struct vlltype&li, svector*expr_list) +void pform_generate_case_item(const struct vlltype&li, list*expr_list) { assert(pform_cur_generate); assert(pform_cur_generate->scheme_type == PGenerate::GS_CASE); @@ -958,9 +958,13 @@ void pform_generate_case_item(const struct vlltype&li, svector*expr_list pform_cur_generate->loop_step = 0; if (expr_list != 0) { - pform_cur_generate->item_test.resize(expr_list->count()); - for (unsigned idx = 0 ; idx < expr_list->count() ; idx += 1) - pform_cur_generate->item_test[idx] = expr_list[0][idx]; + list::iterator expr_cur = expr_list->begin(); + pform_cur_generate->item_test.resize(expr_list->size()); + for (unsigned idx = 0 ; idx < expr_list->size() ; idx += 1) { + pform_cur_generate->item_test[idx] = *expr_cur; + ++ expr_cur; + } + assert(expr_cur == expr_list->end()); } } @@ -1398,7 +1402,7 @@ void pform_make_udp(perm_string name, bool synchronous_flag, * and the name that I receive only has the tail component. */ static void pform_set_net_range(perm_string name, - const svector*range, + const list*range, bool signed_flag, ivl_variable_type_t dt, PWSRType rt) @@ -1415,10 +1419,8 @@ static void pform_set_net_range(perm_string name, cur->set_range(0, 0, rt, true); } else { - assert(range->count() == 2); - assert((*range)[0]); - assert((*range)[1]); - cur->set_range((*range)[0], (*range)[1], rt, false); + assert(range->size() == 2); + cur->set_range(range->front(), range->back(), rt, false); } cur->set_signed(signed_flag); @@ -1427,12 +1429,12 @@ static void pform_set_net_range(perm_string name, } void pform_set_net_range(list*names, - svector*range, + list*range, bool signed_flag, ivl_variable_type_t dt, PWSRType rt) { - assert((range == 0) || (range->count() == 2)); + assert((range == 0) || (range->size() == 2)); for (list::iterator cur = names->begin() ; cur != names->end() @@ -1484,7 +1486,7 @@ void pform_make_events(list*names, const char*fn, unsigned ln) */ void pform_makegate(PGBuiltin::Type type, struct str_pair_t str, - svector* delay, + list* delay, const lgate&info, svector*attr) { @@ -1495,8 +1497,9 @@ void pform_makegate(PGBuiltin::Type type, return; } - for (unsigned idx = 0 ; idx < info.parms->count() ; idx += 1) { - pform_declare_implicit_nets((*info.parms)[idx]); + for (list::iterator cur = info.parms->begin() + ; cur != info.parms->end() ; ++cur) { + pform_declare_implicit_nets(*cur); } perm_string dev_name = lex_strings.make(info.name); @@ -1523,7 +1526,7 @@ void pform_makegate(PGBuiltin::Type type, void pform_makegates(PGBuiltin::Type type, struct str_pair_t str, - svector*delay, + list*delay, svector*gates, svector*attr) { @@ -1559,12 +1562,13 @@ void pform_makegates(PGBuiltin::Type type, static void pform_make_modgate(perm_string type, perm_string name, struct parmvalue_t*overrides, - svector*wires, + list*wires, PExpr*msb, PExpr*lsb, const char*fn, unsigned ln) { - for (unsigned idx = 0 ; idx < wires->count() ; idx += 1) { - pform_declare_implicit_nets((*wires)[idx]); + for (list::iterator idx = wires->begin() + ; idx != wires->end() ; ++idx) { + pform_declare_implicit_nets(*idx); } PGModule*cur = new PGModule(type, name, wires); @@ -1657,9 +1661,9 @@ void pform_make_modgates(perm_string type, /* If there are no parameters, the parser will be tricked into thinking it is one empty parameter. This fixes that. */ - if ((cur.parms->count() == 1) && (cur.parms[0][0] == 0)) { + if ((cur.parms->size() == 1) && (cur.parms->front() == 0)) { delete cur.parms; - cur.parms = new svector(0); + cur.parms = new list; } pform_make_modgate(type, cur_name, overrides, cur.parms, @@ -1667,7 +1671,7 @@ void pform_make_modgates(perm_string type, cur.file, cur.lineno); } else { - svector*wires = new svector(0); + list*wires = new list; pform_make_modgate(type, cur_name, overrides, wires, cur.range[0], cur.range[1], @@ -1679,7 +1683,7 @@ void pform_make_modgates(perm_string type, } static PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, - svector*del, + list*del, struct str_pair_t str) { /* Implicit declaration of nets on the LHS of a continuous @@ -1687,9 +1691,9 @@ static PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, if (generation_flag != GN_VER1995) pform_declare_implicit_nets(lval); - svector*wires = new svector(2); - (*wires)[0] = lval; - (*wires)[1] = rval; + list*wires = new list; + wires->push_back(lval); + wires->push_back(rval); PGAssign*cur; @@ -1709,19 +1713,19 @@ static PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval, return cur; } -void pform_make_pgassign_list(svector*alist, - svector*del, +void pform_make_pgassign_list(list*alist, + list*del, struct str_pair_t str, const char* fn, unsigned lineno) { - PGAssign*tmp; - for (unsigned idx = 0 ; idx < alist->count()/2 ; idx += 1) { - tmp = pform_make_pgassign((*alist)[2*idx], - (*alist)[2*idx+1], - del, str); - FILE_NAME(tmp, fn, lineno); - } + assert(alist->size() % 2 == 0); + while (! alist->empty()) { + PExpr*lval = alist->front(); alist->pop_front(); + PExpr*rval = alist->front(); alist->pop_front(); + PGAssign*tmp = pform_make_pgassign(lval, rval, del, str); + FILE_NAME(tmp, fn, lineno); + } } /* @@ -1783,7 +1787,7 @@ void pform_module_define_port(const struct vlltype&li, NetNet::Type type, ivl_variable_type_t data_type, bool signed_flag, - svector*range, + list*range, svector*attr) { PWire*cur = pform_get_wire_in_scope(name); @@ -1811,10 +1815,10 @@ void pform_module_define_port(const struct vlltype&li, true); } else { - assert(range->count() == 2); - assert((*range)[0]); - assert((*range)[1]); - cur->set_range((*range)[0], (*range)[1], + assert(range->size() == 2); + assert(range->front()); + assert(range->back()); + cur->set_range(range->front(), range->back(), (type == NetNet::IMPLICIT) ? SR_PORT : SR_BOTH, false); } @@ -1920,7 +1924,7 @@ void pform_makewire(const vlltype&li, perm_string name, * pform_makewire above. */ void pform_makewire(const vlltype&li, - svector*range, + list*range, bool signed_flag, list*names, NetNet::Type type, @@ -1948,9 +1952,9 @@ void pform_makewire(const vlltype&li, * This form makes nets with delays and continuous assignments. */ void pform_makewire(const vlltype&li, - svector*range, + list*range, bool signed_flag, - svector*delay, + list*delay, str_pair_t str, net_decl_assign_t*decls, NetNet::Type type, @@ -2058,7 +2062,7 @@ void pform_set_port_type(perm_string name, NetNet::PortType pt, svector*pform_make_task_ports(NetNet::PortType pt, ivl_variable_type_t vtype, bool signed_flag, - svector*range, + list*range, list*names, const char* file, unsigned lineno) @@ -2084,8 +2088,10 @@ svector*pform_make_task_ports(NetNet::PortType pt, curw->set_signed(signed_flag); /* If there is a range involved, it needs to be set. */ - if (range) - curw->set_range((*range)[0], (*range)[1], SR_PORT, false); + if (range) { + assert(range->size() == 2); + curw->set_range(range->front(), range->back(), SR_PORT, false); + } svector*tmp = new svector(*res, curw); @@ -2166,7 +2172,7 @@ LexicalScope::range_t* pform_parameter_value_range(bool exclude_flag, void pform_set_parameter(const struct vlltype&loc, perm_string name, ivl_variable_type_t type, - bool signed_flag, svector*range, PExpr*expr, + bool signed_flag, list*range, PExpr*expr, LexicalScope::range_t*value_range) { LexicalScope*scope = lexical_scope; @@ -2201,11 +2207,11 @@ void pform_set_parameter(const struct vlltype&loc, parm.type = type; if (range) { - assert(range->count() == 2); - assert((*range)[0]); - assert((*range)[1]); - parm.msb = (*range)[0]; - parm.lsb = (*range)[1]; + assert(range->size() == 2); + assert(range->front()); + assert(range->back()); + parm.msb = range->front(); + parm.lsb = range->back(); } else { parm.msb = 0; parm.lsb = 0; @@ -2219,7 +2225,7 @@ void pform_set_parameter(const struct vlltype&loc, void pform_set_localparam(const struct vlltype&loc, perm_string name, ivl_variable_type_t type, - bool signed_flag, svector*range, PExpr*expr) + bool signed_flag, list*range, PExpr*expr) { LexicalScope*scope = lexical_scope; @@ -2249,11 +2255,11 @@ void pform_set_localparam(const struct vlltype&loc, parm.type = type; if (range) { - assert(range->count() == 2); - assert((*range)[0]); - assert((*range)[1]); - parm.msb = (*range)[0]; - parm.lsb = (*range)[1]; + assert(range->size() == 2); + assert(range->front()); + assert(range->back()); + parm.msb = range->front(); + parm.lsb = range->back(); } else { parm.msb = 0; parm.lsb = 0; @@ -2324,16 +2330,18 @@ extern PSpecPath*pform_make_specify_edge_path(const struct vlltype&li, return tmp; } -extern PSpecPath* pform_assign_path_delay(PSpecPath*path, svector*del) +extern PSpecPath* pform_assign_path_delay(PSpecPath*path, list*del) { if (path == 0) return 0; assert(path->delays.size() == 0); - path->delays.resize(del->count()); - for (unsigned idx = 0 ; idx < path->delays.size() ; idx += 1) - path->delays[idx] = (*del)[idx]; + path->delays.resize(del->size()); + for (unsigned idx = 0 ; idx < path->delays.size() ; idx += 1) { + path->delays[idx] = del->front(); + del->pop_front(); + } delete del; @@ -2350,7 +2358,7 @@ extern void pform_module_specify_path(PSpecPath*obj) void pform_set_port_type(const struct vlltype&li, list*names, - svector*range, + list*range, bool signed_flag, NetNet::PortType pt) { diff --git a/pform.h b/pform.h index 9cce000a5..e263946be 100644 --- a/pform.h +++ b/pform.h @@ -89,7 +89,7 @@ typedef named named_pexpr_t; typedef named named_number_t; struct parmvalue_t { - svector*by_order; + list*by_order; svector*by_name; }; @@ -105,7 +105,7 @@ struct net_decl_assign_t { struct enum_type_t { ivl_variable_type_t base_type; bool signed_flag; - auto_ptr< svector > range; + auto_ptr< list > range; auto_ptr< list > names; }; @@ -118,7 +118,7 @@ struct lgate { } string name; - svector*parms; + list*parms; svector*parms_by_name; PExpr*range[2]; @@ -165,7 +165,7 @@ extern void pform_module_define_port(const struct vlltype&li, NetNet::Type type, ivl_variable_type_t data_type, bool signed_flag, - svector*range, + list*range, svector*attr); extern Module::port_t* pform_module_port_reference(perm_string name, @@ -220,7 +220,7 @@ extern void pform_start_generate_if(const struct vlltype&li, PExpr*test); extern void pform_start_generate_else(const struct vlltype&li); extern void pform_start_generate_case(const struct vlltype&lp, PExpr*test); extern void pform_start_generate_nblock(const struct vlltype&lp, char*name); -extern void pform_generate_case_item(const struct vlltype&lp, svector*test); +extern void pform_generate_case_item(const struct vlltype&lp, list*test); extern void pform_generate_block_name(char*name); extern void pform_endgenerate(); @@ -243,7 +243,7 @@ extern void pform_makewire(const struct vlltype&li, perm_string name, /* This form handles simple declarations */ extern void pform_makewire(const struct vlltype&li, - svector*range, + list*range, bool signed_flag, list*names, NetNet::Type type, @@ -254,9 +254,9 @@ extern void pform_makewire(const struct vlltype&li, /* This form handles assignment declarations. */ extern void pform_makewire(const struct vlltype&li, - svector*range, + list*range, bool signed_flag, - svector*delay, + list*delay, str_pair_t str, net_decl_assign_t*assign_list, NetNet::Type type, @@ -270,14 +270,14 @@ extern void pform_make_reginit(const struct vlltype&li, it. The second form takes a single name. */ extern void pform_set_port_type(const struct vlltype&li, list*names, - svector*range, + list*range, bool signed_flag, NetNet::PortType); extern void pform_set_port_type(perm_string nm, NetNet::PortType pt, const char*file, unsigned lineno); extern void pform_set_net_range(list*names, - svector*, + list*, bool signed_flag, ivl_variable_type_t, PWSRType rt = SR_NET); @@ -306,13 +306,13 @@ extern void pform_set_parameter(const struct vlltype&loc, perm_string name, ivl_variable_type_t type, bool signed_flag, - svector*range, + list*range, PExpr*expr, LexicalScope::range_t*value_range); extern void pform_set_localparam(const struct vlltype&loc, perm_string name, ivl_variable_type_t type, bool signed_flag, - svector*range, + list*range, PExpr*expr); extern void pform_set_defparam(const pform_name_t&name, PExpr*expr); @@ -329,7 +329,7 @@ extern PSpecPath*pform_make_specify_edge_path(const struct vlltype&li, list*src, char pol, bool full_flag, list*dst, PExpr*data_source_expression); -extern PSpecPath*pform_assign_path_delay(PSpecPath*obj, svector*delays); +extern PSpecPath*pform_assign_path_delay(PSpecPath*obj, list*delays); extern void pform_module_specify_path(PSpecPath*obj); @@ -356,7 +356,7 @@ extern void pform_make_reals(list*names, */ extern void pform_makegates(PGBuiltin::Type type, struct str_pair_t str, - svector*delay, + list*delay, svector*gates, svector*attr); @@ -365,8 +365,8 @@ extern void pform_make_modgates(perm_string type, svector*gates); /* Make a continuous assignment node, with optional bit- or part- select. */ -extern void pform_make_pgassign_list(svector*alist, - svector*del, +extern void pform_make_pgassign_list(list*alist, + list*del, struct str_pair_t str, const char* fn, unsigned lineno); @@ -375,7 +375,7 @@ extern void pform_make_pgassign_list(svector*alist, extern svector*pform_make_task_ports(NetNet::PortType pt, ivl_variable_type_t vtype, bool signed_flag, - svector*range, + list*range, list*names, const char* file, unsigned lineno); diff --git a/pform_dump.cc b/pform_dump.cc index cbef88cc1..db3aa7e25 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -169,14 +169,14 @@ void PEConcat::dump(ostream&out) const if (repeat_) out << "{" << *repeat_; - if (parms_.count() == 0) { + if (parms_.size() == 0) { out << "{}"; return; } out << "{"; if (parms_[0]) out << *parms_[0]; - for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) { out << ", "; if (parms_[idx]) out << *parms_[idx]; } @@ -478,16 +478,18 @@ void PGModule::dump(ostream&out, unsigned ind) const out << setw(ind) << "" << type_ << " "; // If parameters are overridden by order, dump them. - if (overrides_ && overrides_->count() > 0) { + if (overrides_ && overrides_->size() > 0) { assert(parms_ == 0); out << "#("; - if ((*overrides_)[0] == 0) + list::const_iterator idx = overrides_->begin(); + + if (*idx == 0) out << ""; else - out << *((*overrides_)[0]); - for (unsigned idx = 1 ; idx < overrides_->count() ; idx += 1) { - out << "," << *((*overrides_)[idx]); + out << *idx; + for ( ; idx != overrides_->end() ; ++ idx) { + out << "," << *idx; } out << ") "; } @@ -600,12 +602,12 @@ void PCallTask::dump(ostream&out, unsigned ind) const { out << setw(ind) << "" << path_; - if (parms_.count() > 0) { + if (parms_.size() > 0) { out << "("; if (parms_[0]) out << *parms_[0]; - for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { + for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) { out << ", "; if (parms_[idx]) out << *parms_[idx]; @@ -636,14 +638,15 @@ void PCase::dump(ostream&out, unsigned ind) const for (unsigned idx = 0 ; idx < items_->count() ; idx += 1) { PCase::Item*cur = (*items_)[idx]; - if (cur->expr.count() == 0) { + if (cur->expr.size() == 0) { out << setw(ind+2) << "" << "default:"; } else { - out << setw(ind+2) << "" << *cur->expr[0]; + list::iterator idx_exp = cur->expr.begin(); + out << setw(ind+2) << "" << *idx_exp; - for(unsigned e = 1 ; e < cur->expr.count() ; e += 1) - out << ", " << *cur->expr[e]; + for( ; idx_exp != cur->expr.end() ; ++idx_exp) + out << ", " << *idx_exp; out << ":"; } diff --git a/util.h b/util.h index 29f208dce..64de121a2 100644 --- a/util.h +++ b/util.h @@ -20,6 +20,8 @@ */ # include +# include +# include # include "StringHeap.h" # include "verinum.h"