Concat LPM

This commit is contained in:
Nick Gasson 2008-07-07 14:48:57 +01:00
parent ebaa4c7d5d
commit bdf5ee7ab7
3 changed files with 11 additions and 42 deletions

View File

@ -212,22 +212,10 @@ static vhdl_expr *translate_select(ivl_expr_t e)
{
vhdl_expr *from = translate_expr(ivl_expr_oper1(e));
if (NULL == from)
return NULL;
ivl_expr_t o2 = ivl_expr_oper2(e);
if (o2) {
vhdl_expr *off = translate_expr(ivl_expr_oper2(e));
if (NULL == off)
return NULL;
vhdl_var_ref *ref = dynamic_cast<vhdl_var_ref*>(from);
assert(ref);
ref->set_slice(off);
return ref;
}
else
return from;
return NULL;
// Hack: resize it to the correct size
return from->resize(ivl_expr_width(e));
}
static vhdl_type *expr_to_vhdl_type(ivl_expr_t e)

View File

@ -143,6 +143,8 @@ int draw_lpm(vhdl_arch *arch, ivl_lpm_t lpm)
return draw_binop_lpm(arch, lpm, VHDL_BINOP_SUB);
case IVL_LPM_MULT:
return draw_binop_lpm(arch, lpm, VHDL_BINOP_MULT);
case IVL_LPM_CONCAT:
return draw_binop_lpm(arch, lpm, VHDL_BINOP_CONCAT);
case IVL_LPM_PART_PV:
return draw_part_select_pv_lpm(arch, lpm);
case IVL_LPM_PART_VP:

View File

@ -110,22 +110,14 @@ static int draw_noop(vhdl_procedural *proc, stmt_container *container,
*/
template <class T>
static T *make_vhdl_assignment(vhdl_procedural *proc, stmt_container *container,
ivl_signal_t sig, vhdl_expr *rhs, bool blocking,
vhdl_expr *base = NULL)
ivl_signal_t sig, vhdl_expr *rhs, bool blocking)
{
std::string signame(get_renamed_signal(sig));
vhdl_decl *decl = proc->get_scope()->get_decl(signame);
assert(decl);
// TODO: Fix casting when there is a part select
if (base == NULL)
rhs = rhs->cast(decl->get_type());
if (base) {
vhdl_type integer(VHDL_TYPE_INTEGER);
base = base->cast(&integer);
}
rhs = rhs->cast(decl->get_type());
bool isvar = strip_var(signame) != signame;
@ -162,9 +154,6 @@ static T *make_vhdl_assignment(vhdl_procedural *proc, stmt_container *container,
vhdl_var_ref *lval_ref = new vhdl_var_ref(renamed.c_str(), NULL);
vhdl_var_ref *sig_ref = new vhdl_var_ref(signame.c_str(), NULL);
if (base)
lval_ref->set_slice(base);
T *a = new T(lval_ref, sig_ref);
container->add_stmt(a);
@ -185,8 +174,6 @@ static T *make_vhdl_assignment(vhdl_procedural *proc, stmt_container *container,
// The type here can be null as it is never actually needed
vhdl_var_ref *lval_ref = new vhdl_var_ref(signame.c_str(), NULL);
if (base)
lval_ref->set_slice(base);
T *a = new T(lval_ref, rhs);
container->add_stmt(a);
@ -211,14 +198,6 @@ static T *make_assignment(vhdl_procedural *proc, stmt_container *container,
ivl_lval_t lval = ivl_stmt_lval(stmt, 0);
ivl_signal_t sig;
if ((sig = ivl_lval_sig(lval))) {
vhdl_expr *base = NULL;
ivl_expr_t e_off = ivl_lval_part_off(lval);
if (e_off) {
if ((base = translate_expr(e_off)) == NULL)
return NULL;
}
ivl_expr_t rval = ivl_stmt_rval(stmt);
if (ivl_expr_type(rval) == IVL_EX_TERNARY) {
// Expand ternary expressions into an if statement
@ -231,9 +210,9 @@ static T *make_assignment(vhdl_procedural *proc, stmt_container *container,
vhdl_if_stmt *vhdif = new vhdl_if_stmt(test);
make_vhdl_assignment<T>(proc, vhdif->get_then_container(), sig,
true_part, blocking, base);
true_part, blocking);
make_vhdl_assignment<T>(proc, vhdif->get_else_container(), sig,
false_part, blocking, base);
false_part, blocking);
container->add_stmt(vhdif);
return NULL;
@ -243,7 +222,7 @@ static T *make_assignment(vhdl_procedural *proc, stmt_container *container,
if (NULL == rhs)
return NULL;
return make_vhdl_assignment<T>(proc, container, sig, rhs, blocking, base);
return make_vhdl_assignment<T>(proc, container, sig, rhs, blocking);
}
}
else {