Initializing an array of records in VHDL

mohit picture mohit · Dec 17, 2013 · Viewed 31k times · Source

I have an record defined as follows

type ifx_t is
record
  data                        : std_logic_vector(127 downto 0);
  address                     : std_logic_vector (19 downto 0); 
  WrReq                       : std_logic;-- 
  RdReq                       : std_logic; --
end record;
type Array_ifx_t is array (0 to 2) of ifx_t;

And I have to initialize an instance of this array of records and I have tried the following way and it doesn't work

signal pair_in       : Array_ifx_t:= (others =>((others =>'0'),(others=>'0'),'0','0')); 

Kindly help.

Answer

Morten Zilmer picture Morten Zilmer · Dec 17, 2013

As said in the comment, ModelSim work when compiling the code from question with ModelSim. However, other tools may be more strict about using a typed value for elements in Array_ifx_t.

For a typed assign and use of named record elements, which I think gives getter overview and avoid mistakes by position references, you can make the initialization with:

constant IFX_T_0S : ifx_t := (data => (others =>'0'),
                              address => (others=>'0'),
                              WrReq => '0',
                              RdReq => '0');

signal pair_in : Array_ifx_t:= (others => IFX_T_0S);