n bit adder

L

Lilmiss

Hi,
The question is to write VHDL code for an n-bit incrementor circuit.
Could you provide any suggestions
for improving my code?


Generate:

library IEEE;
use IEEE.STD_LOGIC_1164.all;


Entity incrementer_st is
generic(width : positive);
port(A : in std_logic_vector (width-1 downto 0) ;
C0 : in std_logic;
Cn : out std_logic;
S : out std_logic_vector(width-1 downto 0));
End incrementer_st;



architecture incrementer_st of incrementer_st is
component incrementer
port ( A : in STD_LOGIC;
Cin : in STD_LOGIC;
S : out STD_LOGIC;
Cout : out STD_LOGIC);
end component;
signal C : std_logic_vector(0 to width);
begin
g1 : for b in 0 to width-1 generate
U1: incrementer port map(A=>A(b), Cin=> C(b), S=>S(b), Cout=>C(b+1));
end generate;

C(0) <= C0;
Cn <= C(width);
end incrementer_st;


--Also, could you clarify the difference between generic and generate
statements (silly question I know)

10x
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top