Remove the NetEBitSel and combine all bit/part select

behavior into the NetESelect node and IVL_EX_SELECT
 ivl_target expression type.
This commit is contained in:
steve 2005-01-24 05:28:30 +00:00
parent edeb9d8eca
commit dfb7c7ba6f
17 changed files with 218 additions and 308 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: design_dump.cc,v 1.153 2005/01/22 18:16:00 steve Exp $"
#ident "$Id: design_dump.cc,v 1.154 2005/01/24 05:28:30 steve Exp $"
#endif
# include "config.h"
@ -1011,14 +1011,6 @@ void NetESignal::dump(ostream&o) const
o << name() << "[" << msi()<<":"<<lsi() << "]";
}
void NetEBitSel::dump(ostream&o) const
{
sig_->dump(o);
o << "[";
idx_->dump(o);
o << "]";
}
void NetEMemory::dump(ostream&o) const
{
o << mem_->name() << "[";
@ -1102,6 +1094,11 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
* Revision 1.154 2005/01/24 05:28:30 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.153 2005/01/22 18:16:00 steve
* Remove obsolete NetSubnet class.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_expr.cc,v 1.92 2004/12/11 02:31:25 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.93 2005/01/24 05:28:30 steve Exp $"
#endif
# include "config.h"
@ -668,7 +668,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
long lsv = lsn->as_long();
long msv = msn->as_long();
unsigned long wid = 1 + ((msv>lsv)? (msv-lsv) : (lsv-msv));
if (wid > net->pin_count()) {
if (wid > net->vector_width()) {
cerr << get_line() << ": error: part select ["
<< msv << ":" << lsv << "] out of range."
<< endl;
@ -677,7 +677,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
delete msn;
return 0;
}
assert(wid <= net->pin_count());
assert(wid <= net->vector_width());
if (net->sb_to_idx(msv) < net->sb_to_idx(lsv)) {
cerr << get_line() << ": error: part select ["
@ -690,7 +690,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
}
if (net->sb_to_idx(msv) >= net->pin_count()) {
if (net->sb_to_idx(msv) >= net->vector_width()) {
cerr << get_line() << ": error: part select ["
<< msv << ":" << lsv << "] out of range."
<< endl;
@ -699,18 +699,21 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
delete msn;
return 0;
}
#if 0
NetESignal*tmp = new NetESignal(net,
net->sb_to_idx(msv),
net->sb_to_idx(lsv));
#else
NetESignal*tmp = new NetESignal(net);
cerr << get_line() << ": internal error: I forgot "
"how to elaborate part selects." << endl;
#endif
tmp->set_line(*this);
return tmp;
// If the part select convers exactly the entire
// vector, then do not bother with it. Return the
// signal itself.
if (net->sb_to_idx(lsv) == 0 && wid == net->vector_width())
return tmp;
NetExpr*ex = new NetEConst(verinum(net->sb_to_idx(lsv)));
NetESelect*ss = new NetESelect(tmp, ex, wid);
ss->set_line(*this);
return ss;
}
// If the bit select is constant, then treat it similar
@ -722,7 +725,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
long msv = msn->as_long();
unsigned idx = net->sb_to_idx(msv);
if (idx >= net->pin_count()) {
if (idx >= net->vector_width()) {
/* The bit select is out of range of the
vector. This is legal, but returns a
constant 1'bx value. */
@ -740,26 +743,42 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
return tmp;
}
#if 0
NetESignal*tmp = new NetESignal(net, idx, idx);
#else
NetESignal*tmp = new NetESignal(net);
cerr << get_line() << ": internal error: I forgot "
"how to elaborate constant bit selects." << endl;
#endif
tmp->set_line(*this);
// If the vector is only one bit, we are done. The
// bit select will return the scaler itself.
if (net->vector_width() == 1)
return tmp;
return tmp;
// Make an expression out of the index
NetEConst*idx_c = new NetEConst(verinum(idx));
idx_c->set_line(*net);
// Make a bit select with the canonical index
NetESelect*res = new NetESelect(tmp, idx_c, 1);
res->set_line(*net);
return res;
}
NetESignal*node = new NetESignal(net);
assert(idx_ == 0);
// Non-constant bit select? punt and make a subsignal
// device to mux the bit in the net.
// device to mux the bit in the net. This is a fairly
// compilcated task because we need to generate
// expressions to convert calculated bit select
// values to canonical values that are used internally.
if (msb_) {
NetExpr*ex = msb_->elaborate_expr(des, scope);
NetEBitSel*ss = new NetEBitSel(node, ex);
if (net->msb() < net->lsb()) {
ex = make_sub_expr(net->lsb(), ex);
} else {
ex = make_add_expr(ex, - net->lsb());
}
NetESelect*ss = new NetESelect(node, ex, 1);
ss->set_line(*this);
return ss;
}
@ -1016,6 +1035,11 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
/*
* $Log: elab_expr.cc,v $
* Revision 1.93 2005/01/24 05:28:30 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.92 2004/12/11 02:31:25 steve
* Rework of internals to carry vectors through nexus instead
* of single bits. Make the ivl, tgt-vvp and vvp initial changes

12
emit.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: emit.cc,v 1.80 2005/01/22 01:06:55 steve Exp $"
#ident "$Id: emit.cc,v 1.81 2005/01/24 05:28:30 steve Exp $"
#endif
# include "config.h"
@ -480,11 +480,6 @@ void NetESignal::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_signal(this);
}
void NetEBitSel::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_subsignal(this);
}
void NetETernary::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_ternary(this);
@ -517,6 +512,11 @@ int emit(const Design*des, const char*type)
/*
* $Log: emit.cc,v $
* Revision 1.81 2005/01/24 05:28:30 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.80 2005/01/22 01:06:55 steve
* Change case compare from logic to an LPM node.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: ivl_target.h,v 1.133 2005/01/22 17:36:59 steve Exp $"
#ident "$Id: ivl_target.h,v 1.134 2005/01/24 05:28:30 steve Exp $"
#endif
#ifdef __cplusplus
@ -176,7 +176,7 @@ typedef enum ivl_drive_e {
and incompatibilities to be introduced. */
typedef enum ivl_expr_type_e {
IVL_EX_NONE = 0,
IVL_EX_BITSEL = 1,
/* IVL_EX_BITSEL = 1, */
IVL_EX_BINARY = 2,
IVL_EX_CONCAT = 3,
IVL_EX_EVENT = 17,
@ -512,6 +512,16 @@ extern ivl_nexus_t ivl_event_pos(ivl_event_t net, unsigned idx);
* & -- AND
* A -- NAND (~&)
* X -- XNOR (~^)
*
* SEMANTIC NOTES
*
* - IVL_EX_SELECT
* This expression takes two operands, oper1 is the expression to
* select from, and oper2 is the selection base. The ivl_expr_width
* value is the width of the bit/part select. The ivl_expr_oper1 value
* is the base of a vector. The compiler has already figured out any
* conversion from signal units to vector units, so the result of
* ivl_expr_oper1 should range from 0 to ivl_expr_width().
*/
extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net);
@ -523,13 +533,11 @@ extern const char* ivl_expr_bits(ivl_expr_t net);
extern ivl_scope_t ivl_expr_def(ivl_expr_t net);
/* IVL_EX_REALNUM */
extern double ivl_expr_dvalue(ivl_expr_t net);
/* IVL_EX_SIGNAL */
extern unsigned ivl_expr_lsi(ivl_expr_t net);
/* IVL_EX_SIGNAL, IVL_EX_SFUNC, IVL_EX_VARIABLE */
extern const char* ivl_expr_name(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY */
extern char ivl_expr_opcode(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_BITSEL IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */
/* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net);
@ -547,7 +555,7 @@ extern unsigned ivl_expr_repeat(ivl_expr_t net);
extern ivl_event_t ivl_expr_event(ivl_expr_t net);
/* IVL_EX_SCOPE */
extern ivl_scope_t ivl_expr_scope(ivl_expr_t net);
/* IVL_EX_BITSEL */
/* IVL_EX_SIGNAL */
extern ivl_signal_t ivl_expr_signal(ivl_expr_t net);
/* any expression */
extern int ivl_expr_signed(ivl_expr_t net);
@ -1436,6 +1444,11 @@ _END_DECL
/*
* $Log: ivl_target.h,v $
* Revision 1.134 2005/01/24 05:28:30 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.133 2005/01/22 17:36:59 steve
* stub dump signed flags of magnitude compare.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: net_nex_input.cc,v 1.12 2004/09/04 04:24:15 steve Exp $"
#ident "$Id: net_nex_input.cc,v 1.13 2005/01/24 05:28:30 steve Exp $"
#endif
# include "config.h"
@ -54,15 +54,6 @@ NexusSet* NetEBinary::nex_input()
return result;
}
NexusSet* NetEBitSel::nex_input()
{
NexusSet*result = sig_->nex_input();
NexusSet*tmp = idx_->nex_input();
result->add(*tmp);
delete tmp;
return result;
}
NexusSet* NetEConcat::nex_input()
{
NexusSet*result = parms_[0]->nex_input();
@ -398,6 +389,11 @@ NexusSet* NetWhile::nex_input()
/*
* $Log: net_nex_input.cc,v $
* Revision 1.13 2005/01/24 05:28:30 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.12 2004/09/04 04:24:15 steve
* PR1026: assignment statements can have sensitivities in the l-values.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.cc,v 1.232 2005/01/22 18:16:01 steve Exp $"
#ident "$Id: netlist.cc,v 1.233 2005/01/24 05:28:30 steve Exp $"
#endif
# include "config.h"
@ -2171,35 +2171,6 @@ unsigned NetESignal::msi() const
return net_->msb();
}
NetEBitSel::NetEBitSel(NetESignal*sig, NetExpr*ex)
: sig_(sig), idx_(ex)
{
// This supports mux type indexing of an expression, so the
// with is by definition 1 bit.
expr_width(1);
}
NetEBitSel::~NetEBitSel()
{
delete idx_;
}
perm_string NetEBitSel::name() const
{
return sig_->name();
}
const NetNet* NetEBitSel::sig() const
{
return sig_->sig();
}
NetEBitSel* NetEBitSel::dup_expr() const
{
assert(0);
return 0;
}
NetETernary::NetETernary(NetExpr*c, NetExpr*t, NetExpr*f)
: cond_(c), true_val_(t), false_val_(f)
{
@ -2336,6 +2307,11 @@ const NetProc*NetTaskDef::proc() const
/*
* $Log: netlist.cc,v $
* Revision 1.233 2005/01/24 05:28:30 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.232 2005/01/22 18:16:01 steve
* Remove obsolete NetSubnet class.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.h,v 1.328 2005/01/22 18:16:01 steve Exp $"
#ident "$Id: netlist.h,v 1.329 2005/01/24 05:28:31 steve Exp $"
#endif
/*
@ -2755,7 +2755,10 @@ class NetEParam : public NetExpr {
* expressions. The sub-expression is self-sized, and has bits
* selected from it. The base is the expression that identifies the
* lsb of the expression, and the wid is the width of the part select,
* or 1 for a bit select.
* or 1 for a bit select. No matter what the subexpression is, the
* base is translated in cannonical bits. It is up to the elaborator
* to figure this out and adjust the expression if the subexpression
* has a non-cannonical base or direction.
*
* If the base expression is null, then this expression node can be
* used to express width expansion, signed or unsigned depending on
@ -3031,39 +3034,6 @@ class NetESignal : public NetExpr {
NetNet*net_;
};
/*
* An expression that takes a bit 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 NetEBitSel : public NetExpr {
public:
NetEBitSel(NetESignal*sig, NetExpr*ex);
~NetEBitSel();
perm_string name() const;
const NetExpr*index() const { return idx_; }
virtual bool set_width(unsigned);
const NetNet* sig() const;
NetEBitSel* dup_expr() const;
virtual NexusSet* nex_input();
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* idx_;
};
/*
* This object type is used to contain a logical scope within a
@ -3406,6 +3376,11 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.329 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.328 2005/01/22 18:16:01 steve
* Remove obsolete NetSubnet class.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netmisc.cc,v 1.9 2004/12/11 02:31:27 steve Exp $"
#ident "$Id: netmisc.cc,v 1.10 2005/01/24 05:28:31 steve Exp $"
#endif
# include "config.h"
@ -76,6 +76,47 @@ NetNet* add_to_net(Design*des, NetNet*sig, long val)
#endif
}
/*
* Add a signed constant to an existing expression. Generate a new
* NetEBAdd node that has the input expression and an expression made
* from the constant value.
*/
NetExpr* make_add_expr(NetExpr*expr, long val)
{
if (val == 0)
return expr;
// If the value to be added is <0, then instead generate a
// SUBTRACT node and turn the value positive.
char add_op = '+';
if (val < 0) {
add_op = '-';
val = -val;
}
verinum val_v (val, expr->expr_width());
val_v.has_sign(true);
NetEConst*val_c = new NetEConst(val_v);
val_c->set_line(*expr);
NetEBAdd*res = new NetEBAdd(add_op, expr, val_c);
res->set_line(*expr);
return res;
}
NetExpr* make_sub_expr(long val, NetExpr*expr)
{
verinum val_v (val, expr->expr_width());
val_v.has_sign(true);
NetEConst*val_c = new NetEConst(val_v);
val_c->set_line(*expr);
NetEBAdd*res = new NetEBAdd('-', val_c, expr);
res->set_line(*expr);
return res;
}
NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe)
{
@ -94,6 +135,11 @@ NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe)
/*
* $Log: netmisc.cc,v $
* Revision 1.10 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.9 2004/12/11 02:31:27 steve
* Rework of internals to carry vectors through nexus instead
* of single bits. Make the ivl, tgt-vvp and vvp initial changes

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netmisc.h,v 1.19 2004/03/07 20:04:11 steve Exp $"
#ident "$Id: netmisc.h,v 1.20 2005/01/24 05:28:31 steve Exp $"
#endif
# include "netlist.h"
@ -57,6 +57,23 @@ extern NetNet*pad_to_width(Design*des, NetNet*n, unsigned w);
*/
extern NetNet*add_to_net(Design*des, NetNet*sig, long val);
/*
* These functions make various sorts of expressions, given operands
* of certain type. The order of the operands is preserved in cases
* where order matters.
*
* make_add_expr
* Make a NetEBAdd expresion with <expr> the first argument and
* <val> the second. This may get turned into a subtract if <val> is
* less then zero. If val is exactly zero, then return <expr> as is.
*
* make_sub_expr
* Make a NetEBAdd(subtract) node that subtracts the given
* expression from the integer value.
*/
extern NetExpr*make_add_expr(NetExpr*expr, long val);
extern NetExpr*make_sub_expr(long val, NetExpr*expr);
/*
* In some cases the lval is accessible as a pointer to the head of
* a list of NetAssign_ objects. This function returns the width of
@ -75,6 +92,11 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe);
/*
* $Log: netmisc.h,v $
* Revision 1.20 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.19 2004/03/07 20:04:11 steve
* MOre thorough use of elab_and_eval function.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: set_width.cc,v 1.34 2003/08/28 04:11:19 steve Exp $"
#ident "$Id: set_width.cc,v 1.35 2005/01/24 05:28:31 steve Exp $"
#endif
# include "config.h"
@ -354,12 +354,6 @@ bool NetESignal::set_width(unsigned w)
return true;
}
bool NetEBitSel::set_width(unsigned w)
{
if (w != 1) return false;
return true;
}
bool NetETernary::set_width(unsigned w)
{
bool flag = true;
@ -411,6 +405,11 @@ bool NetEUReduce::set_width(unsigned w)
/*
* $Log: set_width.cc,v $
* Revision 1.35 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.34 2003/08/28 04:11:19 steve
* Spelling patch.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: t-dll-api.cc,v 1.114 2005/01/22 01:06:55 steve Exp $"
#ident "$Id: t-dll-api.cc,v 1.115 2005/01/24 05:28:31 steve Exp $"
#endif
# include "config.h"
@ -248,20 +248,6 @@ extern "C" double ivl_expr_dvalue(ivl_expr_t net)
return net->u_.real_.value;
}
extern "C" unsigned ivl_expr_lsi(ivl_expr_t net)
{
switch (net->type_) {
case IVL_EX_SIGNAL:
return net->u_.signal_.lsi;
default:
assert(0);
}
return 0;
}
extern "C" const char* ivl_expr_name(ivl_expr_t net)
{
switch (net->type_) {
@ -305,9 +291,6 @@ extern "C" ivl_expr_t ivl_expr_oper1(ivl_expr_t net)
case IVL_EX_SELECT:
return net->u_.binary_.lef_;
case IVL_EX_BITSEL:
return net->u_.bitsel_.bit;
case IVL_EX_UNARY:
return net->u_.unary_.sub_;
@ -438,8 +421,6 @@ extern "C" ivl_signal_t ivl_expr_signal(ivl_expr_t net)
{
assert(net);
switch (net->type_) {
case IVL_EX_BITSEL:
return net->u_.bitsel_.sig;
case IVL_EX_SIGNAL:
return net->u_.signal_.sig;
@ -1972,6 +1953,11 @@ extern "C" ivl_variable_type_t ivl_variable_type(ivl_variable_t net)
/*
* $Log: t-dll-api.cc,v $
* Revision 1.115 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.114 2005/01/22 01:06:55 steve
* Change case compare from logic to an LPM node.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: t-dll-expr.cc,v 1.39 2004/06/17 16:06:19 steve Exp $"
#ident "$Id: t-dll-expr.cc,v 1.40 2005/01/24 05:28:31 steve Exp $"
#endif
# include "config.h"
@ -442,105 +442,8 @@ void dll_target::expr_signal(const NetESignal*net)
expr_->width_= net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0;
expr_->u_.signal_.sig = find_signal(des_, net->sig());
expr_->u_.signal_.lsi = net->lsi();
expr_->u_.signal_.msi = net->msi();
}
void dll_target::expr_subsignal(const NetEBitSel*net)
{
assert(expr_ == 0);
ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
assert(expr);
expr->type_ = IVL_EX_BITSEL;
expr->value_= IVL_VT_VECTOR;
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
expr->u_.bitsel_.sig = find_signal(des_, net->sig());
assert(expr->u_.bitsel_.sig->lsb_index == net->sig()->lsb());
net->index()->expr_scan(this);
assert(expr_);
expr->u_.bitsel_.bit = expr_;
/* If the lsb of the signal is not 0, then we are about to
lose the proper offset to the normalized vector. Modify the
expression to subtract the offset:
reg [7:4] a;
... = a[x];
becomes
reg [3:0] a;
... = a[x-4];
to reflect the normalizing of vectors that is done by the
compiler. */
if (expr->u_.bitsel_.sig->lsb_index != 0) {
/* Create in tmpc the constant offset (4 in the above
example) to be subtracted from the index. */
char*bits;
long lsb = expr->u_.bitsel_.sig->lsb_index;
ivl_expr_t tmpc = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
tmpc->type_ = IVL_EX_NUMBER;
tmpc->width_ = expr->u_.bitsel_.bit->width_;
tmpc->signed_ = net->index()->has_sign()? 1 : 0;
tmpc->u_.number_.bits_ = bits = (char*)malloc(tmpc->width_);
for (unsigned idx = 0 ; idx < tmpc->width_ ; idx += 1) {
bits[idx] = (lsb & 1)? '1' : '0';
lsb >>= 1;
}
/* Now make the subtractor (x-4 in the above example)
that has as input A the index expression and input B
the constant to subtract. */
ivl_expr_t tmps = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
tmps->type_ = IVL_EX_BINARY;
tmps->width_ = tmpc->width_;
tmps->signed_ = net->index()->has_sign()? 1 : 0;
tmps->u_.binary_.op_ = '-';
tmps->u_.binary_.lef_ = expr->u_.bitsel_.bit;
tmps->u_.binary_.rig_ = tmpc;
/* Replace (x) with (x-4) */
expr->u_.bitsel_.bit = tmps;
/* If the index item distance (the distance to the next
most significant bit) is not 1, then multiply the
previous result to convert the index. */
if (expr->u_.bitsel_.sig->lsb_dist != 1) {
long dist = expr->u_.bitsel_.sig->lsb_dist;
tmpc = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
tmpc->type_ = IVL_EX_NUMBER;
tmpc->width_ = expr->u_.bitsel_.bit->width_;
tmpc->signed_ = 1;
tmpc->u_.number_.bits_ = bits = (char*)malloc(tmpc->width_);
for (unsigned idx = 0 ; idx < tmpc->width_ ; idx += 1) {
bits[idx] = (dist & 1)? '1' : '0';
dist >>= 1;
}
tmps = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
tmps->type_ = IVL_EX_BINARY;
tmps->width_ = tmpc->width_;
tmps->signed_ = 1;
tmps->u_.binary_.op_ = '*';
tmps->u_.binary_.lef_ = expr->u_.bitsel_.bit;
tmps->u_.binary_.rig_ = tmpc;
expr->u_.bitsel_.bit = tmps;
}
}
expr_ = expr;
}
void dll_target::expr_ufunc(const NetEUFunc*net)
{
@ -604,6 +507,11 @@ void dll_target::expr_variable(const NetEVariable*net)
/*
* $Log: t-dll-expr.cc,v $
* Revision 1.40 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.39 2004/06/17 16:06:19 steve
* Help system function signedness survive elaboration.
*

14
t-dll.h
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: t-dll.h,v 1.117 2004/12/29 23:55:43 steve Exp $"
#ident "$Id: t-dll.h,v 1.118 2005/01/24 05:28:31 steve Exp $"
#endif
# include "target.h"
@ -137,7 +137,6 @@ struct dll_target : public target_t, public expr_scan_t {
void expr_scope(const NetEScope*);
void expr_select(const NetESelect*);
void expr_sfunc(const NetESFunc*);
void expr_subsignal(const NetEBitSel*);
void expr_ternary(const NetETernary*);
void expr_ufunc(const NetEUFunc*);
void expr_unary(const NetEUnary*);
@ -202,11 +201,6 @@ struct ivl_expr_s {
ivl_expr_t rig_;
} binary_;
struct {
ivl_signal_t sig;
ivl_expr_t bit;
} bitsel_;
struct {
unsigned rept;
unsigned parms;
@ -228,7 +222,6 @@ struct ivl_expr_s {
struct {
ivl_signal_t sig;
unsigned lsi, msi;
} signal_;
struct {
@ -687,6 +680,11 @@ struct ivl_variable_s {
/*
* $Log: t-dll.h,v $
* Revision 1.118 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.117 2004/12/29 23:55:43 steve
* Unify elaboration of l-values for all proceedural assignments,
* including assing, cassign and force.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: target.cc,v 1.71 2004/12/29 23:55:43 steve Exp $"
#ident "$Id: target.cc,v 1.72 2005/01/24 05:28:31 steve Exp $"
#endif
# include "config.h"
@ -381,12 +381,6 @@ void expr_scan_t::expr_signal(const NetESignal*)
"unhandled expr_signal." << endl;
}
void expr_scan_t::expr_subsignal(const NetEBitSel*)
{
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
"unhandled bit select expression." << endl;
}
void expr_scan_t::expr_ternary(const NetETernary*)
{
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
@ -419,6 +413,11 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/*
* $Log: target.cc,v $
* Revision 1.72 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.71 2004/12/29 23:55:43 steve
* Unify elaboration of l-values for all proceedural assignments,
* including assing, cassign and force.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: target.h,v 1.68 2005/01/22 01:06:55 steve Exp $"
#ident "$Id: target.h,v 1.69 2005/01/24 05:28:31 steve Exp $"
#endif
# include "netlist.h"
@ -142,7 +142,6 @@ struct expr_scan_t {
virtual void expr_select(const NetESelect*);
virtual void expr_sfunc(const NetESFunc*);
virtual void expr_signal(const NetESignal*);
virtual void expr_subsignal(const NetEBitSel*);
virtual void expr_ternary(const NetETernary*);
virtual void expr_ufunc(const NetEUFunc*);
virtual void expr_unary(const NetEUnary*);
@ -171,6 +170,11 @@ extern const struct target *target_table[];
/*
* $Log: target.h,v $
* Revision 1.69 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.68 2005/01/22 01:06:55 steve
* Change case compare from logic to an LPM node.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: stub.c,v 1.100 2005/01/24 05:05:25 steve Exp $"
#ident "$Id: stub.c,v 1.101 2005/01/24 05:28:31 steve Exp $"
#endif
# include "config.h"
@ -103,12 +103,6 @@ void show_expression(ivl_expr_t net, unsigned ind)
switch (code) {
case IVL_EX_BITSEL:
fprintf(out, "%*s<%s[] width=%u, %s>\n", ind, "",
ivl_signal_name(ivl_expr_signal(net)), width, sign);
show_expression(ivl_expr_oper1(net), ind+3);
break;
case IVL_EX_BINARY:
fprintf(out, "%*s<\"%c\" width=%u, %s, type=%s>\n", ind, "",
ivl_expr_opcode(net), width, sign, vt);
@ -943,6 +937,11 @@ int target_design(ivl_design_t des)
/*
* $Log: stub.c,v $
* Revision 1.101 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.100 2005/01/24 05:05:25 steve
* Check widths of ternary expressions.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: eval_expr.c,v 1.112 2005/01/24 05:08:02 steve Exp $"
#ident "$Id: eval_expr.c,v 1.113 2005/01/24 05:28:31 steve Exp $"
#endif
# include "vvp_priv.h"
@ -1125,39 +1125,6 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp,
return rv;
}
static struct vector_info draw_bitsel_expr(ivl_expr_t exp, unsigned wid)
{
struct vector_info res;
ivl_signal_t sig = ivl_expr_signal(exp);
ivl_expr_t sel = ivl_expr_oper1(exp);
/* Evaluate the bit select expression and save the result into
index register 0. */
res = draw_eval_expr(sel, 0);
fprintf(vvp_out, " %%ix/get 0, %u,%u;\n", res.base, res.wid);
clr_vector(res);
res.base = allocate_vector(wid);
res.wid = wid;
switch (ivl_signal_type(sig)) {
case IVL_SIT_TRI:
case IVL_SIT_TRI0:
case IVL_SIT_TRI1:
fprintf(vvp_out, " %%load/nx %u, V_%s, 0;\n", res.base,
vvp_signal_label(sig));
break;
default:
fprintf(vvp_out, " %%load/x %u, V_%s, 0;\n", res.base,
vvp_signal_label(sig));
break;
}
if (res.base >= 8)
save_expression_lookaside(res.base, exp, wid);
return res;
}
/*
* The concatenation operator is evaluated by evaluating each sub-
* expression, then copying it into the continguous vector of the
@ -2063,10 +2030,6 @@ struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid,
res = draw_binary_expr(exp, wid, stuff_ok_flag);
break;
case IVL_EX_BITSEL:
res = draw_bitsel_expr(exp, wid);
break;
case IVL_EX_CONCAT:
res = draw_concat_expr(exp, wid);
break;
@ -2125,6 +2088,11 @@ struct vector_info draw_eval_expr(ivl_expr_t exp, int stuff_ok_flag)
/*
* $Log: eval_expr.c,v $
* Revision 1.113 2005/01/24 05:28:31 steve
* Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type.
*
* Revision 1.112 2005/01/24 05:08:02 steve
* Part selects are done in the compiler, not here.
*