Add Active_High support func and fix LPM part select

This commit is contained in:
Nick Gasson 2008-07-07 16:17:54 +01:00
parent b0de1a8d7e
commit 6b73cc39a5
3 changed files with 25 additions and 4 deletions

View File

@ -89,7 +89,7 @@ static int draw_part_select_vp_lpm(vhdl_arch *arch, ivl_lpm_t lpm)
if (NULL == out)
return 1;
selfrom->set_slice(off);
selfrom->set_slice(off, ivl_lpm_width(lpm) - 1);
arch->add_stmt(new vhdl_cassign_stmt(out, selfrom));
return 0;
}
@ -108,7 +108,7 @@ static int draw_part_select_pv_lpm(vhdl_arch *arch, ivl_lpm_t lpm)
if (NULL == out)
return 1;
out->set_slice(off);
out->set_slice(off, ivl_lpm_width(lpm) - 1);
arch->add_stmt(new vhdl_cassign_stmt(out, selfrom));
return 0;
}

View File

@ -15,7 +15,9 @@ package Verilog_Support is
-- Routines to implement Verilog reduction operators
function Reduce_OR(X : unsigned) return std_logic;
-- Convert Boolean to std_logic
function Active_High(B : Boolean) return std_logic;
end Verilog_Support;
@ -36,6 +38,15 @@ package body Verilog_Support is
end if;
end loop;
return '0';
end function;
end function;
function Active_High(B : Boolean) return std_logic is
begin
if B then
return '1';
else
return '0';
end if;
end function;
end Verilog_Support;

View File

@ -400,6 +400,16 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to)
return conv;
}
else if (to->get_name() == VHDL_TYPE_STD_LOGIC &&
type_->get_name() == VHDL_TYPE_BOOLEAN) {
// Verilog assumes active-high logic and there
// is a special routine in verilog_support.vhd
// to do this for us
vhdl_fcall *ah = new vhdl_fcall("Active_High", vhdl_type::std_logic());
ah->add_expr(this);
return ah;
}
else {
// We have to cast the expression before resizing or the
// wrong sign bit may be extended (i.e. when casting between