Core handles subsignal expressions.

This commit is contained in:
steve 1999-04-25 00:44:10 +00:00
parent 32b52cbb97
commit 09cfbc6240
7 changed files with 125 additions and 36 deletions

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.17 1999/04/19 01:59:36 steve Exp $" #ident "$Id: design_dump.cc,v 1.18 1999/04/25 00:44:10 steve Exp $"
#endif #endif
/* /*
@ -469,6 +469,14 @@ void NetESignal::dump(ostream&o) const
o << name(); o << name();
} }
void NetESubSignal::dump(ostream&o) const
{
sig_->dump(o);
o << "[";
idx_->dump(o);
o << "]";
}
void NetEMemory::dump(ostream&o) const void NetEMemory::dump(ostream&o) const
{ {
o << mem_->name() << "["; o << mem_->name() << "[";
@ -543,6 +551,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.18 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.17 1999/04/19 01:59:36 steve * Revision 1.17 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

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.19 1999/04/19 01:59:36 steve Exp $" #ident "$Id: elaborate.cc,v 1.20 1999/04/25 00:44:10 steve Exp $"
#endif #endif
/* /*
@ -680,41 +680,56 @@ NetExpr* PEString::elaborate_expr(Design*des, const string&path) const
NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const
{ {
if (text_[0] == '$') { // System identifiers show up in the netlist as identifiers.
if (text_[0] == '$')
return new NetEIdent(text_, 64); return new NetEIdent(text_, 64);
} else { string name = path+"."+text_;
string name = path+"."+text_;
if (NetExpr*ex = des->get_parameter(name)) // If the identifier name a paramter name, then return
return ex; // the expression that it represents.
if (NetExpr*ex = des->get_parameter(name))
return ex;
if (NetNet*net = des->find_signal(name)) { // If the identifier names a signal (a register or wire)
NetESignal*node = des->get_esignal(net); // then create a NetESignal node to handle it.
return node; if (NetNet*net = des->find_signal(name)) {
NetESignal*node = des->get_esignal(net);
assert(idx_ == 0);
assert(lsb_ == 0);
if (msb_) {
NetExpr*ex = msb_->elaborate_expr(des, path);
NetESubSignal*ss = new NetESubSignal(node, ex);
return ss;
} }
assert(msb_ == 0);
if (NetMemory*mem = des->find_memory(name)) { return node;
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;
} }
// If the identifier names a memory, then this is a
// memory reference and I must generate a NetEMemory
// object to handle it.
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;
}
// I cannot interpret this identifier. Error message.
cerr << get_line() << ": Unable to bind wire/reg/memory "
"`" << path << "." << text_ << "'" << endl;
des->errors += 1;
return 0;
} }
NetExpr* PExpr::elaborate_expr(Design*des, const string&path) const NetExpr* PExpr::elaborate_expr(Design*des, const string&path) const
@ -1028,6 +1043,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.20 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.19 1999/04/19 01:59:36 steve * Revision 1.19 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

10
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.7 1999/04/19 01:59:36 steve Exp $" #ident "$Id: emit.cc,v 1.8 1999/04/25 00:44:10 steve Exp $"
#endif #endif
/* /*
@ -229,6 +229,11 @@ void NetESignal::emit_node(ostream&o, struct target_t*tgt) const
tgt->net_esignal(o, this); tgt->net_esignal(o, this);
} }
void NetESubSignal::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_subsignal(this);
}
void NetEUnary::expr_scan(struct expr_scan_t*tgt) const void NetEUnary::expr_scan(struct expr_scan_t*tgt) const
{ {
tgt->expr_unary(this); tgt->expr_unary(this);
@ -248,6 +253,9 @@ void emit(ostream&o, const Design*des, const char*type)
/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.8 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.7 1999/04/19 01:59:36 steve * Revision 1.7 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

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.20 1999/04/19 01:59:36 steve Exp $" #ident "$Id: netlist.cc,v 1.21 1999/04/25 00:44:10 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -536,6 +536,16 @@ void NetESignal::set_width(unsigned w)
expr_width(w); expr_width(w);
} }
NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex)
: sig_(sig), idx_(ex)
{
}
NetESubSignal::~NetESubSignal()
{
idx_.clr_and_delete();
}
NetEUnary::~NetEUnary() NetEUnary::~NetEUnary()
{ {
expr_.clr_and_delete(); expr_.clr_and_delete();
@ -1016,6 +1026,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.21 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.20 1999/04/19 01:59:36 steve * Revision 1.20 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

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.24 1999/04/22 04:56:58 steve Exp $" #ident "$Id: netlist.h,v 1.25 1999/04/25 00:44:10 steve Exp $"
#endif #endif
/* /*
@ -972,6 +972,29 @@ class NetESignal : public NetExpr, public NetNode {
private: private:
}; };
/*
* An expression that takes a portion of a signal is represented as
* one of these. For example, ``foo[x+5]'' is a signal and x+5 is an
* expression to select a single bit from that signal. I can't just
* make a new NetESignal node connected to the single net because the
* expression may vary during execution, so the structure is not known
* at compile (elaboration) time.
*/
class NetESubSignal : public NetExpr {
public:
NetESubSignal(NetESignal*sig, NetExpr*ex);
~NetESubSignal();
virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const;
private:
// For now, only support single-bit selects of a signal.
NetESignal*sig_;
NetExpr::REF idx_;
};
/* /*
* This class contains an entire design. It includes processes and a * This class contains an entire design. It includes processes and a
* netlist, and can be passed around from function to function. * netlist, and can be passed around from function to function.
@ -1103,6 +1126,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.25 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.24 1999/04/22 04:56:58 steve * Revision 1.24 1999/04/22 04:56:58 steve
* Add to vvm proceedural memory references. * Add to vvm proceedural memory references.
* *

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.6 1999/04/19 01:59:37 steve Exp $" #ident "$Id: target.cc,v 1.7 1999/04/25 00:44:10 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
@ -164,6 +164,12 @@ void expr_scan_t::expr_signal(const NetESignal*)
"unhandled expr_signal." << endl; "unhandled expr_signal." << endl;
} }
void expr_scan_t::expr_subsignal(const NetESubSignal*)
{
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
"unhandled expr_subsignal." << endl;
}
void expr_scan_t::expr_unary(const NetEUnary*) void expr_scan_t::expr_unary(const NetEUnary*)
{ {
cerr << "expr_scan_t (" << typeid(*this).name() << "): " cerr << "expr_scan_t (" << typeid(*this).name() << "): "
@ -178,6 +184,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/* /*
* $Log: target.cc,v $ * $Log: target.cc,v $
* Revision 1.7 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.6 1999/04/19 01:59:37 steve * Revision 1.6 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *

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.6 1999/04/19 01:59:37 steve Exp $" #ident "$Id: target.h,v 1.7 1999/04/25 00:44:10 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -99,6 +99,7 @@ struct expr_scan_t {
virtual void expr_ident(const NetEIdent*); virtual void expr_ident(const NetEIdent*);
virtual void expr_memory(const NetEMemory*); virtual void expr_memory(const NetEMemory*);
virtual void expr_signal(const NetESignal*); virtual void expr_signal(const NetESignal*);
virtual void expr_subsignal(const NetESubSignal*);
virtual void expr_unary(const NetEUnary*); virtual void expr_unary(const NetEUnary*);
virtual void expr_binary(const NetEBinary*); virtual void expr_binary(const NetEBinary*);
}; };
@ -120,6 +121,9 @@ extern const struct target *target_table[];
/* /*
* $Log: target.h,v $ * $Log: target.h,v $
* Revision 1.7 1999/04/25 00:44:10 steve
* Core handles subsignal expressions.
*
* Revision 1.6 1999/04/19 01:59:37 steve * Revision 1.6 1999/04/19 01:59:37 steve
* Add memories to the parse and elaboration phases. * Add memories to the parse and elaboration phases.
* *