Replace svector with std::vector
The custom `svector` class is essentially a subset of `std::vector`. There is no inherent advantage to using `svector`. Both have the same memory footprint. `svector` was designed to be of static size, but there are a few places in the parser where it has to grow at runtime. Handling this becomes a bit easier by switching to `std::vector` since it is possible to use its methods which take care of resizing the vector. This also allows to remove the unused parameter of the `lgate` struct constructor, which was only needed for compatibility with `svector`. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
e67a796a77
commit
e15b125da8
|
|
@ -19,7 +19,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
# include "svector.h"
|
||||
# include <string>
|
||||
# include <list>
|
||||
# include <iostream>
|
||||
|
|
|
|||
1
PGate.h
1
PGate.h
|
|
@ -19,7 +19,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
# include "svector.h"
|
||||
# include "StringHeap.h"
|
||||
# include "named.h"
|
||||
# include "PNamedItem.h"
|
||||
|
|
|
|||
4
PUdp.cc
4
PUdp.cc
|
|
@ -26,12 +26,12 @@ PUdp::PUdp(perm_string n, unsigned nports)
|
|||
|
||||
unsigned PUdp::find_port(const char*name)
|
||||
{
|
||||
for (unsigned idx = 0 ; idx < ports.count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < ports.size() ; idx += 1) {
|
||||
|
||||
if (ports[idx] == name)
|
||||
return idx;
|
||||
}
|
||||
|
||||
return ports.count();
|
||||
return ports.size();
|
||||
}
|
||||
|
||||
|
|
|
|||
10
PUdp.h
10
PUdp.h
|
|
@ -20,9 +20,9 @@
|
|||
*/
|
||||
|
||||
# include <map>
|
||||
# include <vector>
|
||||
# include "LineInfo.h"
|
||||
# include "StringHeap.h"
|
||||
# include "svector.h"
|
||||
# include "verinum.h"
|
||||
|
||||
class PExpr;
|
||||
|
|
@ -53,14 +53,14 @@ class PUdp : public LineInfo {
|
|||
public:
|
||||
explicit PUdp(perm_string n, unsigned nports);
|
||||
|
||||
svector<std::string>ports;
|
||||
std::vector<std::string> ports;
|
||||
unsigned find_port(const char*name);
|
||||
|
||||
bool sequential;
|
||||
|
||||
svector<std::string>tinput;
|
||||
svector<char> tcurrent;
|
||||
svector<char> toutput;
|
||||
std::vector<std::string> tinput;
|
||||
std::vector<char> tcurrent;
|
||||
std::vector<char> toutput;
|
||||
|
||||
verinum::V initial;
|
||||
|
||||
|
|
|
|||
10
Statement.cc
10
Statement.cc
|
|
@ -208,7 +208,7 @@ const pform_name_t& PCallTask::path() const
|
|||
return path_;
|
||||
}
|
||||
|
||||
PCase::PCase(ivl_case_quality_t q, NetCase::TYPE t, PExpr*ex, svector<PCase::Item*>*l)
|
||||
PCase::PCase(ivl_case_quality_t q, NetCase::TYPE t, PExpr*ex, std::vector<PCase::Item*>*l)
|
||||
: quality_(q), type_(t), expr_(ex), items_(l)
|
||||
{
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ PCase::PCase(ivl_case_quality_t q, NetCase::TYPE t, PExpr*ex, svector<PCase::Ite
|
|||
PCase::~PCase()
|
||||
{
|
||||
delete expr_;
|
||||
for (unsigned idx = 0 ; idx < items_->count() ; idx += 1)
|
||||
for (unsigned idx = 0 ; idx < items_->size() ; idx += 1)
|
||||
if ((*items_)[idx]->stat) delete (*items_)[idx]->stat;
|
||||
|
||||
delete[]items_;
|
||||
|
|
@ -300,10 +300,10 @@ PDoWhile::~PDoWhile()
|
|||
delete statement_;
|
||||
}
|
||||
|
||||
PEventStatement::PEventStatement(const svector<PEEvent*>&ee)
|
||||
PEventStatement::PEventStatement(const std::vector<PEEvent*>&ee)
|
||||
: expr_(ee), statement_(0), always_sens_(false)
|
||||
{
|
||||
assert(expr_.count() > 0);
|
||||
assert(expr_.size() > 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ void PEventStatement::set_statement(Statement*st)
|
|||
bool PEventStatement::has_aa_term(Design*des, NetScope*scope)
|
||||
{
|
||||
bool flag = false;
|
||||
for (unsigned idx = 0 ; idx < expr_.count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < expr_.size() ; idx += 1) {
|
||||
flag = expr_[idx]->has_aa_term(des, scope) || flag;
|
||||
}
|
||||
return flag;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
# include <vector>
|
||||
# include <list>
|
||||
# include "ivl_target.h"
|
||||
# include "svector.h"
|
||||
# include "StringHeap.h"
|
||||
# include "PDelays.h"
|
||||
# include "PExpr.h"
|
||||
|
|
@ -267,7 +266,7 @@ class PCase : public Statement {
|
|||
Statement*stat;
|
||||
};
|
||||
|
||||
PCase(ivl_case_quality_t, NetCase::TYPE, PExpr*ex, svector<Item*>*);
|
||||
PCase(ivl_case_quality_t, NetCase::TYPE, PExpr*ex, std::vector<Item*>*);
|
||||
~PCase();
|
||||
|
||||
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
|
||||
|
|
@ -280,7 +279,7 @@ class PCase : public Statement {
|
|||
NetCase::TYPE type_;
|
||||
PExpr*expr_;
|
||||
|
||||
svector<Item*>*items_;
|
||||
std::vector<Item*>*items_;
|
||||
|
||||
private: // not implemented
|
||||
PCase(const PCase&);
|
||||
|
|
@ -416,7 +415,7 @@ class PEventStatement : public Statement {
|
|||
|
||||
public:
|
||||
|
||||
explicit PEventStatement(const svector<PEEvent*>&ee);
|
||||
explicit PEventStatement(const std::vector<PEEvent*>&ee);
|
||||
explicit PEventStatement(PEEvent*ee);
|
||||
// Make an @* statement or make a special @* version with the items
|
||||
// from functions added and outputs removed for always_comb/latch.
|
||||
|
|
@ -444,7 +443,7 @@ class PEventStatement : public Statement {
|
|||
NetProc* elaborate_wait_fork(Design*des, NetScope*scope) const;
|
||||
|
||||
private:
|
||||
svector<PEEvent*>expr_;
|
||||
std::vector<PEEvent*>expr_;
|
||||
Statement*statement_;
|
||||
bool always_sens_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ NetNet* PEConcat::elaborate_anet(Design*des, NetScope*scope) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
svector<NetNet*>nets (parms_.count());
|
||||
std::vector<NetNet*> nets(parms_.count());
|
||||
unsigned pins = 0;
|
||||
unsigned errors = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -3637,7 +3637,7 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope,
|
|||
unsigned wid_sum = 0;
|
||||
unsigned parm_cnt = 0;
|
||||
unsigned parm_errors = 0;
|
||||
svector<NetExpr*> parms(parms_.size());
|
||||
std::vector<NetExpr*> parms(parms_.size());
|
||||
|
||||
/* Elaborate all the parameters and attach them to the concat node. */
|
||||
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
|
||||
|
|
|
|||
10
elab_net.cc
10
elab_net.cc
|
|
@ -46,7 +46,7 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
|
|||
{
|
||||
assert(scope);
|
||||
|
||||
svector<NetNet*>nets (parms_.size());
|
||||
std::vector<NetNet*> nets(parms_.size());
|
||||
unsigned width = 0;
|
||||
unsigned errors = 0;
|
||||
|
||||
|
|
@ -57,11 +57,11 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
|
|||
}
|
||||
|
||||
/* Elaborate the operands of the concatenation. */
|
||||
for (unsigned idx = 0 ; idx < nets.count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < nets.size() ; idx += 1) {
|
||||
|
||||
if (debug_elaborate) {
|
||||
cerr << get_fileline() << ": debug: Elaborate subexpression "
|
||||
<< idx << " of " << nets.count() << " l-values: "
|
||||
<< idx << " of " << nets.size() << " l-values: "
|
||||
<< *parms_[idx] << endl;
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
|
|||
<< endl;
|
||||
}
|
||||
|
||||
for (unsigned idx = 0 ; idx < nets.count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < nets.size() ; idx += 1) {
|
||||
unsigned wid = nets[idx]->vector_width();
|
||||
unsigned off = width - wid;
|
||||
NetTran*ps = new NetTran(scope, scope->local_symbol(),
|
||||
|
|
@ -141,7 +141,7 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
|
|||
|
||||
NetPartSelect::dir_t part_dir = NetPartSelect::VP;
|
||||
|
||||
for (unsigned idx = 0 ; idx < nets.count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < nets.size() ; idx += 1) {
|
||||
unsigned wid = nets[idx]->vector_width();
|
||||
unsigned off = width - wid;
|
||||
NetPartSelect*ps = new NetPartSelect(osig, off, wid, part_dir);
|
||||
|
|
|
|||
|
|
@ -1704,7 +1704,7 @@ void PBlock::elaborate_scope(Design*des, NetScope*scope) const
|
|||
void PCase::elaborate_scope(Design*des, NetScope*scope) const
|
||||
{
|
||||
assert(items_);
|
||||
for (unsigned idx = 0 ; idx < (*items_).count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < (*items_).size() ; idx += 1) {
|
||||
assert( (*items_)[idx] );
|
||||
|
||||
if (Statement*sp = (*items_)[idx]->stat)
|
||||
|
|
|
|||
|
|
@ -852,7 +852,7 @@ void PCase::elaborate_sig(Design*des, NetScope*scope) const
|
|||
if (items_ == 0)
|
||||
return;
|
||||
|
||||
for (unsigned idx = 0 ; idx < items_->count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < items_->size() ; idx += 1) {
|
||||
if ( (*items_)[idx]->stat )
|
||||
(*items_)[idx]->stat ->elaborate_sig(des,scope);
|
||||
}
|
||||
|
|
|
|||
30
elaborate.cc
30
elaborate.cc
|
|
@ -2014,7 +2014,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
|
|||
}
|
||||
|
||||
assert(udp);
|
||||
NetUDP*net = new NetUDP(scope, my_name, udp->ports.count(), udp);
|
||||
NetUDP*net = new NetUDP(scope, my_name, udp->ports.size(), udp);
|
||||
net->set_line(*this);
|
||||
net->rise_time(rise_expr);
|
||||
net->fall_time(fall_expr);
|
||||
|
|
@ -2043,7 +2043,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
|
|||
// ports. If this is simply positional binding in the first
|
||||
// place, then get the binding from the base class.
|
||||
if (pins_) {
|
||||
unsigned nexp = udp->ports.count();
|
||||
unsigned nexp = udp->ports.size();
|
||||
pins = vector<PExpr*>(nexp);
|
||||
|
||||
// Scan the bindings, matching them with port names.
|
||||
|
|
@ -2086,9 +2086,9 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
|
|||
connections. In this case, the port count must be
|
||||
right. Check that is is, the get the pin list. */
|
||||
|
||||
if (pin_count() != udp->ports.count()) {
|
||||
if (pin_count() != udp->ports.size()) {
|
||||
cerr << get_fileline() << ": error: Wrong number "
|
||||
"of ports. Expecting " << udp->ports.count() <<
|
||||
"of ports. Expecting " << udp->ports.size() <<
|
||||
", got " << pin_count() << "."
|
||||
<< endl;
|
||||
des->errors += 1;
|
||||
|
|
@ -2097,7 +2097,7 @@ void PGModule::elaborate_udp_(Design*des, PUdp*udp, NetScope*scope) const
|
|||
|
||||
// No named bindings, just use the positional list I
|
||||
// already have.
|
||||
assert(pin_count() == udp->ports.count());
|
||||
assert(pin_count() == udp->ports.size());
|
||||
pins = get_pins();
|
||||
}
|
||||
|
||||
|
|
@ -3046,7 +3046,7 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const
|
|||
bool context_is_real = (expr_->expr_type() == IVL_VT_REAL);
|
||||
bool context_unsigned = !expr_->has_sign();
|
||||
|
||||
for (unsigned idx = 0; idx < items_->count(); idx += 1) {
|
||||
for (unsigned idx = 0; idx < items_->size(); idx += 1) {
|
||||
|
||||
PCase::Item*cur = (*items_)[idx];
|
||||
|
||||
|
|
@ -3082,7 +3082,7 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const
|
|||
|
||||
context_width = test_case_width(des, scope, expr_, context_mode);
|
||||
|
||||
for (unsigned idx = 0; idx < items_->count(); idx += 1) {
|
||||
for (unsigned idx = 0; idx < items_->size(); idx += 1) {
|
||||
|
||||
PCase::Item*cur = (*items_)[idx];
|
||||
|
||||
|
|
@ -3126,7 +3126,7 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const
|
|||
be some cases that have multiple guards. Count each as a
|
||||
separate item. */
|
||||
unsigned icount = 0;
|
||||
for (unsigned idx = 0 ; idx < items_->count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < items_->size() ; idx += 1) {
|
||||
PCase::Item*cur = (*items_)[idx];
|
||||
|
||||
if (cur->expr.empty())
|
||||
|
|
@ -3143,7 +3143,7 @@ NetProc* PCase::elaborate(Design*des, NetScope*scope) const
|
|||
is a "default" case. Otherwise, the guard has one or more
|
||||
expressions, and each guard is a case. */
|
||||
unsigned inum = 0;
|
||||
for (unsigned idx = 0 ; idx < items_->count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < items_->size() ; idx += 1) {
|
||||
|
||||
ivl_assert(*this, inum < icount);
|
||||
PCase::Item*cur = (*items_)[idx];
|
||||
|
|
@ -4648,7 +4648,7 @@ NetProc* PEventStatement::elaborate_st(Design*des, NetScope*scope,
|
|||
/* If there are no expressions, this is a signal that it is an
|
||||
@* statement. Generate an expression to use. */
|
||||
|
||||
if (expr_.count() == 0) {
|
||||
if (expr_.size() == 0) {
|
||||
assert(enet);
|
||||
/* For synthesis or always_comb/latch we want just the inputs,
|
||||
* but for the rest we want inputs and outputs that may cause
|
||||
|
|
@ -4732,7 +4732,7 @@ cerr << endl;
|
|||
|
||||
expr_count = 1;
|
||||
|
||||
} else for (unsigned idx = 0 ; idx < expr_.count() ; idx += 1) {
|
||||
} else for (unsigned idx = 0 ; idx < expr_.size() ; idx += 1) {
|
||||
|
||||
assert(expr_[idx]->expr());
|
||||
|
||||
|
|
@ -4889,7 +4889,7 @@ NetProc* PEventStatement::elaborate_wait(Design*des, NetScope*scope,
|
|||
NetProc*enet) const
|
||||
{
|
||||
assert(scope);
|
||||
assert(expr_.count() == 1);
|
||||
assert(expr_.size() == 1);
|
||||
|
||||
if (scope->in_func()) {
|
||||
cerr << get_fileline() << ": error: functions cannot have "
|
||||
|
|
@ -5051,7 +5051,7 @@ NetProc* PEventStatement::elaborate_wait(Design*des, NetScope*scope,
|
|||
NetProc* PEventStatement::elaborate_wait_fork(Design*des, NetScope*scope) const
|
||||
{
|
||||
assert(scope);
|
||||
assert(expr_.count() == 1);
|
||||
assert(expr_.size() == 1);
|
||||
assert(expr_[0] == 0);
|
||||
assert(! statement_);
|
||||
|
||||
|
|
@ -5086,7 +5086,7 @@ NetProc* PEventStatement::elaborate_wait_fork(Design*des, NetScope*scope) const
|
|||
NetProc* PEventStatement::elaborate(Design*des, NetScope*scope) const
|
||||
{
|
||||
/* Check to see if this is a wait fork statement. */
|
||||
if ((expr_.count() == 1) && (expr_[0] == 0))
|
||||
if ((expr_.size() == 1) && (expr_[0] == 0))
|
||||
return elaborate_wait_fork(des, scope);
|
||||
|
||||
NetProc*enet = 0;
|
||||
|
|
@ -5100,7 +5100,7 @@ NetProc* PEventStatement::elaborate(Design*des, NetScope*scope) const
|
|||
enet->set_line(*this);
|
||||
}
|
||||
|
||||
if ((expr_.count() == 1) && (expr_[0]->type() == PEEvent::POSITIVE))
|
||||
if ((expr_.size() == 1) && (expr_[0]->type() == PEEvent::POSITIVE))
|
||||
return elaborate_wait(des, scope, enet);
|
||||
|
||||
return elaborate_st(des, scope, enet);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ NetUDP::NetUDP(NetScope*s, perm_string n, unsigned pins, PUdp *u)
|
|||
for (unsigned idx = 1 ; idx < pins ; idx += 1) {
|
||||
pin(idx).set_dir(Link::INPUT);
|
||||
}
|
||||
table_idx = udp->tinput.count()-1;
|
||||
table_idx = udp->tinput.size() - 1;
|
||||
}
|
||||
|
||||
bool NetUDP::first(string&inp, char&out) const
|
||||
|
|
@ -44,7 +44,7 @@ bool NetUDP::next(string&inp, char&out) const
|
|||
{
|
||||
table_idx++;
|
||||
|
||||
if (table_idx >= udp->tinput.count()) return false;
|
||||
if (table_idx >= udp->tinput.size()) return false;
|
||||
|
||||
if (is_sequential()) {
|
||||
inp = string("") + udp->tcurrent[table_idx] +
|
||||
|
|
@ -84,11 +84,11 @@ char NetUDP::get_initial() const
|
|||
|
||||
unsigned NetUDP::port_count() const
|
||||
{
|
||||
return udp->ports.count();
|
||||
return udp->ports.size();
|
||||
}
|
||||
|
||||
string NetUDP::port_name(unsigned idx) const
|
||||
{
|
||||
assert(idx < udp->ports.count());
|
||||
assert(idx < udp->ports.size());
|
||||
return udp->ports[idx];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2626,7 +2626,7 @@ class NetUDP : public NetNode {
|
|||
return false when the scan is done. */
|
||||
bool first(std::string&inp, char&out) const;
|
||||
bool next(std::string&inp, char&out) const;
|
||||
unsigned rows() const { return udp->tinput.count(); }
|
||||
unsigned rows() const { return udp->tinput.size(); }
|
||||
|
||||
unsigned nin() const { return pin_count()-1; }
|
||||
bool is_sequential() const { return udp->sequential; }
|
||||
|
|
|
|||
63
parse.y
63
parse.y
|
|
@ -402,10 +402,10 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector<Statem
|
|||
struct str_pair_t drive;
|
||||
|
||||
PCase::Item*citem;
|
||||
svector<PCase::Item*>*citems;
|
||||
std::vector<PCase::Item*>*citems;
|
||||
|
||||
lgate*gate;
|
||||
svector<lgate>*gates;
|
||||
std::vector<lgate>*gates;
|
||||
|
||||
Module::port_t *mport;
|
||||
LexicalScope::range_t* value_range;
|
||||
|
|
@ -425,7 +425,8 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector<Statem
|
|||
PExpr*expr;
|
||||
std::list<PExpr*>*exprs;
|
||||
|
||||
svector<PEEvent*>*event_expr;
|
||||
PEEvent*event_expr;
|
||||
std::vector<PEEvent*>*event_exprs;
|
||||
|
||||
ivl_case_quality_t case_quality;
|
||||
NetNet::Type nettype;
|
||||
|
|
@ -687,7 +688,7 @@ static void current_function_set_statement(const YYLTYPE&loc, std::vector<Statem
|
|||
%type <vartype> integer_vector_type
|
||||
%type <parmvalue> parameter_value_opt
|
||||
|
||||
%type <event_expr> event_expression_list
|
||||
%type <event_exprs> event_expression_list
|
||||
%type <event_expr> event_expression
|
||||
%type <event_statement> event_control
|
||||
%type <statement> statement statement_item statement_or_null
|
||||
|
|
@ -2924,15 +2925,11 @@ case_item
|
|||
|
||||
case_items
|
||||
: case_items case_item
|
||||
{ svector<PCase::Item*>*tmp;
|
||||
tmp = new svector<PCase::Item*>(*$1, $2);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
{ $1->push_back($2);
|
||||
$$ = $1;
|
||||
}
|
||||
| case_item
|
||||
{ svector<PCase::Item*>*tmp = new svector<PCase::Item*>(1);
|
||||
(*tmp)[0] = $1;
|
||||
$$ = tmp;
|
||||
{ $$ = new std::vector<PCase::Item*>(1, $1);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3256,18 +3253,15 @@ event_control /* A.K.A. clocking_event */
|
|||
|
||||
event_expression_list
|
||||
: event_expression
|
||||
{ $$ = $1; }
|
||||
{ $$ = new std::vector<PEEvent*>(1, $1);
|
||||
}
|
||||
| event_expression_list K_or event_expression
|
||||
{ svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
|
||||
delete $1;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
{ $1->push_back($3);
|
||||
$$ = $1;
|
||||
}
|
||||
| event_expression_list ',' event_expression
|
||||
{ svector<PEEvent*>*tmp = new svector<PEEvent*>(*$1, *$3);
|
||||
delete $1;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
{ $1->push_back($3);
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -3275,31 +3269,23 @@ event_expression
|
|||
: K_posedge expression
|
||||
{ PEEvent*tmp = new PEEvent(PEEvent::POSEDGE, $2);
|
||||
FILE_NAME(tmp, @1);
|
||||
svector<PEEvent*>*tl = new svector<PEEvent*>(1);
|
||||
(*tl)[0] = tmp;
|
||||
$$ = tl;
|
||||
$$ = tmp;
|
||||
}
|
||||
| K_negedge expression
|
||||
{ PEEvent*tmp = new PEEvent(PEEvent::NEGEDGE, $2);
|
||||
FILE_NAME(tmp, @1);
|
||||
svector<PEEvent*>*tl = new svector<PEEvent*>(1);
|
||||
(*tl)[0] = tmp;
|
||||
$$ = tl;
|
||||
$$ = tmp;
|
||||
}
|
||||
| K_edge expression
|
||||
{ PEEvent*tmp = new PEEvent(PEEvent::EDGE, $2);
|
||||
FILE_NAME(tmp, @1);
|
||||
svector<PEEvent*>*tl = new svector<PEEvent*>(1);
|
||||
(*tl)[0] = tmp;
|
||||
$$ = tl;
|
||||
$$ = tmp;
|
||||
pform_requires_sv(@1, "Edge event");
|
||||
}
|
||||
| expression
|
||||
{ PEEvent*tmp = new PEEvent(PEEvent::ANYEDGE, $1);
|
||||
FILE_NAME(tmp, @1);
|
||||
svector<PEEvent*>*tl = new svector<PEEvent*>(1);
|
||||
(*tl)[0] = tmp;
|
||||
$$ = tl;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -4189,18 +4175,13 @@ gate_instance
|
|||
|
||||
gate_instance_list
|
||||
: gate_instance_list ',' gate_instance
|
||||
{ svector<lgate>*tmp1 = $1;
|
||||
lgate*tmp2 = $3;
|
||||
svector<lgate>*out = new svector<lgate> (*tmp1, *tmp2);
|
||||
delete tmp1;
|
||||
delete tmp2;
|
||||
$$ = out;
|
||||
{ $1->push_back(*$3);
|
||||
delete $3;
|
||||
$$ = $1;
|
||||
}
|
||||
| gate_instance
|
||||
{ svector<lgate>*tmp = new svector<lgate>(1);
|
||||
(*tmp)[0] = *$1;
|
||||
{ $$ = new std::vector<lgate>(1, *$1);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
|||
53
pform.cc
53
pform.cc
|
|
@ -1796,11 +1796,6 @@ PExpr* pform_select_mtm_expr(PExpr*min, PExpr*typ, PExpr*max)
|
|||
return res;
|
||||
}
|
||||
|
||||
template <> inline svector<perm_string>::svector(unsigned size)
|
||||
: nitems_(size), items_(new perm_string[size])
|
||||
{
|
||||
}
|
||||
|
||||
static void process_udp_table(PUdp*udp, list<string>*table,
|
||||
const struct vlltype&loc)
|
||||
{
|
||||
|
|
@ -1819,18 +1814,23 @@ static void process_udp_table(PUdp*udp, list<string>*table,
|
|||
|
||||
The parser doesn't check that we got the right kind here,
|
||||
so this loop must watch out. */
|
||||
svector<string> input (table->size());
|
||||
svector<char> current (table->size());
|
||||
svector<char> output (table->size());
|
||||
std::vector<string> &input = udp->tinput;
|
||||
std::vector<char> ¤t = udp->tcurrent;
|
||||
std::vector<char> &output = udp->toutput;
|
||||
|
||||
input.resize(table->size());
|
||||
current.resize(table->size());
|
||||
output.resize(table->size());
|
||||
|
||||
{ unsigned idx = 0;
|
||||
for (list<string>::iterator cur = table->begin()
|
||||
; cur != table->end() ; ++ cur , idx += 1) {
|
||||
string tmp = *cur;
|
||||
|
||||
/* Pull the input values from the string. */
|
||||
assert(tmp.find(':') == (udp->ports.count() - 1));
|
||||
input[idx] = tmp.substr(0, udp->ports.count()-1);
|
||||
tmp = tmp.substr(udp->ports.count()-1);
|
||||
assert(tmp.find(':') == (udp->ports.size() - 1));
|
||||
input[idx] = tmp.substr(0, udp->ports.size()-1);
|
||||
tmp = tmp.substr(udp->ports.size()-1);
|
||||
|
||||
assert(tmp[0] == ':');
|
||||
|
||||
|
|
@ -1862,9 +1862,6 @@ static void process_udp_table(PUdp*udp, list<string>*table,
|
|||
}
|
||||
}
|
||||
|
||||
udp->tinput = input;
|
||||
udp->tcurrent = current;
|
||||
udp->toutput = output;
|
||||
}
|
||||
|
||||
void pform_make_udp(const struct vlltype&loc, perm_string name,
|
||||
|
|
@ -1908,8 +1905,8 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
the parms list in the list of ports in the port list of the
|
||||
UDP declaration, and the defs map maps that name to a
|
||||
PWire* created by an input or output declaration. */
|
||||
svector<PWire*> pins (parms->size());
|
||||
svector<perm_string> pin_names (parms->size());
|
||||
std::vector<PWire*> pins(parms->size());
|
||||
std::vector<perm_string> pin_names(parms->size());
|
||||
{ list<perm_string>::iterator cur;
|
||||
unsigned idx;
|
||||
for (cur = parms->begin(), idx = 0
|
||||
|
|
@ -1930,7 +1927,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
-- An input port is declared output.
|
||||
|
||||
*/
|
||||
assert(pins.count() > 0);
|
||||
assert(pins.size() > 0);
|
||||
do {
|
||||
if (pins[0] == 0) {
|
||||
cerr << loc << ": error: "
|
||||
|
|
@ -1956,7 +1953,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
}
|
||||
} while (0);
|
||||
|
||||
for (unsigned idx = 1 ; idx < pins.count() ; idx += 1) {
|
||||
for (unsigned idx = 1 ; idx < pins.size() ; idx += 1) {
|
||||
if (pins[idx] == 0) {
|
||||
cerr << loc << ": error: "
|
||||
<< "Port " << (idx+1)
|
||||
|
|
@ -2044,7 +2041,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
udp->sequential = true;
|
||||
|
||||
// Make the port list for the UDP
|
||||
for (unsigned idx = 0 ; idx < pins.count() ; idx += 1)
|
||||
for (unsigned idx = 0 ; idx < pins.size() ; idx += 1)
|
||||
udp->ports[idx] = pins[idx]->basename();
|
||||
|
||||
process_udp_table(udp, table, loc);
|
||||
|
|
@ -2067,7 +2064,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
list<string>*table)
|
||||
{
|
||||
|
||||
svector<PWire*> pins(parms->size() + 1);
|
||||
std::vector<PWire*> pins(parms->size() + 1);
|
||||
|
||||
/* Make the PWire for the output port. */
|
||||
pins[0] = new PWire(out_name,
|
||||
|
|
@ -2081,12 +2078,12 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
for (cur = parms->begin(), idx = 1
|
||||
; cur != parms->end()
|
||||
; idx += 1, ++ cur) {
|
||||
assert(idx < pins.count());
|
||||
assert(idx < pins.size());
|
||||
pins[idx] = new PWire(*cur, NetNet::WIRE,
|
||||
NetNet::PINPUT, IVL_VT_LOGIC);
|
||||
FILE_NAME(pins[idx], loc);
|
||||
}
|
||||
assert(idx == pins.count());
|
||||
assert(idx == pins.size());
|
||||
}
|
||||
|
||||
/* Verify the initial expression, if present, to be sure that
|
||||
|
|
@ -2117,14 +2114,14 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
VLerror("UDP primitive already exists.");
|
||||
|
||||
} else {
|
||||
PUdp*udp = new PUdp(name, pins.count());
|
||||
PUdp*udp = new PUdp(name, pins.size());
|
||||
FILE_NAME(udp, loc);
|
||||
|
||||
// Detect sequential udp.
|
||||
udp->sequential = synchronous_flag;
|
||||
|
||||
// Make the port list for the UDP
|
||||
for (unsigned idx = 0 ; idx < pins.count() ; idx += 1)
|
||||
for (unsigned idx = 0 ; idx < pins.size() ; idx += 1)
|
||||
udp->ports[idx] = pins[idx]->basename();
|
||||
|
||||
assert(udp);
|
||||
|
|
@ -2238,7 +2235,7 @@ void pform_makegates(const struct vlltype&loc,
|
|||
PGBuiltin::Type type,
|
||||
struct str_pair_t str,
|
||||
list<PExpr*>*delay,
|
||||
svector<lgate>*gates,
|
||||
std::vector<lgate>*gates,
|
||||
list<named_pexpr_t>*attr)
|
||||
{
|
||||
assert(! pform_cur_module.empty());
|
||||
|
|
@ -2253,7 +2250,7 @@ void pform_makegates(const struct vlltype&loc,
|
|||
error_count += 1;
|
||||
}
|
||||
|
||||
for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < gates->size() ; idx += 1) {
|
||||
pform_makegate(type, str, delay, (*gates)[idx], attr);
|
||||
}
|
||||
|
||||
|
|
@ -2369,7 +2366,7 @@ static void pform_make_modgate(perm_string type,
|
|||
void pform_make_modgates(const struct vlltype&loc,
|
||||
perm_string type,
|
||||
struct parmvalue_t*overrides,
|
||||
svector<lgate>*gates,
|
||||
std::vector<lgate>*gates,
|
||||
std::list<named_pexpr_t>*attr)
|
||||
{
|
||||
// The grammer should not allow module gates to happen outside
|
||||
|
|
@ -2399,7 +2396,7 @@ void pform_make_modgates(const struct vlltype&loc,
|
|||
error_count += 1;
|
||||
}
|
||||
|
||||
for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < gates->size() ; idx += 1) {
|
||||
lgate cur = (*gates)[idx];
|
||||
perm_string cur_name = lex_strings.make(cur.name);
|
||||
|
||||
|
|
|
|||
4
pform.h
4
pform.h
|
|
@ -445,13 +445,13 @@ extern void pform_makegates(const struct vlltype&loc,
|
|||
PGBuiltin::Type type,
|
||||
struct str_pair_t str,
|
||||
std::list<PExpr*>*delay,
|
||||
svector<lgate>*gates,
|
||||
std::vector<lgate>*gates,
|
||||
std::list<named_pexpr_t>*attr);
|
||||
|
||||
extern void pform_make_modgates(const struct vlltype&loc,
|
||||
perm_string type,
|
||||
struct parmvalue_t*overrides,
|
||||
svector<lgate>*gates,
|
||||
std::vector<lgate>*gates,
|
||||
std::list<named_pexpr_t>*attr);
|
||||
|
||||
/* Make a continuous assignment node, with optional bit- or part- select. */
|
||||
|
|
|
|||
|
|
@ -950,7 +950,7 @@ void PCase::dump(ostream&out, unsigned ind) const
|
|||
out << " (" << *expr_ << ") /* " << get_fileline() << " */" << endl;
|
||||
dump_attributes_map(out, attributes, ind+2);
|
||||
|
||||
for (unsigned idx = 0 ; idx < items_->count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < items_->size() ; idx += 1) {
|
||||
PCase::Item*cur = (*items_)[idx];
|
||||
|
||||
if (cur->expr.empty()) {
|
||||
|
|
@ -1050,16 +1050,16 @@ void PDoWhile::dump(ostream&out, unsigned ind) const
|
|||
|
||||
void PEventStatement::dump(ostream&out, unsigned ind) const
|
||||
{
|
||||
if (expr_.count() == 0) {
|
||||
if (expr_.size() == 0) {
|
||||
out << setw(ind) << "" << "@* ";
|
||||
|
||||
} else if ((expr_.count() == 1) && (expr_[0] == 0)) {
|
||||
} else if ((expr_.size() == 1) && (expr_[0] == 0)) {
|
||||
out << setw(ind) << "" << "wait fork ";
|
||||
|
||||
} else {
|
||||
out << setw(ind) << "" << "@(" << *(expr_[0]);
|
||||
if (expr_.count() > 1)
|
||||
for (unsigned idx = 1 ; idx < expr_.count() ; idx += 1)
|
||||
if (expr_.size() > 1)
|
||||
for (unsigned idx = 1 ; idx < expr_.size() ; idx += 1)
|
||||
out << " or " << *(expr_[idx]);
|
||||
|
||||
out << ")";
|
||||
|
|
@ -1077,13 +1077,13 @@ void PEventStatement::dump_inline(ostream&out) const
|
|||
{
|
||||
assert(statement_ == 0);
|
||||
|
||||
if (expr_.count() == 0) {
|
||||
if (expr_.size() == 0) {
|
||||
out << "@* ";
|
||||
|
||||
} else {
|
||||
out << "@(" << *(expr_[0]);
|
||||
if (expr_.count() > 1)
|
||||
for (unsigned idx = 1 ; idx < expr_.count() ; idx += 1)
|
||||
if (expr_.size() > 1)
|
||||
for (unsigned idx = 1 ; idx < expr_.size() ; idx += 1)
|
||||
out << " or " << *(expr_[idx]);
|
||||
|
||||
out << ")";
|
||||
|
|
@ -1775,7 +1775,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.count() ; idx += 1)
|
||||
for (unsigned idx = 1 ; idx < ports.size() ; idx += 1)
|
||||
out << ", " << ports[idx];
|
||||
out << ");" << endl;
|
||||
|
||||
|
|
@ -1783,7 +1783,7 @@ void PUdp::dump(ostream&out) const
|
|||
out << " reg " << ports[0] << ";" << endl;
|
||||
|
||||
out << " table" << endl;
|
||||
for (unsigned idx = 0 ; idx < tinput.count() ; idx += 1) {
|
||||
for (unsigned idx = 0 ; idx < tinput.size() ; idx += 1) {
|
||||
out << " ";
|
||||
for (unsigned chr = 0 ; chr < tinput[idx].length() ; chr += 1)
|
||||
out << " " << tinput[idx][chr];
|
||||
|
|
|
|||
|
|
@ -77,9 +77,7 @@ typedef std::pair<PExpr*,PExpr*> pform_range_t;
|
|||
|
||||
/* The lgate is gate instantiation information. */
|
||||
struct lgate : public LineInfo {
|
||||
explicit lgate(int = 0)
|
||||
: parms(0), parms_by_name(0), ranges(0)
|
||||
{ }
|
||||
explicit lgate() : parms(0), parms_by_name(0), ranges(0) { }
|
||||
|
||||
std::string name;
|
||||
std::list<PExpr*>*parms;
|
||||
|
|
|
|||
121
svector.h
121
svector.h
|
|
@ -1,121 +0,0 @@
|
|||
#ifndef IVL_svector_H
|
||||
#define IVL_svector_H
|
||||
/*
|
||||
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
* General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version. In order to redistribute the software in
|
||||
* binary form, you will need a Picture Elements Binary Software
|
||||
* License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
# include "config.h"
|
||||
# include <string>
|
||||
# include <vector>
|
||||
# include <cassert>
|
||||
|
||||
/*
|
||||
* This is a way simplified vector class that cannot grow or shrink,
|
||||
* and is really only able to handle values. It is intended to be
|
||||
* lighter weight than the STL list class.
|
||||
*/
|
||||
|
||||
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] = TYPE(0);
|
||||
}
|
||||
|
||||
svector(const svector<TYPE>&that)
|
||||
: nitems_(that.nitems_), items_(new TYPE[nitems_])
|
||||
{ for (unsigned idx = 0 ; idx < that.nitems_ ; idx += 1)
|
||||
items_[idx] = that[idx];
|
||||
}
|
||||
|
||||
svector(const svector<TYPE>&l, const svector<TYPE>&r)
|
||||
: nitems_(l.nitems_ + r.nitems_), items_(new TYPE[nitems_])
|
||||
{ for (unsigned idx = 0 ; idx < l.nitems_ ; idx += 1)
|
||||
items_[idx] = l[idx];
|
||||
|
||||
for (unsigned idx = 0 ; idx < r.nitems_ ; idx += 1)
|
||||
items_[l.nitems_+idx] = r[idx];
|
||||
}
|
||||
|
||||
svector(const svector<TYPE>&l, const 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_; }
|
||||
|
||||
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)
|
||||
{ assert(idx < nitems_);
|
||||
return items_[idx];
|
||||
}
|
||||
|
||||
TYPE operator[] (unsigned idx) const
|
||||
{ assert(idx < nitems_);
|
||||
return items_[idx];
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned nitems_;
|
||||
TYPE* items_;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Override the implementation of the above template for the string
|
||||
* type parameter. The initialization to nil works different here.
|
||||
*/
|
||||
template <> inline svector<std::string>::svector(unsigned size)
|
||||
: nitems_(size), items_(new std::string[size])
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a convenience function that converts an svector to a
|
||||
* vector. This is to ease the transition from svector to vector so
|
||||
* that the svector class can be gradually removed.
|
||||
*/
|
||||
template <class T> inline std::vector<T> vector_from_svector(const svector<T>&that)
|
||||
{
|
||||
std::vector<T> res (that.count());
|
||||
for (unsigned idx = 0 ; idx < that.count() ; idx += 1)
|
||||
res[idx] = that[idx];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* IVL_svector_H */
|
||||
Loading…
Reference in New Issue