for generate

Joined
Jan 29, 2009
Messages
152
Reaction score
0
This is a (silly) example:
Code:
architecture structural of ADD4 is
  component FA is
    port(X, Y, Z : in std_logic;
         S, C : out std_logic);
  end component;
  signal C : std_logic_vector(4 downto 0);
begin
C(0) <= C0;
gen: for i in 0 to 3 generate
  ADD: FA port map(A(i),B(i),C(i),S(i),C(i + 1));
end generate gen;
C4 <= C(4);
end structural;

It gives a synthesizable 4-bit adder, given the correct FA (full-adder) component;
This isn't very serious code: You're likely to get better code using just the '+' operator.
 

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,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top