Skip to content

Commit

Permalink
Rework the heirarchical identifier parse syntax and pform
Browse files Browse the repository at this point in the history
 to handle more general combinations of heirarch and bit selects.
  • Loading branch information
steve committed May 24, 2007
1 parent 67b1eee commit ddd36ec
Show file tree
Hide file tree
Showing 30 changed files with 1,036 additions and 681 deletions.
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.180 2007/02/06 05:07:31 steve Exp $"
#ident "$Id: Makefile.in,v 1.181 2007/05/24 04:07:11 steve Exp $"
#
#
SHELL = /bin/sh
Expand Down Expand Up @@ -108,7 +108,7 @@ load_module.o netlist.o netmisc.o net_assign.o \
net_design.o net_event.o net_expr.o net_force.o net_func.o \
net_link.o net_modulo.o net_nex_input.o net_nex_output.o \
net_proc.o net_scope.o net_udp.o pad_to_width.o \
parse.o parse_misc.o pform.o pform_dump.o \
parse.o parse_misc.o pform.o pform_dump.o pform_types.o \
set_width.o symbol_search.o sync.o sys_funcs.o \
verinum.o verireal.o target.o targets.o \
Attrib.o HName.o LineInfo.o Module.o PDelays.o PEvent.o \
Expand Down
15 changes: 7 additions & 8 deletions Module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: Module.cc,v 1.26 2007/04/19 02:52:53 steve Exp $"
#ident "$Id: Module.cc,v 1.27 2007/05/24 04:07:11 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -111,9 +111,9 @@ unsigned Module::find_port(const char*name) const
}


PWire* Module::get_wire(const hname_t&name) const
PWire* Module::get_wire(const pform_name_t&name) const
{
map<hname_t,PWire*>::const_iterator obj = wires_.find(name);
map<pform_name_t,PWire*>::const_iterator obj = wires_.find(name);
if (obj == wires_.end())
return 0;
else
Expand All @@ -133,11 +133,6 @@ PGate* Module::get_gate(perm_string name)
return 0;
}

const map<hname_t,PWire*>& Module::get_wires() const
{
return wires_;
}

