This is what I have done, sorry for not posting this earlier, I think it should work. I found an example in my book and have expanded on it.
I am trying to read data coming in from a 9 bit vector. If there 5 or more zeros I need to assign a value of zero to a second signal, and 1 if otherwise. I am then running that through a shift register. I'm not sure that I am exiting my loop though. Thanks for reading.
entity smoother is
Port(smoother_clk, smoother_rst: In std_logic;
smoother_data_in: In std_logic_vector(8 downto 0);
smoother_data_out: Out std_logic_vector(75 downto 0));
end smoother;
architecture Behavioral of smoother is
SIGNAL zeros: integer;
SIGNAL smoothed: std_logic;
SIGNAL smoother_shift: std_logic_vector(75 downto 0);
begin
Process(smoother_data_in, zeros, smoothed, smoother_shift, smoother_clk, smoother_rst)
variable count: Integer Range 0 to 8;
Begin
If (smoother_rst ='0') then
smoother_data_out <= x"0000000000000000000";
elsif (smoother_clk'EVENT and smoother_clk='1') THEN
count := 0;
FOR i IN smoother_data_in'Range LOOP
CASE smoother_data_in(i) IS
WHEN '0' => count := count + 1;
WHEN Others => count := count;
End Case;
End Loop;
zeros <= count;
If zeros >= 5 then
smoothed <= '0';
else
smoothed <= '1';
end if;
smoother_shift <= smoother_shift(74 downto 0) & smoothed;
end if;
smoother_data_out <= smoother_shift;
End Process;
end Behavioral;
|