How to make generics depending on generics?

How to make generics depending on generics?

par Marc Bernard René Gay-Balmaz,
Nombre de réponses : 4

Hi!

I need in the project to create a design with generics that depend themselves on generics (the first one is the number of elements in the second), but it doesn't work.

I searched for a solution and found that thread: https://electronics.stackexchange.com/questions/461259/vhdl-use-a-type-dependent-on-entity-generics-for-other-entity-ports-generics
that suggested a solution. I tried to apply that solution but it doesn't work. Do you know if maybe it is not supported by quartus? (As it is an addition of VHDL 2008)
Or do you have a suggestion of an other way to do that?

If needed, here is the problematic code:
component neuron is
generic(
entry_nb : natural;
seeds : seeds_t(entry_nb -1 downto 0)(inner_weight_size - 1 downto 0)
);
port(
inputs : in std_logic_vector(entry_nb - 1 downto 0);
weights : in wheights_t(entry_nb - 1 downto 0);
weights_en : in std_logic_vector(entry_nb - 1 downto 0);

clk : in std_logic;
rst : in std_logic;

result : out std_logic
);
end component;

Thanks in advance for your help!

En réponse à Marc Bernard René Gay-Balmaz

Re: How to make generics depending on generics?

par René Beuchat,

Hello,

yes it is possible of passing generic, but they need to be known at compile time. No dynamic creation available.

If you need VHDL2008, you need to activate it and to have the version with licence activated (1719@lamipc54.epfl.ch, with the VPN).

By default, the VHDL 1993 is activated.

Assignements--> Settings --> Complier Inputs --> clic VHDL 2008



Good luck

RB

En réponse à René Beuchat

Re: How to make generics depending on generics?

par René Beuchat,

Question: where the seed_t is defined?

You want to pass an entire matrix as a generic? not as an input port?

RB

En réponse à René Beuchat

Re: How to make generics depending on generics?

par Marc Bernard René Gay-Balmaz,

seed_t is defined in a package I made, here is the definition if needed:


subtype inner_seed_st is std_logic_vector;
type seeds_t is array (natural range<>) of std_logic_vector;
type seeds_array_t is array (natural range<>) of seeds_t;

And yes, I would like to do that as it is used only to give initial values to pseudo random generators, so only needed at the start of the system, I am affraid that the FPGA may already be a bit full with all the neurons I try to fit in to add the seeds somewhere on the board

En réponse à René Beuchat

Re: How to make generics depending on generics?

par Marc Bernard René Gay-Balmaz,

Thanks for that fast answer !
It seems to works better with quartus but it seems that the change didn't affect the VHDL version of qsys, and thus qsys doesn't succeed in analysing the component. Do you know how to handle that? (is there a way to set the VHDL version in QSys or should I write the file that should be generated by hand?)

It seems that I could select the right version of VHDL, but I am working on the VM so I guess it has already been activated :)

If needed, here are the errors I get : 


I now get the error "Error (12006): Node instance "nn_controller_0" instantiates undefined entity "new_component". " If I try to compile directly from quartus.

And the error "Error: VHDL Type Declaration error at my_neural_pack.vhd(19): element type for array type cannot be unconstrained". " If I run the analysis from QSys