Implement LPM part select
This commit is contained in:
parent
f800298d01
commit
081f397460
|
|
@ -58,6 +58,30 @@ static int draw_binop_lpm(vhdl_arch *arch, ivl_lpm_t lpm, vhdl_binop_t op)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int draw_part_select_lpm(vhdl_arch *arch, ivl_lpm_t lpm)
|
||||
{
|
||||
vhdl_var_ref *selfrom = nexus_to_var_ref(arch->get_scope(), ivl_lpm_data(lpm, 0));
|
||||
if (NULL == selfrom)
|
||||
return 1;
|
||||
|
||||
vhdl_expr *off = nexus_to_var_ref(arch->get_scope(), ivl_lpm_data(lpm, 1));
|
||||
if (NULL == off)
|
||||
return 1;
|
||||
|
||||
vhdl_var_ref *out = nexus_to_var_ref(arch->get_scope(), ivl_lpm_q(lpm, 0));
|
||||
if (NULL == out)
|
||||
return 1;
|
||||
|
||||
// Array indexes must be integers
|
||||
vhdl_type integer(VHDL_TYPE_INTEGER);
|
||||
off = off->cast(&integer);
|
||||
|
||||
selfrom->set_slice(off);
|
||||
arch->add_stmt(new vhdl_cassign_stmt(out, selfrom));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int draw_lpm(vhdl_arch *arch, ivl_lpm_t lpm)
|
||||
{
|
||||
switch (ivl_lpm_type(lpm)) {
|
||||
|
|
@ -67,6 +91,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_PART_VP:
|
||||
return draw_part_select_lpm(arch, lpm);
|
||||
default:
|
||||
error("Unsupported LPM type: %d", ivl_lpm_type(lpm));
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public:
|
|||
|
||||
void emit(std::ofstream &of, int level) const;
|
||||
const std::string &get_name() const { return name_; }
|
||||
void set_slice(vhdl_expr *s) { slice_ = s; }
|
||||
private:
|
||||
std::string name_;
|
||||
vhdl_expr *slice_;
|
||||
|
|
|
|||
Loading…
Reference in New Issue