I use this ENTITY :
ENTITY SPI_PT100 IS
GENERIC
(
PT100_DATA_SIZE : INTEGER := 8; --nombre de data à envoyer par trame
PT100_NB_MOSI : INTEGER := 3; --nombre de ligne MOSI
PT100_10ms_CNT : INTEGER := 400000; --nb tick in_clk entre deux trames (défaut 10ms @ 40Mhz)
PT100_500ns_CNT : INTEGER := 20 --nb de tick in_clk entre deux changement d'état sur SCLK (1/2 periode) (défaut : sclk = 1Mhz)
);
PORT
(
--input
in_clk : IN STD_LOGIC; --40Mhz
in_data : IN STD_LOGIC_VECTOR((PT100_DATA_SIZE-1) DOWNTO 0); --data à envoyer
--output
out_spi_sclk : OUT STD_LOGIC := '0'; --clk du SPI
out_spi_u_sync : OUT STD_LOGIC := '1'; -- u_sync du SPI
out_spi_mosi : OUT STD_LOGIC := '0' -- mosi du SPI
);
END ENTITY;
I want to use PT100_NB_MOSI as a generic multiaray size :
in_data : IN STD_LOGIC_VECTOR((PT100_DATA_SIZE-1) DOWNTO 0); ==>
in_data : IN STD_LOGIC_VECTOR((PT100_NB_MOSI-1) DOWNTO 0)) OF ((PT100_DATA_SIZE-1) DOWNTO 0);
I know that I can do it using a type or a subtype but in this case I think I must use a package. Is there a solution using only GENERIC mechanism ?
Unfortunately not. What you can do is use a one-dimensional vector:
in_data : IN STD_LOGIC_VECTOR((PT100_NB_MOSI*PT100_DATA_SIZE-1) DOWNTO 0);
And access in_data(i*PT100_DATA_SIZE+j) for accessing the (i, j) array element.
Else, you have to declare it in a package file as an array:
type my_arr is array(natural range <>) of std_logic_vector(PT100_DATA_SIZE-1 DOWNTO 0);
Then include the array: use work.my_pkg.my_arr; (or use work.my_pkg.all; for the whole package) and use it in the interface:
in_data : IN my_arr((PT100_NB_MOSI-1) DOWNTO 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With