API for concatenation expressions.
This commit is contained in:
parent
10fbb2a1bb
commit
d6efae4bdd
3
ivl.def
3
ivl.def
|
|
@ -16,6 +16,9 @@ ivl_expr_opcode
|
|||
ivl_expr_oper1
|
||||
ivl_expr_oper2
|
||||
ivl_expr_oper3
|
||||
ivl_expr_parm
|
||||
ivl_expr_parms
|
||||
ivl_expr_repeat
|
||||
ivl_expr_signed
|
||||
ivl_expr_string
|
||||
ivl_expr_width
|
||||
|
|
|
|||
31
ivl_target.h
31
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.24 2000/10/28 17:55:03 steve Exp $"
|
||||
#ident "$Id: ivl_target.h,v 1.25 2000/10/28 22:32:34 steve Exp $"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -258,12 +258,30 @@ extern ivl_nexus_t ivl_const_pin(ivl_net_const_t net, unsigned idx);
|
|||
extern unsigned ivl_const_pins(ivl_net_const_t net);
|
||||
extern int ivl_const_signed(ivl_net_const_t net);
|
||||
|
||||
/* EXPRESSION
|
||||
/* EXPRESSIONS
|
||||
*
|
||||
* These methods operate on expression objects from the
|
||||
* design. Expressions mainly exist in behavioral code. The
|
||||
* ivl_expr_type() function returns the type of the expression node,
|
||||
* and the remaining functions access value bits of the expression.
|
||||
*
|
||||
* ivl_expr_signed
|
||||
* This method returns true (!= 0) if the expression node
|
||||
* represents a signed expression. It is possible for sub-
|
||||
* expressions to be unsigned even if a node is signed, but the
|
||||
* IVL core figures all this out for you. At any rate, this method
|
||||
* can be applied to any expression node.
|
||||
*
|
||||
* ivl_expr_type
|
||||
* Get the type of the expression node. Every expression node has a
|
||||
* type, which can affect how some of the other expression methods
|
||||
* operate on the node
|
||||
*
|
||||
* ivl_expr_width
|
||||
* This method returns the bit width of the expression at this
|
||||
* node. It can be applied to any expression node.
|
||||
*/
|
||||
|
||||
extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net);
|
||||
|
||||
/* IVL_EX_NUMBER */
|
||||
|
|
@ -278,6 +296,12 @@ extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net);
|
|||
extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net);
|
||||
/* */
|
||||
extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net);
|
||||
/* IVL_EX_CONCAT */
|
||||
extern ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx);
|
||||
/* IVL_EX_CONCAT */
|
||||
extern unsigned ivl_expr_parms(ivl_expr_t net);
|
||||
/* IVL_EX_CONCAT */
|
||||
extern unsigned ivl_expr_repeat(ivl_expr_t net);
|
||||
/* any expression */
|
||||
extern int ivl_expr_signed(ivl_expr_t net);
|
||||
/* IVL_EX_STRING */
|
||||
|
|
@ -524,6 +548,9 @@ _END_DECL
|
|||
|
||||
/*
|
||||
* $Log: ivl_target.h,v $
|
||||
* Revision 1.25 2000/10/28 22:32:34 steve
|
||||
* API for concatenation expressions.
|
||||
*
|
||||
* Revision 1.24 2000/10/28 17:55:03 steve
|
||||
* stub for the concat operator.
|
||||
*
|
||||
|
|
|
|||
38
t-dll-api.cc
38
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.15 2000/10/25 05:41:24 steve Exp $"
|
||||
#ident "$Id: t-dll-api.cc,v 1.16 2000/10/28 22:32:34 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "t-dll.h"
|
||||
|
|
@ -152,6 +152,39 @@ extern "C" ivl_expr_t ivl_expr_oper3(ivl_expr_t net)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx)
|
||||
{
|
||||
assert(net);
|
||||
switch (net->type_) {
|
||||
case IVL_EX_CONCAT:
|
||||
assert(idx < net->u_.concat_.parms);
|
||||
return net->u_.concat_.parm[idx];
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" unsigned ivl_expr_parms(ivl_expr_t net)
|
||||
{
|
||||
assert(net);
|
||||
switch (net->type_) {
|
||||
case IVL_EX_CONCAT:
|
||||
return net->u_.concat_.parms;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" unsigned ivl_expr_repeat(ivl_expr_t net)
|
||||
{
|
||||
assert(net);
|
||||
assert(net->type_ == IVL_EX_CONCAT);
|
||||
return net->u_.concat_.rept;
|
||||
}
|
||||
|
||||
extern "C" int ivl_expr_signed(ivl_expr_t net)
|
||||
{
|
||||
assert(net);
|
||||
|
|
@ -503,6 +536,9 @@ extern "C" ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net)
|
|||
|
||||
/*
|
||||
* $Log: t-dll-api.cc,v $
|
||||
* Revision 1.16 2000/10/28 22:32:34 steve
|
||||
* API for concatenation expressions.
|
||||
*
|
||||
* Revision 1.15 2000/10/25 05:41:24 steve
|
||||
* Get target signal from nexus_ptr.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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-expr.cc,v 1.6 2000/10/28 17:55:03 steve Exp $"
|
||||
#ident "$Id: t-dll-expr.cc,v 1.7 2000/10/28 22:32:34 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "t-dll.h"
|
||||
|
|
@ -59,11 +59,24 @@ void dll_target::expr_concat(const NetEConcat*net)
|
|||
{
|
||||
assert(expr_ == 0);
|
||||
|
||||
expr_ = new struct ivl_expr_s;
|
||||
assert(expr_);
|
||||
ivl_expr_t cur = new struct ivl_expr_s;
|
||||
assert(cur);
|
||||
|
||||
expr_->type_ = IVL_EX_CONCAT;
|
||||
expr_->width_= net->expr_width();
|
||||
cur->type_ = IVL_EX_CONCAT;
|
||||
cur->width_= net->expr_width();
|
||||
|
||||
cur->u_.concat_.rept = net->repeat();
|
||||
cur->u_.concat_.parms = net->nparms();
|
||||
cur->u_.concat_.parm = new ivl_expr_t [net->nparms()];
|
||||
|
||||
for (unsigned idx = 0 ; idx < net->nparms() ; idx += 1) {
|
||||
expr_ = 0;
|
||||
net->parm(idx)->expr_scan(this);
|
||||
assert(expr_);
|
||||
cur->u_.concat_.parm[idx] = expr_;
|
||||
}
|
||||
|
||||
expr_ = cur;
|
||||
}
|
||||
|
||||
void dll_target::expr_const(const NetEConst*net)
|
||||
|
|
@ -133,6 +146,9 @@ void dll_target::expr_signal(const NetESignal*net)
|
|||
|
||||
/*
|
||||
* $Log: t-dll-expr.cc,v $
|
||||
* Revision 1.7 2000/10/28 22:32:34 steve
|
||||
* API for concatenation expressions.
|
||||
*
|
||||
* Revision 1.6 2000/10/28 17:55:03 steve
|
||||
* stub for the concat operator.
|
||||
*
|
||||
|
|
|
|||
11
t-dll.h
11
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.16 2000/10/28 17:55:03 steve Exp $"
|
||||
#ident "$Id: t-dll.h,v 1.17 2000/10/28 22:32:34 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "target.h"
|
||||
|
|
@ -108,6 +108,12 @@ struct ivl_expr_s {
|
|||
ivl_expr_t rig_;
|
||||
} binary_;
|
||||
|
||||
struct {
|
||||
unsigned rept :16;
|
||||
unsigned parms :16;
|
||||
ivl_expr_t*parm;
|
||||
} concat_;
|
||||
|
||||
struct {
|
||||
char*bits_;
|
||||
} number_;
|
||||
|
|
@ -311,6 +317,9 @@ struct ivl_statement_s {
|
|||
|
||||
/*
|
||||
* $Log: t-dll.h,v $
|
||||
* Revision 1.17 2000/10/28 22:32:34 steve
|
||||
* API for concatenation expressions.
|
||||
*
|
||||
* Revision 1.16 2000/10/28 17:55:03 steve
|
||||
* stub for the concat operator.
|
||||
*
|
||||
|
|
|
|||
26
t-dll.txt
26
t-dll.txt
|
|
@ -28,3 +28,29 @@ The target module API is defined in the ivl_target.h header file. This
|
|||
declares all the type and functions that a loadable module needs to
|
||||
access the design.
|
||||
|
||||
|
||||
ABOUT SPECIFIC EXPRESSION TYPES
|
||||
|
||||
In this section find notes about the various kinds of expression
|
||||
nodes. The notes here are in addition to the more generation
|
||||
documentation in the ivl_target.h header file.
|
||||
|
||||
* IVL_EX_CONCAT
|
||||
|
||||
The concatenation operator forms an expression node that holds the
|
||||
repeat count and all the parameter expressions. The repeat count is
|
||||
an integer that is calculated by the core compiler so it fully
|
||||
evaluated, and *not* an expression.
|
||||
|
||||
The parameter expressions are retrieved by the ivl_expr_parm method,
|
||||
with the index increasing as parameters go from left to right, from
|
||||
most significant to least significant. (Note that this is different
|
||||
from the order of bits within an expression node.)
|
||||
|
||||
* IVL_EX_NUMBER
|
||||
|
||||
This is a constant number. The width is fully know, and the bit
|
||||
values are all represented by the ascii characters 0, 1, x or z. The
|
||||
ivl_expr_bits method returns a pointer to the least significant bit,
|
||||
and the remaining bits are ordered from least significant to most
|
||||
significant. For example, 5'b1zzx0 is the 5 character string "0xzz1".
|
||||
|
|
|
|||
|
|
@ -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.22 2000/10/28 17:55:03 steve Exp $"
|
||||
#ident "$Id: stub.c,v 1.23 2000/10/28 22:32:34 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -34,6 +34,7 @@ static FILE*out;
|
|||
|
||||
static void show_expression(ivl_expr_t net, unsigned ind)
|
||||
{
|
||||
unsigned idx;
|
||||
const ivl_expr_type_t code = ivl_expr_type(net);
|
||||
unsigned width = ivl_expr_width(net);
|
||||
const char*sign = ivl_expr_signed(net)? "signed" : "unsigned";
|
||||
|
|
@ -48,12 +49,15 @@ static void show_expression(ivl_expr_t net, unsigned ind)
|
|||
break;
|
||||
|
||||
case IVL_EX_CONCAT:
|
||||
fprintf(out, "%*s<concat width=%u, %s>\n", ind, "", width, sign);
|
||||
fprintf(out, "%*s<concat repeat=%u, width=%u, %s>\n", ind, "",
|
||||
ivl_expr_repeat(net), width, sign);
|
||||
for (idx = 0 ; idx < ivl_expr_parms(net) ; idx += 1)
|
||||
show_expression(ivl_expr_parm(net, idx), ind+3);
|
||||
|
||||
break;
|
||||
|
||||
case IVL_EX_NUMBER: {
|
||||
const char*bits = ivl_expr_bits(net);
|
||||
unsigned idx;
|
||||
|
||||
fprintf(out, "%*s<number=%u'b", ind, "", width);
|
||||
for (idx = width ; idx > 0 ; idx -= 1)
|
||||
|
|
@ -336,6 +340,9 @@ DECLARE_CYGWIN_DLL(DllMain);
|
|||
|
||||
/*
|
||||
* $Log: stub.c,v $
|
||||
* Revision 1.23 2000/10/28 22:32:34 steve
|
||||
* API for concatenation expressions.
|
||||
*
|
||||
* Revision 1.22 2000/10/28 17:55:03 steve
|
||||
* stub for the concat operator.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue