- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
i have written a VHDL Model wich is configured by a set of generics in the top level entity. The Ports of the model are always the same. No i want to give a number to every set of generics, and choose the generic set by only changing the number in the code. What is the right VHDL keyword? For example: Set# 1: Generic Map( gen1 := 17 gen2 := 22 gen3 := 14 .. .. ) Set# 2: Generic Map( gen1 := 1 gen2 := 4 gen3 := 12 .. .. ) Now i only want to change the set# to select the generics. Thanks in advance, paddyLink Copied
12 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If it is for a test bench, you can use VHDL configurations to override generic values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
could you please tell me how to use the configuration for the selection of a set of generics? I do not understand it in my vhdl book. Thanks, paddy- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The general approach is something like that:
configuration configuration_name of top_level_entity is
for architecture_name
for instance_label: component_name
use entity work.entity_name(architecture_name)
generic map (...);
end for;
...
end for;
end configuration_name;
This will change the generics in the instance_label instantiation of the component component_name. You can have several configurations with different names, and invoke the correct configuration when you launch the simulator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your fast response! I will try it.
Paddy- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IF .. GENERATE for the complete component instantian (not only the generic map) works for sure. CONSTANT ARRAY elements for the generic values may work too, but I didn't yet try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The IF GENERATE works, that is the solution i used before askink here. But there are 40 sets of generics, and i do not want to set the Port Map in every generate....So i am searching for a better solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- IF .. GENERATE for the complete component instantian (not only the generic map) works for sure. CONSTANT ARRAY elements for the generic values may work too, but I didn't yet try. --- Quote End --- This will work, but you will be instantiating the entity N times in parrallel. This is fine if you dont mind lots of them running at once (maybe thats the point) and can capture all of the output. But if you just want 1 running at a time in a testbench, you can use TCL. The VSIM command in modelsim has a -g option that allows you to set/override top level generics. You could put the generic list in a constant in a package, then have something like this:
entity my_TB is
generic (
..
GENERIC_SET : integer range my_TB_generics'range;
..
);
end entity my_TB
then using TCL you would start the testbench thus: VSIM my_TB -gGENERIC_SET=0 Now, because it is TCL you can do loops and things to control every combination of generics. Im not really that up to speed with TCL, but I have seen nice TCL files that allow to test every combination of generics using just a single function (you input all the different values for each generic and it would test every combination of all of them). PS. generic maps have to be mapped like port maps using => not :=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- The IF GENERATE works, that is the solution i used before askink here. But there are 40 sets of generics, and i do not want to set the Port Map in every generate....So i am searching for a better solution. --- Quote End --- you dont have to. If the port map is the same (like you say) you just do this:
my_ents_gen : for i in 0 to 39 generate
my_ent : my_entity
generic map (
gen0 => GENERICS(i)(0),
gen1 => GENERICS(i)(1),
gen2 => GENERICS(i)(2),
..etc
port map (
...
--Do 1 port map once
...
);
end generate my_ents_gen
you only write the code out once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, Im sorry. I did not exactly explain:
I only want to have 1 instance running at a time. So the entity is only used one time in the design. So i did it like this: ... CONSTANT genset : integer := 1; ... ent_inst1: IF genset = 1 GENERATE mymod : mod GENERIC MAP ( gen1 => 1, gen1 => 2, gen1 => 3, ..... ) PORT MAP ( ... ... ... ); END GENERATE ent_inst2: IF genset = 2 GENERATE mymod : mod GENERIC MAP ( gen1 => 17, gen1 => 21, gen1 => 13, ..... ) PORT MAP ( ... ... ... ); END GENERATE- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in that case theres no need for any generate loops, just what I proposed already:
either use an array of generics:
type generics_t is array(0 to n_generics-1) of integer;
type generics_array_t is array(1 to 40) of generics_t;
constant GENERICS_ARRAY : generics_array_t := ( (0,1,2),
(4,5,6),
--etc
);
....
--then in the code
entity top is
generic (
GENERIC_SEL : integer range GENERICS_ARRAY'range := 7
)
.......
some_ent : entity work.my_ent
generic map (
gen0 => GENERICS_ARRAY(GENERIC_SEL)(0),
gen1 => GENERICS_ARRAY(GENERIC_SEL)(1),
--etc
)
.....
or if you have a different type for each generic (and its neater anyway, use a record type:
type generics_t is
record
gen0 : integer;
gen1 : string;
gen2 : boolean;
end record generics_t;
type generics_array_t is array(1 to 40) of generics_t;
constant GENERICS_ARRAY : generics_array_t := ( (gen0 => 0, gen1 => "ZERO", gen2 => false), --combination 0
(gen0 => 1, gen1 => "ONE", gen2 => true), --combination 1
--etc
);
....
--then in the code
entity top is
generic (
GENERIC_SEL : integer range GENERICS_ARRAY'range := 7
)
.......
some_ent : entity work.my_ent
generic map (
gen0 => GENERICS_ARRAY(GENERIC_SEL).gen0,
gen1 => GENERICS_ARRAY(GENERIC_SEL).gen1,
--etc
)
.....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As said, you can use a constant array
TYPE GEN_ARRAY IS ARRAY (1 TO 6,1 TO 3) OF INTEGER;
CONSTANT gen : GEN_ARRAY :=
((2,3,3),
(1,2,4),
(2,2,1),
(1,3,4),
(1,5,4),
(2,2,5));
generic map
( gen1 =>gen(gen_sel,1), gen2 => gen(gen_sel,2))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
many thanks to all. I tried the solution with the "generic record" and it works very fine. Now i have defined all sets of generics in the array and select one by only changing the set#. Thats what i wanted!!! Thanks again Paddy
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page