Normalize run-time index expressions for bit selects
This commit is contained in:
parent
df0b81d94d
commit
b4b5ac9944
|
|
@ -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) & !defined(macintosh)
|
#if !defined(WINNT) & !defined(macintosh)
|
||||||
#ident "$Id: t-dll-expr.cc,v 1.25 2002/06/16 19:19:16 steve Exp $"
|
#ident "$Id: t-dll-expr.cc,v 1.26 2002/06/16 20:39:12 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -73,6 +73,35 @@ void dll_target::sub_off_from_expr_(long off)
|
||||||
expr_ = tmps;
|
expr_ = tmps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dll_target::mul_expr_by_const_(long val)
|
||||||
|
{
|
||||||
|
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] = (val & 1)? '1' : '0';
|
||||||
|
val >>= 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*valf) */
|
||||||
|
expr_ = tmps;
|
||||||
|
}
|
||||||
|
|
||||||
void dll_target::expr_binary(const NetEBinary*net)
|
void dll_target::expr_binary(const NetEBinary*net)
|
||||||
{
|
{
|
||||||
|
|
@ -429,6 +458,9 @@ void dll_target::expr_unary(const NetEUnary*net)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: t-dll-expr.cc,v $
|
* $Log: t-dll-expr.cc,v $
|
||||||
|
* Revision 1.26 2002/06/16 20:39:12 steve
|
||||||
|
* Normalize run-time index expressions for bit selects
|
||||||
|
*
|
||||||
* Revision 1.25 2002/06/16 19:19:16 steve
|
* Revision 1.25 2002/06/16 19:19:16 steve
|
||||||
* Generate runtime code to normalize indices.
|
* Generate runtime code to normalize indices.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,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) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: t-dll-proc.cc,v 1.48 2002/06/16 19:19:16 steve Exp $"
|
#ident "$Id: t-dll-proc.cc,v 1.49 2002/06/16 20:39:12 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -153,8 +153,10 @@ void dll_target::proc_assign(const NetAssign*net)
|
||||||
assert(expr_ == 0);
|
assert(expr_ == 0);
|
||||||
asn->bmux()->expr_scan(this);
|
asn->bmux()->expr_scan(this);
|
||||||
|
|
||||||
if (asn->sig()->lsb() != 0)
|
if (cur->n.sig->lsb_index != 0)
|
||||||
sub_off_from_expr_(asn->sig()->lsb());
|
sub_off_from_expr_(asn->sig()->lsb());
|
||||||
|
if (cur->n.sig->lsb_dist != 1)
|
||||||
|
mul_expr_by_const_(cur->n.sig->lsb_dist);
|
||||||
|
|
||||||
cur->type_ = IVL_LVAL_MUX;
|
cur->type_ = IVL_LVAL_MUX;
|
||||||
cur->idx = expr_;
|
cur->idx = expr_;
|
||||||
|
|
@ -218,8 +220,10 @@ void dll_target::proc_assign_nb(const NetAssignNB*net)
|
||||||
assert(expr_ == 0);
|
assert(expr_ == 0);
|
||||||
asn->bmux()->expr_scan(this);
|
asn->bmux()->expr_scan(this);
|
||||||
|
|
||||||
if (asn->sig()->lsb() != 0)
|
if (cur->n.sig->lsb_index != 0)
|
||||||
sub_off_from_expr_(asn->sig()->lsb());
|
sub_off_from_expr_(asn->sig()->lsb());
|
||||||
|
if (cur->n.sig->lsb_dist != 1)
|
||||||
|
mul_expr_by_const_(cur->n.sig->lsb_dist);
|
||||||
|
|
||||||
cur->type_ = IVL_LVAL_MUX;
|
cur->type_ = IVL_LVAL_MUX;
|
||||||
cur->idx = expr_;
|
cur->idx = expr_;
|
||||||
|
|
@ -782,6 +786,9 @@ void dll_target::proc_while(const NetWhile*net)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: t-dll-proc.cc,v $
|
* $Log: t-dll-proc.cc,v $
|
||||||
|
* Revision 1.49 2002/06/16 20:39:12 steve
|
||||||
|
* Normalize run-time index expressions for bit selects
|
||||||
|
*
|
||||||
* Revision 1.48 2002/06/16 19:19:16 steve
|
* Revision 1.48 2002/06/16 19:19:16 steve
|
||||||
* Generate runtime code to normalize indices.
|
* Generate runtime code to normalize indices.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
6
t-dll.h
6
t-dll.h
|
|
@ -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) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: t-dll.h,v 1.84 2002/06/16 19:19:16 steve Exp $"
|
#ident "$Id: t-dll.h,v 1.85 2002/06/16 20:39:12 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "target.h"
|
# include "target.h"
|
||||||
|
|
@ -149,6 +149,7 @@ struct dll_target : public target_t, public expr_scan_t {
|
||||||
void add_root(ivl_design_s &des_, const NetScope *s);
|
void add_root(ivl_design_s &des_, const NetScope *s);
|
||||||
|
|
||||||
void sub_off_from_expr_(long);
|
void sub_off_from_expr_(long);
|
||||||
|
void mul_expr_by_const_(long);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -608,6 +609,9 @@ struct ivl_statement_s {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: t-dll.h,v $
|
* $Log: t-dll.h,v $
|
||||||
|
* Revision 1.85 2002/06/16 20:39:12 steve
|
||||||
|
* Normalize run-time index expressions for bit selects
|
||||||
|
*
|
||||||
* Revision 1.84 2002/06/16 19:19:16 steve
|
* Revision 1.84 2002/06/16 19:19:16 steve
|
||||||
* Generate runtime code to normalize indices.
|
* Generate runtime code to normalize indices.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue