- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, the error was because the component MAC get its value from another entity, a top-level one.
Thanks for the hint- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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

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