Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

code problem

Hi, I am wring a mermory code, but the waveform is not correct. There is no change of fin_add, only when add_en='1' then add_en_next change. I think probable it is coz the used(num) never become zero. but I don't know this happen. my code is as folllow:

architecture behv of mry is

signal num,match_num:integer;

signal used:std_logic_vector(3 downto 0);--!

type CAM is array(0 to 3) of std_logic_vector(15 downto 0);

signal data_array: CAM;

begin

process (init,add_en,num,used)

begin

fin_init<='0';

fin_add<='0';

add_en_next<='0';

if init='1' then --init

used<=(others=>'0');

fin_init<='1';

elsif add_en='1' then ---add

for num in 0 to 3 loop

add_en_next<='1';

if used(num)='0' then ---cell is empty

add_en_next<='0';

used(num)<='1';

data_array(num)(15 downto 8)<=H_Dn;

data_array(num)(7 downto 0)<=H_GD;

fin_add<='1';

exit;

end if;

end loop;

end if;

end process;

end behv;

12 Replies