Add memories to the parse and elaboration phases.

This commit is contained in:
steve 1999-04-19 01:59:36 +00:00
parent bd40e5dfe1
commit 5895d3c98d
14 changed files with 364 additions and 68 deletions

14
PExpr.h
View File

@ -19,11 +19,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: PExpr.h,v 1.4 1998/11/11 00:01:51 steve Exp $" #ident "$Id: PExpr.h,v 1.5 1999/04/19 01:59:36 steve Exp $"
#endif #endif
# include <string> # include <string>
# include "verinum.h" # include "verinum.h"
# include "LineInfo.h"
class Design; class Design;
class NetNet; class NetNet;
@ -38,7 +39,7 @@ class NetExpr;
* up a netlist interpretation of the expression. * up a netlist interpretation of the expression.
*/ */
class PExpr { class PExpr : public LineInfo {
public: public:
virtual ~PExpr(); virtual ~PExpr();
@ -63,7 +64,7 @@ class PEIdent : public PExpr {
public: public:
explicit PEIdent(const string&s) explicit PEIdent(const string&s)
: text_(s), msb_(0), lsb_(0) { } : text_(s), msb_(0), lsb_(0), idx_(0) { }
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
virtual NetNet* elaborate_net(Design*des, const string&path) const; virtual NetNet* elaborate_net(Design*des, const string&path) const;
@ -77,6 +78,10 @@ class PEIdent : public PExpr {
// Use these to support bit- and part-select operators. // Use these to support bit- and part-select operators.
PExpr*msb_; PExpr*msb_;
PExpr*lsb_; PExpr*lsb_;
// If this is a reference to a memory, this is the index
// expression.
PExpr*idx_;
}; };
class PENumber : public PExpr { class PENumber : public PExpr {
@ -146,6 +151,9 @@ class PEBinary : public PExpr {
/* /*
* $Log: PExpr.h,v $ * $Log: PExpr.h,v $
* Revision 1.5 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.4 1998/11/11 00:01:51 steve * Revision 1.4 1998/11/11 00:01:51 steve
* Check net ranges in declarations. * Check net ranges in declarations.
* *

13
PWire.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: PWire.h,v 1.2 1998/11/23 00:20:22 steve Exp $" #ident "$Id: PWire.h,v 1.3 1999/04/19 01:59:36 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -37,7 +37,8 @@ class PWire {
public: public:
PWire(const string&n, NetNet::Type t =NetNet::IMPLICIT) PWire(const string&n, NetNet::Type t =NetNet::IMPLICIT)
: name(n), type(t), port_type(NetNet::NOT_A_PORT), msb(0), lsb(0) : name(n), type(t), port_type(NetNet::NOT_A_PORT), msb(0),
lsb(0), lidx(0), ridx(0)
{ } { }
string name; string name;
@ -47,6 +48,11 @@ class PWire {
PExpr*msb; PExpr*msb;
PExpr*lsb; PExpr*lsb;
// If this wire is actually a memory, these indices will give
// me the size and address range of the memory.
PExpr*lidx;
PExpr*ridx;
map<string,string> attributes; map<string,string> attributes;
// Write myself to the specified stream. // Write myself to the specified stream.
@ -61,6 +67,9 @@ class PWire {
/* /*
* $Log: PWire.h,v $ * $Log: PWire.h,v $
* Revision 1.3 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.2 1998/11/23 00:20:22 steve * Revision 1.2 1998/11/23 00:20:22 steve
* NetAssign handles lvalues as pin links * NetAssign handles lvalues as pin links
* instead of a signal pointer, * instead of a signal pointer,

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.16 1999/03/15 02:43:32 steve Exp $" #ident "$Id: design_dump.cc,v 1.17 1999/04/19 01:59:36 steve Exp $"
#endif #endif
/* /*
@ -57,6 +57,12 @@ void NetNet::dump_net(ostream&o, unsigned ind) const
dump_obj_attr(o, ind+4); dump_obj_attr(o, ind+4);
} }
void NetMemory::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << name_ << "[" << width_ << "] " <<
"[" << idxh_ << ":" << idxl_ << "]" << endl;
}
/* Dump a NetNode and its pins. Dump what I know about the netnode on /* Dump a NetNode and its pins. Dump what I know about the netnode on
the first line, then list all the pins, with the name of the the first line, then list all the pins, with the name of the
@ -463,6 +469,13 @@ void NetESignal::dump(ostream&o) const
o << name(); o << name();
} }
void NetEMemory::dump(ostream&o) const
{
o << mem_->name() << "[";
idx_->dump(o);
o << "]";
}
void NetESignal::dump_node(ostream&o, unsigned ind) const void NetESignal::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "Expression Node: " << name() << endl; o << setw(ind) << "" << "Expression Node: " << name() << endl;
@ -500,6 +513,15 @@ void Design::dump(ostream&o) const
} while (cur != signals_->sig_next_); } while (cur != signals_->sig_next_);
} }
o << "ELABORATED MEMORIES:" << endl;
{
map<string,NetMemory*>::const_iterator pp;
for (pp = memories_.begin()
; pp != memories_.end() ; pp ++) {
(*pp).second->dump(o, 0);
}
}
o << "ELABORATED NODES:" << endl; o << "ELABORATED NODES:" << endl;
// dump the nodes, // dump the nodes,
@ -521,6 +543,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.17 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.16 1999/03/15 02:43:32 steve * Revision 1.16 1999/03/15 02:43:32 steve
* Support more operators, especially logical. * Support more operators, especially logical.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.18 1999/03/15 02:43:32 steve Exp $" #ident "$Id: elaborate.cc,v 1.19 1999/04/19 01:59:36 steve Exp $"
#endif #endif
/* /*
@ -91,7 +91,13 @@ static void do_assign(Design*des, const string&path,
static const map<string,Module*>* modlist = 0; static const map<string,Module*>* modlist = 0;
static const map<string,PUdp*>* udplist = 0; static const map<string,PUdp*>* udplist = 0;
/* Elaborate a source wire. Generally pretty easy. */ /*
* Elaborate a source wire. The "wire" is the declaration of wires,
* registers, ports and memories. The parser has already merged the
* multiple properties of a wire (i.e. "input wire") so come the
* elaboration this creates an object in the design that represent the
* defined item.
*/
void PWire::elaborate(Design*des, const string&path) const void PWire::elaborate(Design*des, const string&path) const
{ {
NetNet::Type wtype = type; NetNet::Type wtype = type;
@ -100,6 +106,8 @@ void PWire::elaborate(Design*des, const string&path) const
unsigned wid = 1; unsigned wid = 1;
/* Wires, registers and memories can have a width, expressed
as the msb index and lsb index. */
if (msb && lsb) { if (msb && lsb) {
verinum*mval = msb->eval_const(); verinum*mval = msb->eval_const();
assert(mval); assert(mval);
@ -123,11 +131,30 @@ void PWire::elaborate(Design*des, const string&path) const
wid = val->as_ulong(); wid = val->as_ulong();
} }
if (lidx || ridx) {
// If the register has indices, then this is a
// memory. Create the memory object.
verinum*lval = lidx->eval_const();
assert(lval);
verinum*rval = ridx->eval_const();
assert(rval);
long lnum = lval->as_long();
long rnum = rval->as_long();
delete lval;
delete rval;
NetMemory*sig = new NetMemory(path+"."+name, wid, lnum, rnum);
sig->set_attributes(attributes);
des->add_memory(sig);
} else {
NetNet*sig = new NetNet(path + "." + name, wtype, wid); NetNet*sig = new NetNet(path + "." + name, wtype, wid);
sig->port_type(port_type); sig->port_type(port_type);
sig->set_attributes(attributes); sig->set_attributes(attributes);
des->add_signal(sig); des->add_signal(sig);
} }
}
void PGate::elaborate(Design*des, const string&path) const void PGate::elaborate(Design*des, const string&path) const
{ {
@ -667,7 +694,26 @@ NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const
return node; return node;
} }
assert(0); if (NetMemory*mem = des->find_memory(name)) {
assert(msb_ != 0);
assert(lsb_ == 0);
assert(idx_ == 0);
NetExpr*i = msb_->elaborate_expr(des, path);
if (i == 0) {
cerr << get_line() << ": Unable to exaborate "
"index expression `" << *msb_ << "'" << endl;
des->errors += 1;
return 0;
}
NetEMemory*node = new NetEMemory(mem, i);
return node;
}
cerr << get_line() << ": Unable to bind wire/reg/memory "
"`" << path << "." << text_ << "'" << endl;
des->errors += 1;
return 0;
} }
} }
@ -709,6 +755,11 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
assert(expr_); assert(expr_);
NetExpr*rval = expr_->elaborate_expr(des, path); NetExpr*rval = expr_->elaborate_expr(des, path);
if (rval == 0) {
cerr << get_line() << ": " << "failed to elaborate expression."
<< endl;
return 0;
}
assert(rval); assert(rval);
NetAssign*cur = new NetAssign(reg, rval); NetAssign*cur = new NetAssign(reg, rval);
@ -977,6 +1028,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.19 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.18 1999/03/15 02:43:32 steve * Revision 1.18 1999/03/15 02:43:32 steve
* Support more operators, especially logical. * Support more operators, especially logical.
* *

19
emit.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: emit.cc,v 1.6 1999/02/08 02:49:56 steve Exp $" #ident "$Id: emit.cc,v 1.7 1999/04/19 01:59:36 steve Exp $"
#endif #endif
/* /*
@ -173,6 +173,15 @@ void Design::emit(ostream&o, struct target_t*tgt) const
} }
// emit memories
{
map<string,NetMemory*>::const_iterator mi;
for (mi = memories_.begin() ; mi != memories_.end() ; mi++) {
tgt->memory(o, (*mi).second);
}
}
// emit nodes // emit nodes
{ {
NetNode*cur = nodes_->node_next_; NetNode*cur = nodes_->node_next_;
@ -205,6 +214,11 @@ void NetEIdent::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_ident(this); tgt->expr_ident(this);
} }
void NetEMemory::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_memory(this);
}
void NetESignal::expr_scan(struct expr_scan_t*tgt) const void NetESignal::expr_scan(struct expr_scan_t*tgt) const
{ {
tgt->expr_signal(this); tgt->expr_signal(this);
@ -234,6 +248,9 @@ void emit(ostream&o, const Design*des, const char*type)
/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.7 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.6 1999/02/08 02:49:56 steve * Revision 1.6 1999/02/08 02:49:56 steve
* Turn the NetESignal into a NetNode so * Turn the NetESignal into a NetNode so
* that it can connect to the netlist. * that it can connect to the netlist.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: netlist.cc,v 1.19 1999/03/15 02:43:32 steve Exp $" #ident "$Id: netlist.cc,v 1.20 1999/04/19 01:59:36 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -240,6 +240,26 @@ NetNode::~NetNode()
design_->del_node(this); design_->del_node(this);
} }
NetNet::NetNet(const string&n, Type t, unsigned npins)
: NetObj(n, npins), sig_next_(0), sig_prev_(0), design_(0),
type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0),
local_flag_(false)
{
ivalue_ = new verinum::V[npins];
for (unsigned idx = 0 ; idx < npins ; idx += 1)
ivalue_[idx] = verinum::Vz;
}
NetNet::NetNet(const string&n, Type t, long ms, long ls)
: NetObj(n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
sig_prev_(0), design_(0), type_(t), port_type_(NOT_A_PORT),
msb_(ms), lsb_(ls), local_flag_(false)
{
ivalue_ = new verinum::V[pin_count()];
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1)
ivalue_[idx] = verinum::Vz;
}
NetNet::~NetNet() NetNet::~NetNet()
{ {
if (design_) if (design_)
@ -477,6 +497,27 @@ void NetEConst::set_width(unsigned w)
expr_width(w); expr_width(w);
} }
NetEMemory::NetEMemory(NetMemory*m, NetExpr*i)
: mem_(m), idx_(i)
{
}
NetEMemory::~NetEMemory()
{
}
void NetMemory::set_attributes(const map<string,string>&attr)
{
assert(attributes_.size() == 0);
attributes_ = attr;
}
void NetEMemory::set_width(unsigned w)
{
assert(w == mem_->width());
expr_width(w);
}
NetESignal::NetESignal(NetNet*n) NetESignal::NetESignal(NetNet*n)
: NetExpr(n->pin_count()), NetNode(n->name(), n->pin_count()) : NetExpr(n->pin_count()), NetNode(n->name(), n->pin_count())
{ {
@ -854,6 +895,20 @@ NetNet* Design::find_signal(const string&name)
return 0; return 0;
} }
void Design::add_memory(NetMemory*mem)
{
memories_[mem->name()] = mem;
}
NetMemory* Design::find_memory(const string&key)
{
map<string,NetMemory*>::const_iterator cur = memories_.find(key);
if (cur == memories_.end())
return 0;
return (*cur).second;
}
void Design::add_node(NetNode*net) void Design::add_node(NetNode*net)
{ {
assert(net->design_ == 0); assert(net->design_ == 0);
@ -961,6 +1016,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.20 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.19 1999/03/15 02:43:32 steve * Revision 1.19 1999/03/15 02:43:32 steve
* Support more operators, especially logical. * Support more operators, especially logical.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: netlist.h,v 1.22 1999/03/15 02:43:32 steve Exp $" #ident "$Id: netlist.h,v 1.23 1999/04/19 01:59:36 steve Exp $"
#endif #endif
/* /*
@ -218,27 +218,13 @@ class NetNet : public NetObj {
enum PortType { NOT_A_PORT, PIMPLICIT, PINPUT, POUTPUT, PINOUT }; enum PortType { NOT_A_PORT, PIMPLICIT, PINPUT, POUTPUT, PINOUT };
explicit NetNet(const string&n, Type t, unsigned npins =1) explicit NetNet(const string&n, Type t, unsigned npins =1);
: NetObj(n, npins), sig_next_(0), sig_prev_(0), design_(0),
type_(t), port_type_(NOT_A_PORT), msb_(npins-1), lsb_(0),
local_flag_(false)
{ ivalue_ = new verinum::V[npins];
for (unsigned idx = 0 ; idx < npins ; idx += 1)
ivalue_[idx] = verinum::Vz;
}
explicit NetNet(const string&n, Type t, long ms, long ls) explicit NetNet(const string&n, Type t, long ms, long ls);
: NetObj(n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0),
sig_prev_(0), design_(0), type_(t), port_type_(NOT_A_PORT),
msb_(ms), lsb_(ls), local_flag_(false)
{ ivalue_ = new verinum::V[pin_count()];
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1)
ivalue_[idx] = verinum::Vz;
}
virtual ~NetNet(); virtual ~NetNet();
// Every signal has a name, even if it is null.
Type type() const { return type_; } Type type() const { return type_; }
void type(Type t) { type_ = t; } void type(Type t) { type_ = t; }
@ -282,6 +268,34 @@ class NetNet : public NetObj {
verinum::V*ivalue_; verinum::V*ivalue_;
}; };
/*
* This class represents the declared memory object. The parser
* creates one of these for each declared memory in the elaborated
* design. A reference to one of these is handled by the NetEMemory
* object, which is derived from NetExpr.
*/
class NetMemory {
public:
NetMemory(const string&n, long w, long s, long e)
: name_(n), width_(w), idxh_(s), idxl_(e) { }
const string&name() const { return name_; }
unsigned width() const { return width_; }
void set_attributes(const map<string,string>&a);
void dump(ostream&o, unsigned lm) const;
private:
string name_;
unsigned width_;
long idxh_;
long idxl_;
map<string,string> attributes_;
};
/* ========= /* =========
* There are cases where expressions need to be represented. The * There are cases where expressions need to be represented. The
* NetExpr class is the root of a heirarchy that serves that purpose. * NetExpr class is the root of a heirarchy that serves that purpose.
@ -897,6 +911,24 @@ class NetEIdent : public NetExpr {
string name_; string name_;
}; };
/*
* A reference to a memory is represented by this expression.
*/
class NetEMemory : public NetExpr {
public:
NetEMemory(NetMemory*mem, NetExpr*idx);
virtual ~NetEMemory();
virtual void set_width(unsigned);
virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const;
private:
NetMemory*mem_;
NetExpr::REF idx_;
};
/* /*
* When a signal shows up in an expression, this type represents * When a signal shows up in an expression, this type represents
* it. From this the expression can get any kind of access to the * it. From this the expression can get any kind of access to the
@ -953,6 +985,10 @@ class Design {
void del_signal(NetNet*); void del_signal(NetNet*);
NetNet*find_signal(const string&name); NetNet*find_signal(const string&name);
// Memories
void add_memory(NetMemory*);
NetMemory* find_memory(const string&name);
// NODES // NODES
void add_node(NetNode*); void add_node(NetNode*);
void del_node(NetNode*); void del_node(NetNode*);
@ -988,6 +1024,8 @@ class Design {
// List all the signals in the design. // List all the signals in the design.
NetNet*signals_; NetNet*signals_;
map<string,NetMemory*> memories_;
// List the nodes in the design // List the nodes in the design
NetNode*nodes_; NetNode*nodes_;
@ -1048,6 +1086,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.23 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.22 1999/03/15 02:43:32 steve * Revision 1.22 1999/03/15 02:43:32 steve
* Support more operators, especially logical. * Support more operators, especially logical.
* *

70
parse.y
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: parse.y,v 1.16 1999/03/16 04:44:45 steve Exp $" #ident "$Id: parse.y,v 1.17 1999/04/19 01:59:37 steve Exp $"
#endif #endif
# include "parse_misc.h" # include "parse_misc.h"
@ -87,7 +87,7 @@ extern void lex_end_table();
%type <statement> udp_initial udp_init_opt %type <statement> udp_initial udp_init_opt
%type <text> identifier lvalue register_variable %type <text> identifier lvalue register_variable
%type <strings> list_of_register_variables %type <strings> register_variable_list
%type <strings> list_of_variables %type <strings> list_of_variables
%type <wire> port %type <wire> port
@ -194,7 +194,10 @@ delay
} }
} }
| '#' IDENTIFIER | '#' IDENTIFIER
{ $$ = new PEIdent(*$2); { PEIdent*tmp = new PEIdent(*$2);
tmp->set_file(@2.text);
tmp->set_lineno(@2.first_line);
$$ = tmp;
delete $2; delete $2;
} }
; ;
@ -317,7 +320,10 @@ expr_primary
delete $1; delete $1;
} }
| identifier | identifier
{ $$ = new PEIdent(*$1); { PEIdent*tmp = new PEIdent(*$1);
tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line);
$$ = tmp;
delete $1; delete $1;
} }
| SYSTEM_IDENTIFIER | SYSTEM_IDENTIFIER
@ -326,12 +332,16 @@ expr_primary
} }
| identifier '[' expression ']' | identifier '[' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent(*$1);
tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line);
tmp->msb_ = $3; tmp->msb_ = $3;
delete $1; delete $1;
$$ = tmp; $$ = tmp;
} }
| identifier '[' expression ':' expression ']' | identifier '[' expression ':' expression ']'
{ PEIdent*tmp = new PEIdent(*$1); { PEIdent*tmp = new PEIdent(*$1);
tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line);
tmp->msb_ = $3; tmp->msb_ = $3;
tmp->lsb_ = $5; tmp->lsb_ = $5;
delete $1; delete $1;
@ -447,20 +457,6 @@ list_of_ports_opt
| { $$ = 0; } | { $$ = 0; }
; ;
list_of_register_variables
: register_variable
{ list<string>*tmp = new list<string>;
tmp->push_back(*$1);
delete $1;
$$ = tmp;
}
| list_of_register_variables ',' register_variable
{ list<string>*tmp = $1;
tmp->push_back(*$3);
delete $3;
$$ = tmp;
}
;
list_of_variables list_of_variables
: IDENTIFIER : IDENTIFIER
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
@ -508,14 +504,13 @@ module_item
} }
delete $3; delete $3;
} }
| K_reg range_opt list_of_register_variables ';' | K_reg range register_variable_list ';'
{ pform_makewire($3, NetNet::REG); { pform_set_net_range($3, $2);
if ($2) {
pform_set_net_range($3, $2);
delete $2; delete $2;
}
delete $3; delete $3;
} }
| K_reg register_variable_list ';'
{ delete $2; }
| K_parameter parameter_assign_list ';' | K_parameter parameter_assign_list ';'
| gatetype delay_opt gate_instance_list ';' | gatetype delay_opt gate_instance_list ';'
{ pform_makegates($1, $2, $3); { pform_makegates($1, $2, $3);
@ -629,13 +624,36 @@ range_opt
| { $$ = 0; } | { $$ = 0; }
; ;
/* The register_variable rule is matched only when I am parsing
variables in a "reg" definition. I therefore know that I am
creating registers and I do not need to let the containing rule
handle it. The register variable list simply packs them together
so that bit ranges can be assigned. */
register_variable register_variable
: IDENTIFIER : IDENTIFIER
{ $$ = $1; } { pform_makewire(*$1, NetNet::REG);
| IDENTIFIER '[' error ']'
{ yyerror(@1, "Sorry, register regions not implemented.");
$$ = $1; $$ = $1;
} }
| IDENTIFIER '[' const_expression ':' const_expression ']'
{ pform_makewire(*$1, NetNet::REG);
pform_set_reg_idx(*$1, $3, $5);
$$ = $1;
}
;
register_variable_list
: register_variable
{ list<string>*tmp = new list<string>;
tmp->push_back(*$1);
delete $1;
$$ = tmp;
}
| register_variable_list ',' register_variable
{ list<string>*tmp = $1;
tmp->push_back(*$3);
delete $3;
$$ = tmp;
}
; ;
statement statement

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: pform.cc,v 1.10 1999/02/21 17:01:57 steve Exp $" #ident "$Id: pform.cc,v 1.11 1999/04/19 01:59:37 steve Exp $"
#endif #endif
# include "pform.h" # include "pform.h"
@ -385,6 +385,20 @@ void pform_set_type_attrib(const string&name, const string&key,
(*udp).second ->attributes[key] = value; (*udp).second ->attributes[key] = value;
} }
void pform_set_reg_idx(const string&name, PExpr*l, PExpr*r)
{
PWire*cur = cur_module->get_wire(name);
if (cur == 0) {
VLerror("name is not a valid net.");
return;
}
assert(cur->lidx == 0);
assert(cur->ridx == 0);
cur->lidx = l;
cur->ridx = r;
}
static void pform_set_net_range(const string&name, list<PExpr*>*range) static void pform_set_net_range(const string&name, list<PExpr*>*range)
{ {
assert(range->size() == 2); assert(range->size() == 2);
@ -514,6 +528,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.11 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.10 1999/02/21 17:01:57 steve * Revision 1.10 1999/02/21 17:01:57 steve
* Add support for module parameters. * Add support for module parameters.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: pform.h,v 1.8 1999/02/21 17:01:57 steve Exp $" #ident "$Id: pform.h,v 1.9 1999/04/19 01:59:37 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -97,10 +97,11 @@ extern void pform_make_udp(string*name, list<string>*parms,
* The makewire functions announce to the pform code new wires. These * The makewire functions announce to the pform code new wires. These
* go into a module that is currently opened. * go into a module that is currently opened.
*/ */
extern void pform_makewire(const string&name, NetNet::Type type); extern void pform_makewire(const string&name, NetNet::Type type = NetNet::IMPLICIT);
extern void pform_makewire(const list<string>*names, NetNet::Type type); extern void pform_makewire(const list<string>*names, NetNet::Type type);
extern void pform_set_port_type(list<string>*names, NetNet::PortType); extern void pform_set_port_type(list<string>*names, NetNet::PortType);
extern void pform_set_net_range(list<string>*names, list<PExpr*>*); extern void pform_set_net_range(list<string>*names, list<PExpr*>*);
extern void pform_set_reg_idx(const string&name, PExpr*l, PExpr*r);
extern void pform_set_attrib(const string&name, const string&key, extern void pform_set_attrib(const string&name, const string&key,
const string&value); const string&value);
extern void pform_set_type_attrib(const string&name, const string&key, extern void pform_set_type_attrib(const string&name, const string&key,
@ -139,6 +140,9 @@ extern void pform_dump(ostream&out, Module*mod);
/* /*
* $Log: pform.h,v $ * $Log: pform.h,v $
* Revision 1.9 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.8 1999/02/21 17:01:57 steve * Revision 1.8 1999/02/21 17:01:57 steve
* Add support for module parameters. * Add support for module parameters.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: pform_dump.cc,v 1.11 1999/02/21 17:01:57 steve Exp $" #ident "$Id: pform_dump.cc,v 1.12 1999/04/19 01:59:37 steve Exp $"
#endif #endif
/* /*
@ -119,7 +119,17 @@ void PWire::dump(ostream&out) const
out << " [" << *msb << ":" << *lsb << "]"; out << " [" << *msb << ":" << *lsb << "]";
} }
out << " " << name << ";" << endl; out << " " << name;
// If the wire has indices, dump them.
if (lidx || ridx) {
out << "[";
if (lidx) out << *lidx;
if (ridx) out << ":" << *ridx;
out << "]";
}
out << ";" << endl;
for (map<string,string>::const_iterator idx = attributes.begin() for (map<string,string>::const_iterator idx = attributes.begin()
; idx != attributes.end() ; idx != attributes.end()
; idx ++) { ; idx ++) {
@ -414,6 +424,9 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $Log: pform_dump.cc,v $
* Revision 1.12 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.11 1999/02/21 17:01:57 steve * Revision 1.11 1999/02/21 17:01:57 steve
* Add support for module parameters. * Add support for module parameters.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.14 1999/03/15 02:43:32 steve Exp $" #ident "$Id: t-vvm.cc,v 1.15 1999/04/19 01:59:37 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
@ -41,6 +41,7 @@ class target_vvm : public target_t {
public: public:
virtual void start_design(ostream&os, const Design*); virtual void start_design(ostream&os, const Design*);
virtual void signal(ostream&os, const NetNet*); virtual void signal(ostream&os, const NetNet*);
virtual void memory(ostream&os, const NetMemory*);
virtual void logic(ostream&os, const NetLogic*); virtual void logic(ostream&os, const NetLogic*);
virtual void bufz(ostream&os, const NetBUFZ*); virtual void bufz(ostream&os, const NetBUFZ*);
virtual void udp(ostream&os, const NetUDP*); virtual void udp(ostream&os, const NetUDP*);
@ -332,6 +333,12 @@ void target_vvm::signal(ostream&os, const NetNet*sig)
} }
} }
void target_vvm::memory(ostream&os, const NetMemory*mem)
{
os << "static vvm_bitset_t<" << mem->width() << "> " <<
mangle(mem->name()) << "[" << "];" << endl;
}
/* /*
* This method handles writing output functions for gates that have a * This method handles writing output functions for gates that have a
* single output (at pin 0). This writes the output_fun method into * single output (at pin 0). This writes the output_fun method into
@ -883,6 +890,9 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $Log: t-vvm.cc,v $
* Revision 1.15 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.14 1999/03/15 02:43:32 steve * Revision 1.14 1999/03/15 02:43:32 steve
* Support more operators, especially logical. * Support more operators, especially logical.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: target.cc,v 1.5 1999/02/08 02:49:56 steve Exp $" #ident "$Id: target.cc,v 1.6 1999/04/19 01:59:37 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
@ -35,6 +35,12 @@ void target_t::signal(ostream&os, const NetNet*)
{ {
} }
void target_t::memory(ostream&os, const NetMemory*)
{
cerr << "target (" << typeid(*this).name() << "): "
"Unhandled memory." << endl;
}
void target_t::logic(ostream&os, const NetLogic*) void target_t::logic(ostream&os, const NetLogic*)
{ {
} }
@ -146,6 +152,12 @@ void expr_scan_t::expr_ident(const NetEIdent*)
"unhandled expr_ident." << endl; "unhandled expr_ident." << endl;
} }
void expr_scan_t::expr_memory(const NetEMemory*)
{
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
"unhandled expr_memory." << endl;
}
void expr_scan_t::expr_signal(const NetESignal*) void expr_scan_t::expr_signal(const NetESignal*)
{ {
cerr << "expr_scan_t (" << typeid(*this).name() << "): " cerr << "expr_scan_t (" << typeid(*this).name() << "): "
@ -166,6 +178,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/* /*
* $Log: target.cc,v $ * $Log: target.cc,v $
* Revision 1.6 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.5 1999/02/08 02:49:56 steve * Revision 1.5 1999/02/08 02:49:56 steve
* Turn the NetESignal into a NetNode so * Turn the NetESignal into a NetNode so
* that it can connect to the netlist. * that it can connect to the netlist.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: target.h,v 1.5 1999/02/08 02:49:56 steve Exp $" #ident "$Id: target.h,v 1.6 1999/04/19 01:59:37 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -58,6 +58,9 @@ struct target_t {
/* Output a signal (called for each signal) */ /* Output a signal (called for each signal) */
virtual void signal(ostream&os, const NetNet*); virtual void signal(ostream&os, const NetNet*);
/* Output a memory (called for each memory object) */
virtual void memory(ostream&os, const NetMemory*);
/* Output a gate (called for each gate) */ /* Output a gate (called for each gate) */
virtual void logic(ostream&os, const NetLogic*); virtual void logic(ostream&os, const NetLogic*);
virtual void bufz(ostream&os, const NetBUFZ*); virtual void bufz(ostream&os, const NetBUFZ*);
@ -94,6 +97,7 @@ struct expr_scan_t {
virtual ~expr_scan_t(); virtual ~expr_scan_t();
virtual void expr_const(const NetEConst*); virtual void expr_const(const NetEConst*);
virtual void expr_ident(const NetEIdent*); virtual void expr_ident(const NetEIdent*);
virtual void expr_memory(const NetEMemory*);
virtual void expr_signal(const NetESignal*); virtual void expr_signal(const NetESignal*);
virtual void expr_unary(const NetEUnary*); virtual void expr_unary(const NetEUnary*);
virtual void expr_binary(const NetEBinary*); virtual void expr_binary(const NetEBinary*);
@ -116,6 +120,9 @@ extern const struct target *target_table[];
/* /*
* $Log: target.h,v $ * $Log: target.h,v $
* Revision 1.6 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.5 1999/02/08 02:49:56 steve * Revision 1.5 1999/02/08 02:49:56 steve
* Turn the NetESignal into a NetNode so * Turn the NetESignal into a NetNode so
* that it can connect to the netlist. * that it can connect to the netlist.