"loop" to create N instances of a component?

V

vax9000

Guest
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
 
vax9000 wrote:
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
 
On 4 Dec 2005 17:45:47 -0800, "vax9000" <VAX9000@gmail.com> wrote:

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;
 
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:Jim@SynthWorks.com
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

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


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
 

Welcome to EDABoard.com

Sponsor

Back
Top