Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17255 Discussions

Generic component inside generic component

Altera_Forum
Honored Contributor II
1,898 Views

Hello.I am designing a vhdl code that has a generic size setting a bunch of operations.I cannot synthetize it with quartus (Error (10346): VHDL error at mac.vhd(7): formal port or parameter "width" must have actual or default value), but I am able to compile with modelsim.My question is, can I put a generic component inside another? If dont, how should I proceed? 

 

entity mac is 

generic

width : integer); -- QUARTUS POINTS HERE 

port

clk : instd_logic

rst : instd_logic

a_i : instd_logic_vector(width-1downto0); 

b_i : instd_logic_vector(width-1downto0); 

acc : instd_logic_vector(2*width-1downto0); 

out_o : outstd_logic_vector(2*width-1downto0

); 

end mac; 

 

 

architecture bhv of mac is 

component mul 

generic

W_g : integer); 

port

clk : instd_logic

rst : instd_logic

a_i : instd_logic_vector(W_g-1downto0); 

b_i : instd_logic_vector(W_g-1downto0); 

outm_o : outstd_logic_vector(2*W_g-1downto0

); 

endcomponent

 

component soma 

generic

W_gs : integer); 

port

clk : instd_logic

rst : instd_logic

outm_o : instd_logic_vector(2*W_gs-1downto0); 

acc : instd_logic_vector(2*W_gs-1downto0); 

outs_o : outstd_logic_vector(2*W_gs-1downto0

); 

endcomponent;
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,113 Views

You can put generics anywhere you like. The error is due to the fact you did not assign a value anywhere. Modelsim would have produced the same error had you tried to elaborate the design. 

 

You can set generics using Quartus and Modelsim commands, however, you can also set a default value in your design, eg, 

 

generic ( width : integer := 8 );  

 

The width generic can then be overridden in Modelsim using vsim option -gwidth=16, and in Quartus via the set_parameter Tcl command (or using the GUI). 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,113 Views

Value of width is provided by another entity. 

I found what was wrong. I didnt knew i have to set the top level entity. 

But thanks =D
0 Kudos
Altera_Forum
Honored Contributor II
1,113 Views

 

--- Quote Start ---  

Value of width is provided by another entity. 

--- Quote End ---  

 

 

Right, but the error was because the component MAC did not have a value set. 

 

 

--- Quote Start ---  

I didn't knew i have to set the top level entity. 

--- Quote End ---  

 

 

Ah, I see, you accidentally had MAC as the top-level component. 

 

I have got into the habit of putting default values in the entity/architecture file so that I can run a synthesis check, and then deleting them on the component definition in a package, so that I don't forget to put the generics on the component when I instantiate it. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,113 Views

No, the error was because the component MAC get its value from another entity, a top-level one. 

 

 

Thanks for the hint
0 Kudos
Altera_Forum
Honored Contributor II
1,113 Views

 

--- Quote Start ---  

No, the error was because the component MAC get its value from another entity, a top-level one. 

--- Quote End ---  

 

 

Ok, you didn't put the generic map on the component when you instantiated it. 

 

It sounds like you've got things sorted out now. 

 

Note that if you have a generic (or a port) that would normally take on a specific value, then in your component definition, you can supply a value, and then that value will be used if you do not list that generic (or port) in the generic map. 

 

Cheers, 

Dave
0 Kudos
Reply