- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need to instantiate the same module many times, so I'm using a for-generate loop. Each time, however, I've to pass to the module a different file name as a GENERIC to initialize a rom inside the module. The file name is function of the i parameter in the generate loop ... so I wrote this code in quartus (vhdl 2008) but I get errors ... can you help to write it in the right way ? ENGINES : -- engine instantiation for i in 0 to ENGINES_NUMBER-1 generate variable mystringnumber: string (1 to 4); variable romfile: string (1 to 30); begin mystringnumber := (to_string(i)); romfile := ("./roms/weight_lay0_engine" & mystringnumber & ".hex"); ENGINE_inst : entity work.engine GENERIC MAP (ENGINE_WEIGHT_FILE => romfile) PORT MAP (CLOCK => CLOCK, RESET => RESET, HITDATA => HITDATA, ACC => ACC_ENG(i), INTER_X => ENGINE1_INTER_X, INTER_Y => ENGINE1_INTER_Y); end generate ENGINES; thanks francoLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the string values need to be a constant. So you need to decalre romfile as such. The bast way would be:
constant romfile : string := "./roms/weight_lay0_engine" & integer'image(i) & ".hex"; and put this before the begin like you have done with the variables; you cannot put variables where you have them - you can only use variables inside processes, functions and procedures. You dont need to declare the length of the string because it's implicitly declared with the length of the declaration. You could use the to_string function instead of integer'image, but Quartus doesnt support them yet (but modelsim does).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi tricky thanks a lot, it works perfectly
thanks again franco
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