Forum Discussion
Altera_Forum
Honored Contributor
14 years agowhen S4 =>
if(r_by_2 = 1) then
q <= q (m_size-r_by_2-1 downto 0) & q(m_size-1);
else
q(m_size-1 downto r_by_2) <= q (m_size - r_by_2 - 1 downto 0);
q(r_by_2-1 downto 0) <= q(m_size-1 downto m_size - r_by_2);
end if; can be replaced by: when S4 =>
for i in 0 to m_size - 1 loop
q(i0) <= q((i + r_by_2) mod m_size) ;
end loop ;
This code synthesises (I checked!) You may want to use a barrel shift/rotate component in stead (especially if m_size is not a power of 2 as the code above then needs dividers to calculate the 'mod' function), it will probably use less resources and certainly run faster.