Initializing an array of records in VHDL

I have an entry 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 tried the following method and it does not work.

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

Kindly help.

+7
arrays signals vhdl records
source share
2 answers

As the comment says, ModelSim works when compiling code from a question with ModelSim. However, other tools may be more restrictive regarding the use of a typed value for elements in Array_ifx_t .

For the typed purpose and use of the named record elements, which I think gives a getter overview and avoids positional reference errors, you can do 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); 
+7
source share

My initial reaction to looking at the aggregate in your default for pair_in was that there were too many "others", so I wrote one myself using the post type declaration itself:

 library ieee; use ieee.std_logic_1164.all; package some_record is 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; -- positional association in an aggregate used for initialization: signal pair_in: ifx_t := ((others => '0'), (others => '0'),'0','0'); end package; 

And it has been successfully analyzed. The unit has two types of association: positional or named. The above expression is positional by default. With a named association:

 signal pair_in: ifx_t := -- named association of record elements: ( data => (others => '0'), address => (others =>'0'), WrReq => '0', RdReq => '0' ); 

You will notice that this bears a supernatural resemblance to the value expression found in the declaration of the Morten constant declaration, and actually tells the compatibility history for the total expression.

A record type compatible aggregate contains a value expression that is compatible with each record type element. This is done for the data and addresses of the array elements, providing aggregates for the default values, while WrReq and RdReq are directly provided with default values.

An additional instruction found in the original attempt would be appropriate if pair_in was a composite type consisting of an array consisting of elements of the ifx_t record ifx_t .

LRM (for example, IEEE Std 1076-1993) has a section "Expressions", a subsection "Aggregates" with an additional subdivision "Aggregates recording".

There is also a section called “Types”, a subsection “Composite types”, with an additional division “Types of records”.

+2
source share

All Articles