"loop" to create N instances of a component?

V

vax9000

Hi group,
I am writing a small FIFO. I made a component with 8 registers (1
byte), then plan to concatenate N instances of this component to make
an N byte FIFO. The problem is that I may change the number N from time
to time, so the code needs to be flexible. Is there a way to use "loop"
to create the N instances? Thanks

vax, 9000
 
A

avishay

vax9000 said:
Hi group,
I am writing a small FIFO. I made a component with 8 registers (1
byte), then plan to concatenate N instances of this component to make
an N byte FIFO. The problem is that I may change the number N from time
to time, so the code needs to be flexible. Is there a way to use "loop"
to create the N instances? Thanks

vax, 9000

You can do it with FOR GENERATE. Here's an example:

a_label: FOR i IN 0 TO N-1 GENERATE
byte(i) <= byte(i+1) WHEN rising_edge(clk);
END GENERATE

Certainly, you have to deal with the first and the last registers
separately. Note that this is a concurrent statement - it is not inside
a process.

Avishay
 
Z

Zara

Hi group,
I am writing a small FIFO. I made a component with 8 registers (1
byte), then plan to concatenate N instances of this component to make
an N byte FIFO. The problem is that I may change the number N from time
to time, so the code needs to be flexible. Is there a way to use "loop"
to create the N instances? Thanks

vax, 9000


gen_N:for i in 0 to 7 generate
gen_i:whatever FIFO port map (
-- connnect your fifo...
);
end generate;
 
J

Jim Lewis

Homework?

Forget the loop. Use an array of an array.
You can index the outer dimension to read or
write randomly. You can use "&" to shift.
Size it using generics.

Read a good book, like J Bhasker, A VHDL Primer.

Cheers,
Jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top