diff --git a/t-dll-expr.cc b/t-dll-expr.cc index 1e4efd32e..32a98bec1 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.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-expr.cc,v 1.23 2002/04/14 02:56:19 steve Exp $" +#ident "$Id: t-dll-expr.cc,v 1.24 2002/05/29 22:05:54 steve Exp $" #endif # include "config.h" @@ -39,6 +39,40 @@ * method expects that the expr_ member empty (0) when it starts. */ +/* + * This function takes an expression in the expr_ member that is + * already built up, and adds a subtraction of the given constant. + */ +void dll_target::sub_off_from_expr_(long off) +{ + assert(expr_ != 0); + + char*bits; + ivl_expr_t tmpc = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); + tmpc->type_ = IVL_EX_NUMBER; + tmpc->width_ = expr_->width_; + tmpc->signed_ = expr_->signed_; + tmpc->u_.number_.bits_ = bits = (char*)malloc(tmpc->width_); + for (unsigned idx = 0 ; idx < tmpc->width_ ; idx += 1) { + bits[idx] = (off & 1)? '1' : '0'; + off >>= 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_ = tmpc->signed_; + tmps->u_.binary_.op_ = '-'; + tmps->u_.binary_.lef_ = expr_; + tmps->u_.binary_.rig_ = tmpc; + + /* Replace (x) with (x-off) */ + expr_ = tmps; +} + void dll_target::expr_binary(const NetEBinary*net) { @@ -370,6 +404,9 @@ void dll_target::expr_unary(const NetEUnary*net) /* * $Log: t-dll-expr.cc,v $ + * Revision 1.24 2002/05/29 22:05:54 steve + * Offset lvalue index expressions. + * * Revision 1.23 2002/04/14 02:56:19 steve * Support signed expressions through to VPI. * diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 7bf67d7e5..2db10571f 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -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.44 2002/05/27 00:08:45 steve Exp $" +#ident "$Id: t-dll-proc.cc,v 1.45 2002/05/29 22:05:55 steve Exp $" #endif # include "config.h" @@ -196,6 +196,10 @@ void dll_target::proc_assign_nb(const NetAssignNB*net) if (asn->bmux()) { assert(expr_ == 0); asn->bmux()->expr_scan(this); + + if (asn->sig()->lsb() != 0) + sub_off_from_expr_(asn->sig()->lsb()); + cur->type_ = IVL_LVAL_MUX; cur->idx = expr_; expr_ = 0; @@ -813,6 +817,9 @@ void dll_target::proc_while(const NetWhile*net) /* * $Log: t-dll-proc.cc,v $ + * Revision 1.45 2002/05/29 22:05:55 steve + * Offset lvalue index expressions. + * * Revision 1.44 2002/05/27 00:08:45 steve * Support carrying the scope of named begin-end * blocks down to the code generator, and have diff --git a/t-dll.h b/t-dll.h index ea171945b..7f6166963 100644 --- a/t-dll.h +++ b/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.80 2002/05/27 00:08:45 steve Exp $" +#ident "$Id: t-dll.h,v 1.81 2002/05/29 22:05:55 steve Exp $" #endif # include "target.h" @@ -150,6 +150,7 @@ struct dll_target : public target_t, public expr_scan_t { static ivl_signal_t find_signal(ivl_design_s &des, const NetNet*net); void add_root(ivl_design_s &des_, const NetScope *s); + void sub_off_from_expr_(long); }; /* @@ -604,6 +605,9 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.81 2002/05/29 22:05:55 steve + * Offset lvalue index expressions. + * * Revision 1.80 2002/05/27 00:08:45 steve * Support carrying the scope of named begin-end * blocks down to the code generator, and have diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 74c90e936..675cd69cf 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -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.61 2002/05/27 00:08:45 steve Exp $" +#ident "$Id: stub.c,v 1.62 2002/05/29 22:05:55 steve Exp $" #endif # include "config.h" @@ -43,6 +43,12 @@ static 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>\n", ind, "", ivl_expr_opcode(net), width, sign); @@ -231,7 +237,9 @@ static void show_assign_lval(ivl_lval_t lval, unsigned ind) unsigned pp; ivl_nexus_t nex = ivl_lval_pin(lval, 0); - fprintf(out, "%*s{%s", ind, "", ivl_nexus_name(nex)); + fprintf(out, "%*spart_off=%u {%s", ind, "", + ivl_lval_part_off(lval), + ivl_nexus_name(nex)); fprintf(out, "", ivl_nexus_ptrs(nex)); for (pp = 1 ; pp < ivl_lval_pins(lval) ; pp += 1) { nex = ivl_lval_pin(lval, pp); @@ -688,6 +696,9 @@ int target_design(ivl_design_t des) /* * $Log: stub.c,v $ + * Revision 1.62 2002/05/29 22:05:55 steve + * Offset lvalue index expressions. + * * Revision 1.61 2002/05/27 00:08:45 steve * Support carrying the scope of named begin-end * blocks down to the code generator, and have