Altera_Forum
Honored Contributor
10 years agoarithmetic mode for LE from vhdl
I have searched many threads for the solution and the answers were incomplete. So i try to do some investigation.
this code in vhdl definitely put your counter in arithmetic mode for LE. if you have any suggestion please share it with me.process(reset, clk, count_en)
variable v : unsigned(cnt_reg'length downto 0);
begin
if reset = '1' then
cnt_reg <= (others => '0');
cnt_full <= '0'; -- it means counter foolish your
elsif rising_edge(clk) then
if count_en = '1' then
v := ('0' & cnt_reg) + (to_unsigned(0,v'length-1) & count_en); -- if you add with constant you cannot get arithmetic mode for LE
cnt_reg <= v(v'high-1 downto 0);
cnt_full <= v(v'high);
end if;
end if;
end process;