const list<PGate*>& Module::get_gates() const
{
return gates_;
Expand All @@ -151,6 +146,10 @@ const list<PProcess*>& Module::get_behaviors() const

/*
* $Log: Module.cc,v $
* Revision 1.27 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
*
* Revision 1.26 2007/04/19 02:52:53 steve
* Add support for -v flag in command file.
*
Expand Down
14 changes: 9 additions & 5 deletions Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: Module.h,v 1.42 2007/04/19 02:52:53 steve Exp $"
#ident "$Id: Module.h,v 1.43 2007/05/24 04:07:11 steve Exp $"
#endif

# include <list>
Expand All @@ -30,6 +30,7 @@
# include "named.h"
# include "LineInfo.h"
# include "netlist.h"
# include "pform_types.h"
class PEvent;
class PExpr;
class PEIdent;
Expand Down Expand Up @@ -98,7 +99,7 @@ class Module : public LineInfo {
new parameters within the module, but may be used to set
values within this module (when instantiated) or in other
instantiated modules. */
map<hname_t,PExpr*>defparms;
map<pform_name_t,PExpr*>defparms;

/* Parameters may be overridden at instantiation time;
the overrides do not contain explicit parameter names,
Expand Down Expand Up @@ -150,10 +151,9 @@ class Module : public LineInfo {

// Find a wire by name. This is used for connecting gates to
// existing wires, etc.
PWire* get_wire(const hname_t&name) const;
PWire* get_wire(const pform_name_t&name) const;
PGate* get_gate(perm_string name);

const map<hname_t,PWire*>& get_wires() const;
const list<PGate*>& get_gates() const;
const list<PProcess*>& get_behaviors() const;

Expand All @@ -168,7 +168,7 @@ class Module : public LineInfo {
private:
perm_string name_;

map<hname_t,PWire*> wires_;
map<pform_name_t,PWire*> wires_;
list<PGate*> gates_;
list<PProcess*> behaviors_;
map<perm_string,PTask*> tasks_;
Expand All @@ -182,6 +182,10 @@ class Module : public LineInfo {

/*
* $Log: Module.h,v $
* Revision 1.43 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
*
* Revision 1.42 2007/04/19 02:52:53 steve
* Add support for -v flag in command file.
*
Expand Down
44 changes: 30 additions & 14 deletions PExpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: PExpr.cc,v 1.38 2006/10/30 05:44:49 steve Exp $"
#ident "$Id: PExpr.cc,v 1.39 2007/05/24 04:07:11 steve Exp $"
#endif

# include "config.h"
Expand Down Expand Up @@ -93,13 +93,26 @@ PEBShift::~PEBShift()
{
}

PECallFunction::PECallFunction(const hname_t&n, const svector<PExpr *> &parms)
PECallFunction::PECallFunction(const pform_name_t&n, const svector<PExpr *> &parms)
: path_(n), parms_(parms)
{
}

PECallFunction::PECallFunction(const hname_t&n)
: path_(n)
static pform_name_t pn_from_ps(perm_string n)
{
name_component_t tmp_name (n);
pform_name_t tmp;
tmp.push_back(tmp_name);
return tmp;
}

PECallFunction::PECallFunction(perm_string n, const svector<PExpr*>&parms)
: path_(pn_from_ps(n)), parms_(parms)
{
}

PECallFunction::PECallFunction(perm_string n)
: path_(pn_from_ps(n))
{
}

Expand Down Expand Up @@ -165,33 +178,32 @@ bool PEFNumber::is_constant(Module*) const
return true;
}

PEIdent::PEIdent(const hname_t&s)
: path_(s), msb_(0), lsb_(0), sel_(SEL_NONE), idx_(0)
PEIdent::PEIdent(const pform_name_t&that)
: path_(that)
{
}

PEIdent::~PEIdent()
PEIdent::PEIdent(perm_string s)
{
path_.push_back(name_component_t(s));
}

const hname_t& PEIdent::path() const
PEIdent::~PEIdent()
{
return path_;
}

/*
* An identifier can be in a constant expression if (and only if) it is
* a parameter.
*
* NOTE: This test does not work if the name is hierarchical!
*/
bool PEIdent::is_constant(Module*mod) const
{
if (mod == 0) return false;

/* This is a work-around for map not matching < even when
there is a perm_string operator that can do the comprare.
The real fix is to make the path_ carry perm_strings. */
perm_string tmp = perm_string::literal(path_.peek_name(0));
/* */
perm_string tmp = path_.back().name;

{ map<perm_string,Module::param_expr_t>::const_iterator cur;
cur = mod->parameters.find(tmp);
Expand Down Expand Up @@ -288,6 +300,10 @@ bool PEUnary::is_constant(Module*m) const

/*
* $Log: PExpr.cc,v $
* Revision 1.39 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
*
* Revision 1.38 2006/10/30 05:44:49 steve
* Expression widths with unsized literals are pseudo-infinite width.
*
Expand Down
31 changes: 24 additions & 7 deletions PExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: PExpr.h,v 1.87 2007/01/16 05:44:14 steve Exp $"
#ident "$Id: PExpr.h,v 1.88 2007/05/24 04:07:11 steve Exp $"
#endif

# include <string>
# include <vector>
# include "netlist.h"
# include "verinum.h"
# include "LineInfo.h"
# include "pform_types.h"

class Design;
class Module;
Expand Down Expand Up @@ -247,9 +248,14 @@ class PEFNumber : public PExpr {
class PEIdent : public PExpr {

public:
explicit PEIdent(const hname_t&s);
explicit PEIdent(perm_string);
explicit PEIdent(const pform_name_t&);
~PEIdent();

// Add another name to the string of heirarchy that is the
// current identifier.
void append_name(perm_string);

virtual void dump(ostream&) const;
virtual unsigned test_width(Design*des, NetScope*scope,
unsigned min, unsigned lval,
Expand Down Expand Up @@ -286,7 +292,10 @@ class PEIdent : public PExpr {
virtual bool is_constant(Module*) const;
verinum* eval_const(const Design*des, NetScope*sc) const;

const hname_t& path() const;
const pform_name_t& path() const { return path_; }

private:
pform_name_t path_;

private:
// Common functions to calculate parts of part/bit selects.
Expand Down Expand Up @@ -332,9 +341,9 @@ class PEIdent : public PExpr {
NetScope*scope,
NetESignal*net,
NetScope*found) const;
hname_t path_;

public:
#if 0
// Use these to support part-select operators.
PExpr*msb_;
PExpr*lsb_;
Expand All @@ -345,6 +354,8 @@ class PEIdent : public PExpr {
// expression. If this is a reference to a vector, this is a
// bit select.
std::vector<PExpr*> idx_;
#endif

NetNet* elaborate_net_array_(Design*des, NetScope*scope,
NetNet*sig, unsigned lwidth,
const NetExpr* rise,
Expand Down Expand Up @@ -621,8 +632,10 @@ class PETernary : public PExpr {
*/
class PECallFunction : public PExpr {
public:
explicit PECallFunction(const hname_t&n, const svector<PExpr *> &parms);
explicit PECallFunction(const hname_t&n);
explicit PECallFunction(const pform_name_t&n, const svector<PExpr *> &parms);
// Call of system function (name is not heirarchical)
explicit PECallFunction(perm_string n, const svector<PExpr *> &parms);
explicit PECallFunction(perm_string n);
~PECallFunction();

virtual void dump(ostream &) const;
Expand All @@ -638,7 +651,7 @@ class PECallFunction : public PExpr {
int expr_wid, bool sys_task_arg) const;

private:
hname_t path_;
pform_name_t path_;
svector<PExpr *> parms_;

bool check_call_matches_definition_(Design*des, NetScope*dscope) const;
Expand All @@ -655,6 +668,10 @@ class PECallFunction : public PExpr {

/*
* $Log: PExpr.h,v $
* Revision 1.88 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
*
* Revision 1.87 2007/01/16 05:44:14 steve
* Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory
Expand Down
6 changes: 3 additions & 3 deletions PGenerate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: PGenerate.cc,v 1.2 2007/03/05 05:59:10 steve Exp $"
#ident "$Id: PGenerate.cc,v 1.3 2007/05/24 04:07:11 steve Exp $"
#endif

# include "PGenerate.h"
Expand All @@ -42,9 +42,9 @@ PWire* PGenerate::add_wire(PWire*wire)
return wire;
}

PWire* PGenerate::get_wire(const hname_t&name) const
PWire* PGenerate::get_wire(const pform_name_t&name) const
{
map<hname_t,PWire*>::const_iterator obj = wires.find(name);
map<pform_name_t,PWire*>::const_iterator obj = wires.find(name);
if (obj == wires.end())
return 0;
else
Expand Down
7 changes: 4 additions & 3 deletions PGenerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: PGenerate.h,v 1.2 2007/03/05 05:59:10 steve Exp $"
#ident "$Id: PGenerate.h,v 1.3 2007/05/24 04:07:11 steve Exp $"
#endif

# include "LineInfo.h"
# include "StringHeap.h"
# include "HName.h"
# include <list>
# include <map>
# include "pform_types.h"

class Design;
class NetScope;
Expand Down Expand Up @@ -59,9 +60,9 @@ class PGenerate : public LineInfo {
PExpr*loop_test;
PExpr*loop_step;

map<hname_t,PWire*>wires;
map<pform_name_t,PWire*>wires;
PWire* add_wire(PWire*);
PWire* get_wire(const hname_t&name) const;
PWire* get_wire(const pform_name_t&name) const;

list<PGate*> gates;
void add_gate(PGate*);
Expand Down
Loading

0 comments on commit ddd36ec

Please sign in to comment.