Forum Discussion

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

One Register of an array will not reset

I've created a register array (8x9) in VHDL and I'm resetting registers 6-0 in one process and register 7 in another. The problem is register 7 is not being recognized as getting reset and this causes the compiler to optimize all the registers out. ModelSim shows the problem so I'm sure the problem is controlling the contents of register 7 but I can't see the problem in the code. I've reduced the code to the absolute minimum below. Any thoughts would be appreciated.

Thanks


 library IEEE;use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Entity FIFO_TEMP is port(
    DATA_IN:        in        STD_LOGIC_VECTOR(8 downto 0);
    DATA_OUT:    out    STD_LOGIC_VECTOR(8 downto 0);
--    WORD_RDY:    out     STD_LOGIC;
--    FIFO_FULL:    out    STD_LOGIC;
--    WORD_RD:        in        STD_LOGIC;
--    WORD_WR:        in        STD_LOGIC;
    RESET_N:        in        STD_LOGIC;
    SYS_CLK:        in        STD_LOGIC);
end FIFO_TEMP;
Architecture FIFOXN of FIFO_TEMP is 
    type Register_Array is array(7 downto 0) of STD_LOGIC_VECTOR(8 downto 0);
    signal    Fifo: Register_Array;
    signal    New_Word:    STD_LOGIC_VECTOR(2 downto 0);
    signal    Wd_Latch:    STD_LOGIC;
Begin
    process(SYS_CLK, Fifo, RESET_N) 
    begin
        if RESET_N ='0' then
            for i in 6 downto 0 loop
                Fifo(i) <= (others =>'0');
            end loop;
            New_Word <= "111";
        end if;        
    end process;
    process (SYS_CLK, RESET_N, Fifo)
    begin
        if RESET_N ='0' then
            Fifo(7) <="000000000";
            Wd_Latch <= '0';
        end if;
    end process;
end FIFOXN;

13 Replies

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

    Regarding my post above:

    ... I also had some elements of the array in one process with the other elements of the array in another process. When the elements in one of the processes were updated, the elements in the other process were updated incorrectly. When I showed this to Modelsim they believed that it was a Modelsim bug. However, their VHDL language expert told me that, based on the VHDL LRM, in a "For Loop when there is an array with a variable for an index, Modelsim initializes all elements of the array including elements that are not described in the process". This may possibly have changed with VHDL 2008.

    This is not a Modelsim bug. It is, unfortunately, specified in the VHDL LRM. I do not remember which part of the VHDL LRM it is in.

    The reason it is in the VHDL LRM, according to the Modelsim VHDL language expert, is in case the computation for the indices of the array are extremely complex, this would reduce the time required for initialization.

    I consider this to be a serious problem with the language specification. This may have been with VHDL 1993. I do not know if it is in VHDL 2008. If there is a VHDL LRM expert reading this please comment on it.

    Anyway, this issue is only when the signal array is within a For loop that only specifies some of the elements of the array.

    This issue does not occur when using a Generate statement rather than the For loop.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I do not remember which part of the VHDL LRM it is in.

    --- Quote End ---

    Too bad. But the statement doesn't sound plausible at first sight according to my knowledge of the VHDL specification. So unless somebody can confirm this, I tend to assume a Modelsim bug for the time being.

    Thanks so far.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I have always understood it that a complex signal (like an array or record) must have ALL of it's elements updated in a single process. Otherwise it counts as multiple driver errors. Similar discussions have come up on comp.lang.vhdl previously and, IIRC, the LRM says that any process that drives a single element implicitly drives the other elements too.

    A generate is different because a generate does not drive anything, it just defines connectivity.