Add ivl_lval_t and support for assignment l-values.
This commit is contained in:
parent
f5fae7f271
commit
e10679633d
6
ivl.def
6
ivl.def
|
|
@ -26,6 +26,10 @@ ivl_logic_type
|
|||
ivl_logic_pin
|
||||
ivl_logic_pins
|
||||
|
||||
ivl_lval_mux
|
||||
ivl_lval_pin
|
||||
ivl_lval_pins
|
||||
|
||||
ivl_nexus_name
|
||||
ivl_nexus_ptrs
|
||||
ivl_nexus_ptr
|
||||
|
|
@ -54,6 +58,8 @@ ivl_stmt_cond_expr
|
|||
ivl_stmt_cond_false
|
||||
ivl_stmt_cond_true
|
||||
ivl_stmt_delay_val
|
||||
ivl_stmt_lval
|
||||
ivl_stmt_lvals
|
||||
ivl_stmt_lwidth
|
||||
ivl_stmt_name
|
||||
ivl_stmt_parm
|
||||
|
|
|
|||
36
ivl_target.h
36
ivl_target.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: ivl_target.h,v 1.20 2000/10/15 04:46:23 steve Exp $"
|
||||
#ident "$Id: ivl_target.h,v 1.21 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -113,6 +113,7 @@ _BEGIN_DECL
|
|||
*/
|
||||
typedef struct ivl_design_s *ivl_design_t;
|
||||
typedef struct ivl_expr_s *ivl_expr_t;
|
||||
typedef struct ivl_lval_s *ivl_lval_t;
|
||||
typedef struct ivl_net_const_s*ivl_net_const_t;
|
||||
typedef struct ivl_net_event_s*ivl_net_event_t;
|
||||
typedef struct ivl_net_logic_s*ivl_net_logic_t;
|
||||
|
|
@ -312,6 +313,32 @@ extern ivl_logic_t ivl_logic_type(ivl_net_logic_t net);
|
|||
extern ivl_nexus_t ivl_logic_pin(ivl_net_logic_t net, unsigned pin);
|
||||
extern unsigned ivl_logic_pins(ivl_net_logic_t net);
|
||||
|
||||
|
||||
/* LVAL
|
||||
* The l-values of assignments are concatenation of ivl_lval_t
|
||||
* objects. Each l-value has a bunch of connections (in the form of
|
||||
* ivl_nexus_t objects) and possibly a mux expression. The compiler
|
||||
* takes care of part selects and nested concatenations. The
|
||||
* ivl_stmt_lval function pulls ivl_lval_t objects out of the
|
||||
* statement.
|
||||
*
|
||||
* ivl_lval_mux
|
||||
* If the l-value includes a bit select expression, this method
|
||||
* returns an ivl_expr_t that represents that
|
||||
* expression. Otherwise, it returns 0.
|
||||
*
|
||||
* ivl_lval_pin
|
||||
* Return an ivl_nexus_t for the connection of the ivl_lval_t.
|
||||
*
|
||||
* ivl_lval_pins
|
||||
* Return the number of pins for this object.
|
||||
*/
|
||||
|
||||
extern ivl_expr_t ivl_lval_mux(ivl_lval_t net);
|
||||
extern unsigned ivl_lval_pins(ivl_lval_t net);
|
||||
extern ivl_nexus_t ivl_lval_pin(ivl_lval_t net, unsigned idx);
|
||||
|
||||
|
||||
/* NEXUS
|
||||
* connections of signals and nodes is handled by single-bit
|
||||
* nexus. These functions manage the ivl_nexus_t object. They also
|
||||
|
|
@ -445,6 +472,10 @@ extern ivl_statement_t ivl_stmt_cond_true(ivl_statement_t net);
|
|||
/* IVL_ST_DELAY */
|
||||
extern unsigned long ivl_stmt_delay_val(ivl_statement_t net);
|
||||
/* IVL_ST_ASSIGN */
|
||||
extern ivl_lval_t ivl_stmt_lval(ivl_statement_t net, unsigned idx);
|
||||
/* IVL_ST_ASSIGN */
|
||||
extern unsigned ivl_stmt_lvals(ivl_statement_t net);
|
||||
/* IVL_ST_ASSIGN */
|
||||
extern unsigned ivl_stmt_lwidth(ivl_statement_t net);
|
||||
/* IVL_ST_STASK */
|
||||
extern const char* ivl_stmt_name(ivl_statement_t net);
|
||||
|
|
@ -518,6 +549,9 @@ _END_DECL
|
|||
|
||||
/*
|
||||
* $Log: ivl_target.h,v $
|
||||
* Revision 1.21 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.20 2000/10/15 04:46:23 steve
|
||||
* Scopes and processes are accessible randomly from
|
||||
* the design, and signals and logic are accessible
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: net_assign.cc,v 1.5 2000/09/20 02:53:15 steve Exp $"
|
||||
#ident "$Id: net_assign.cc,v 1.6 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -132,6 +132,18 @@ const NetAssign_* NetAssignBase::l_val(unsigned idx) const
|
|||
return cur;
|
||||
}
|
||||
|
||||
unsigned NetAssignBase::l_val_count() const
|
||||
{
|
||||
const NetAssign_*cur = lval_;
|
||||
unsigned cnt = 0;
|
||||
while (cur) {
|
||||
cnt += 1;
|
||||
cur = cur->more;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
unsigned NetAssignBase::lwidth() const
|
||||
{
|
||||
unsigned sum = 0;
|
||||
|
|
@ -161,6 +173,9 @@ NetAssignNB::~NetAssignNB()
|
|||
|
||||
/*
|
||||
* $Log: net_assign.cc,v $
|
||||
* Revision 1.6 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.5 2000/09/20 02:53:15 steve
|
||||
* Correctly measure comples l-values of assignments.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: netlist.h,v 1.173 2000/10/07 19:45:43 steve Exp $"
|
||||
#ident "$Id: netlist.h,v 1.174 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -1242,6 +1242,7 @@ class NetAssignBase : public NetProc {
|
|||
|
||||
NetAssign_* l_val(unsigned);
|
||||
const NetAssign_* l_val(unsigned) const;
|
||||
unsigned l_val_count() const;
|
||||
|
||||
// This returns the total width of the accumulated l-value. It
|
||||
// accounts for any grouping of NetAssign_ objects that might happen.
|
||||
|
|
@ -2806,6 +2807,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
|||
|
||||
/*
|
||||
* $Log: netlist.h,v $
|
||||
* Revision 1.174 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.173 2000/10/07 19:45:43 steve
|
||||
* Put logic devices into scopes.
|
||||
*
|
||||
|
|
|
|||
61
t-dll-api.cc
61
t-dll-api.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: t-dll-api.cc,v 1.13 2000/10/16 22:44:54 steve Exp $"
|
||||
#ident "$Id: t-dll-api.cc,v 1.14 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "t-dll.h"
|
||||
|
|
@ -201,6 +201,28 @@ extern "C" ivl_nexus_t ivl_logic_pin(ivl_net_logic_t net, unsigned pin)
|
|||
return net->pins_[pin];
|
||||
}
|
||||
|
||||
extern "C" ivl_expr_t ivl_lval_mux(ivl_lval_t net)
|
||||
{
|
||||
assert(net);
|
||||
return net->mux;
|
||||
}
|
||||
|
||||
extern "C" unsigned ivl_lval_pins(ivl_lval_t net)
|
||||
{
|
||||
assert(net);
|
||||
return net->width_;
|
||||
}
|
||||
|
||||
extern "C" ivl_nexus_t ivl_lval_pin(ivl_lval_t net, unsigned idx)
|
||||
{
|
||||
assert(net);
|
||||
assert(idx < net->width_);
|
||||
if (net->width_ == 1)
|
||||
return net->n.pin_;
|
||||
else
|
||||
return net->n.pins_[idx];
|
||||
}
|
||||
|
||||
extern "C" const char* ivl_nexus_name(ivl_nexus_t net)
|
||||
{
|
||||
assert(net);
|
||||
|
|
@ -350,10 +372,42 @@ extern "C" unsigned long ivl_stmt_delay_val(ivl_statement_t net)
|
|||
return net->u_.delay_.delay_;
|
||||
}
|
||||
|
||||
extern "C" ivl_lval_t ivl_stmt_lval(ivl_statement_t net, unsigned idx)
|
||||
{
|
||||
switch (net->type_) {
|
||||
case IVL_ST_ASSIGN:
|
||||
assert(idx < net->u_.assign_.lvals_);
|
||||
return net->u_.assign_.lval_ + idx;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" unsigned ivl_stmt_lvals(ivl_statement_t net)
|
||||
{
|
||||
switch (net->type_) {
|
||||
case IVL_ST_ASSIGN:
|
||||
return net->u_.assign_.lvals_;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" unsigned ivl_stmt_lwidth(ivl_statement_t net)
|
||||
{
|
||||
assert(net->type_ == IVL_ST_ASSIGN);
|
||||
return net->u_.assign_.lwidth_;
|
||||
unsigned sum = 0;
|
||||
for (unsigned idx = 0 ; idx < net->u_.assign_.lvals_ ; idx += 1) {
|
||||
ivl_lval_t cur = net->u_.assign_.lval_ + idx;
|
||||
if (cur->mux)
|
||||
sum += 1;
|
||||
else
|
||||
sum += cur->width_;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
extern "C" const char* ivl_stmt_name(ivl_statement_t net)
|
||||
|
|
@ -422,6 +476,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
|
|||
|
||||
/*
|
||||
* $Log: t-dll-api.cc,v $
|
||||
* Revision 1.14 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.13 2000/10/16 22:44:54 steve
|
||||
* Stubs so that cygwin port will link ivl.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: t-dll-proc.cc,v 1.9 2000/10/08 04:01:54 steve Exp $"
|
||||
#ident "$Id: t-dll-proc.cc,v 1.10 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "target.h"
|
||||
|
|
@ -74,12 +74,44 @@ bool dll_target::process(const NetProcTop*net)
|
|||
*/
|
||||
void dll_target::proc_assign(const NetAssign*net)
|
||||
{
|
||||
unsigned cnt;
|
||||
|
||||
assert(stmt_cur_);
|
||||
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
||||
|
||||
stmt_cur_->type_ = IVL_ST_ASSIGN;
|
||||
|
||||
stmt_cur_->u_.assign_.lwidth_ = net->lwidth();
|
||||
stmt_cur_->u_.assign_.lvals_ = cnt = net->l_val_count();
|
||||
stmt_cur_->u_.assign_.lval_ = new struct ivl_lval_s[cnt];
|
||||
|
||||
for (unsigned idx = 0 ; idx < cnt ; idx += 1) {
|
||||
struct ivl_lval_s*cur = stmt_cur_->u_.assign_.lval_ + idx;
|
||||
const NetAssign_*asn = net->l_val(idx);
|
||||
|
||||
cur->width_ = asn->pin_count();
|
||||
|
||||
if (cur->width_ > 1) {
|
||||
cur->n.pins_ = new ivl_nexus_t[cur->width_];
|
||||
for (unsigned pp = 0 ; pp < cur->width_ ; pp += 1) {
|
||||
const Nexus*nex = asn->pin(pp).nexus();
|
||||
assert(nex->t_cookie());
|
||||
cur->n.pins_[pp] = (ivl_nexus_t)nex->t_cookie();
|
||||
}
|
||||
|
||||
} else {
|
||||
const Nexus*nex = asn->pin(0).nexus();
|
||||
assert(nex->t_cookie());
|
||||
cur->n.pin_ = (ivl_nexus_t)nex->t_cookie();
|
||||
}
|
||||
|
||||
cur->mux = 0;
|
||||
if (asn->bmux()) {
|
||||
assert(expr_ == 0);
|
||||
asn->bmux()->expr_scan(this);
|
||||
cur->mux = expr_;
|
||||
expr_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
assert(expr_ == 0);
|
||||
net->rval()->expr_scan(this);
|
||||
|
|
@ -269,6 +301,9 @@ void dll_target::proc_while(const NetWhile*net)
|
|||
|
||||
/*
|
||||
* $Log: t-dll-proc.cc,v $
|
||||
* Revision 1.10 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.9 2000/10/08 04:01:54 steve
|
||||
* Back pointers in the nexus objects into the devices
|
||||
* that point to it.
|
||||
|
|
|
|||
22
t-dll.h
22
t-dll.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: t-dll.h,v 1.13 2000/10/15 04:46:23 steve Exp $"
|
||||
#ident "$Id: t-dll.h,v 1.14 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "target.h"
|
||||
|
|
@ -130,6 +130,20 @@ struct ivl_expr_s {
|
|||
} u_;
|
||||
};
|
||||
|
||||
/*
|
||||
* This object contains references to ivl_nexus_t objects that in turn
|
||||
* are reg nets. This is used by the assignment to represent the
|
||||
* l-value expressions.
|
||||
*/
|
||||
struct ivl_lval_s {
|
||||
unsigned width_ :24;
|
||||
ivl_expr_t mux;
|
||||
union {
|
||||
ivl_nexus_t*pins_;
|
||||
ivl_nexus_t pin_;
|
||||
} n;
|
||||
};
|
||||
|
||||
/*
|
||||
* This object represents a vector constant, possibly signed, in a
|
||||
* structural context.
|
||||
|
|
@ -248,7 +262,8 @@ struct ivl_statement_s {
|
|||
enum ivl_statement_type_e type_;
|
||||
union {
|
||||
struct { /* IVL_ST_ASSIGN */
|
||||
unsigned lwidth_ :24;
|
||||
unsigned lvals_;
|
||||
struct ivl_lval_s*lval_;
|
||||
ivl_expr_t rval_;
|
||||
} assign_;
|
||||
|
||||
|
|
@ -298,6 +313,9 @@ struct ivl_statement_s {
|
|||
|
||||
/*
|
||||
* $Log: t-dll.h,v $
|
||||
* Revision 1.14 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.13 2000/10/15 04:46:23 steve
|
||||
* Scopes and processes are accessible randomly from
|
||||
* the design, and signals and logic are accessible
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: stub.c,v 1.18 2000/10/15 21:02:08 steve Exp $"
|
||||
#ident "$Id: stub.c,v 1.19 2000/10/18 20:04:39 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -75,18 +75,32 @@ static void show_expression(ivl_expr_t net, unsigned ind)
|
|||
|
||||
static void show_statement(ivl_statement_t net, unsigned ind)
|
||||
{
|
||||
unsigned idx;
|
||||
const ivl_statement_type_t code = ivl_statement_type(net);
|
||||
|
||||
switch (code) {
|
||||
|
||||
case IVL_ST_ASSIGN:
|
||||
fprintf(out, "%*sASSIGN <lwidth=%u>\n", ind, "",
|
||||
ivl_stmt_lwidth(net));
|
||||
for (idx = 0 ; idx < ivl_stmt_lvals(net) ; idx += 1) {
|
||||
unsigned pp;
|
||||
ivl_lval_t lval = ivl_stmt_lval(net, idx);
|
||||
ivl_nexus_t nex = ivl_lval_pin(lval, 0);
|
||||
|
||||
fprintf(out, "%*s{%s", ind+4, "", ivl_nexus_name(nex));
|
||||
for (pp = 1 ; pp < ivl_lval_pins(lval) ; pp += 1) {
|
||||
nex = ivl_lval_pin(lval, pp);
|
||||
fprintf(out, ", %s", ivl_nexus_name(nex));
|
||||
}
|
||||
fprintf(out, "}\n");
|
||||
}
|
||||
|
||||
show_expression(ivl_stmt_rval(net), ind+4);
|
||||
break;
|
||||
|
||||
case IVL_ST_BLOCK: {
|
||||
unsigned cnt = ivl_stmt_block_count(net);
|
||||
unsigned idx;
|
||||
fprintf(out, "%*sbegin\n", ind, "");
|
||||
for (idx = 0 ; idx < cnt ; idx += 1) {
|
||||
ivl_statement_t cur = ivl_stmt_block_stmt(net, idx);
|
||||
|
|
@ -124,7 +138,6 @@ static void show_statement(ivl_statement_t net, unsigned ind)
|
|||
break;
|
||||
|
||||
case IVL_ST_STASK: {
|
||||
unsigned idx;
|
||||
fprintf(out, "%*sCall %s(%u parameters);\n", ind, "",
|
||||
ivl_stmt_name(net), ivl_stmt_parm_count(net));
|
||||
for (idx = 0 ; idx < ivl_stmt_parm_count(net) ; idx += 1)
|
||||
|
|
@ -323,6 +336,9 @@ DECLARE_CYGWIN_DLL(DllMain);
|
|||
|
||||
/*
|
||||
* $Log: stub.c,v $
|
||||
* Revision 1.19 2000/10/18 20:04:39 steve
|
||||
* Add ivl_lval_t and support for assignment l-values.
|
||||
*
|
||||
* Revision 1.18 2000/10/15 21:02:08 steve
|
||||
* Makefile patches to support target loading under cygwin.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue