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

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I was just describing the situation why the "fin_add" never changes. At the beginning there is the code

    --- Quote Start ---

    process (init,add_en,num,used)

    begin

    fin_init<='0';

    fin_add<='0';

    --- Quote End ---

    and logically there should be a change of the fin_add after something changed in the sensivity list.

    But since the process exectution enters the IF branch - fin_add<='1' and only last assignment in the process takes place. Therefore he will not notice '0' assignment on the waveform.

    Thats true

    If his fin_add always = '1' this means that his process always enters to the branch there fin_add assigned '1'.

    The problem can be in the testbench.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Apart from the question, if the presented code as a whole has a reasonable operation (I said, why it can't in my opinion), the usage of fin_add and fin_init in the process is reasonable as such. But when the for loop iteration is translated to combinational code, these signals loose their original function. As uilka_b pointed out, they never change, respectively they are eliminated.