root/ossiedev/branches/mcarrick/VHDL/carry_lookahead_adder/carry_lookahead_adder_logic.vhd @ 8216

Revision 8216, 1.3 KB (checked in by mcarrick, 5 years ago)

initial check in of CLA

Line 
1-- Carry Look Ahead Logic
2--
3-- This implements the carry look head logic for the
4-- carry look ahead adder. The minimum requirement
5-- for the number of bits is 2.
6--
7
8library ieee;
9use ieee.std_logic_1164.all;
10
11entity carry_lookahead_logic is
12        generic (       numBits : integer := 4
13        );
14        port (  p               : in    std_logic_vector(numBits-1 downto 0);
15                        g               : in    std_logic_vector(numBits-1 downto 0);
16                        cIn             : in    std_logic;
17                        c               : out   std_logic_vector(numBits-1 downto 0)
18        );
19end entity carry_lookahead_logic;
20
21architecture carry_lookahead_logic_behav of carry_lookahead_logic is
22
23        -- internal signal for carry values
24        signal carry : std_logic_vector(numBits-1 downto 0);
25
26        begin
27
28                -- determine if numBits is large enough
29                valid_numBits : if (numBits > 1) generate
30
31                        -- calculate all of the carry signals
32                        calculate_carry : for i in 0 to numBits-1 generate
33
34                                -- case for first signal
35                                first_carry : if (i = 0) generate
36                                begin
37                                        carry(i) <= g(i) or (p(i) and cIn);
38                                end generate first_carry;
39                               
40                                -- case for other carries
41                                other_carries : if (i > 0) generate
42                                begin
43                                        carry(i) <= g(i) or (p(i) and carry(i-1));
44                                end generate other_carries;
45
46                        end generate calculate_carry;
47
48                end generate valid_numBits;
49
50                -- assign output value
51                c <= carry;
52
53
54
55end architecture carry_lookahead_logic_behav;
56
57
58
59
60
61
Note: See TracBrowser for help on using the browser.