1 |
2 |
ameziti |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Company:
|
3 |
|
|
--
|
4 |
|
|
-- File: cp_CLAAdder.vhd
|
5 |
|
|
--
|
6 |
|
|
-- Description:
|
7 |
|
|
-- projet copyblaze
|
8 |
|
|
-- carry look-ahead adder by recursively expanding the carry term to each stage
|
9 |
|
|
--
|
10 |
|
|
-- File history:
|
11 |
|
|
-- v1.0: 14/10/11: Creation
|
12 |
|
|
--
|
13 |
|
|
-- Targeted device: ProAsic A3P250 VQFP100
|
14 |
|
|
-- Author: AbdAllah Meziti
|
15 |
|
|
--------------------------------------------------------------------------------
|
16 |
|
|
|
17 |
|
|
library ieee;
|
18 |
|
|
use ieee.std_logic_1164.all;
|
19 |
|
|
use ieee.numeric_std.all;
|
20 |
|
|
|
21 |
|
|
use work.Usefull_Pkg.all; -- Usefull Package
|
22 |
|
|
|
23 |
|
|
--------------------------------------------------------------------------------
|
24 |
|
|
-- Entity: cp_CLAAdder
|
25 |
|
|
--
|
26 |
|
|
-- Description:
|
27 |
|
|
--
|
28 |
|
|
-- REMARQUE:
|
29 |
|
|
--
|
30 |
|
|
--
|
31 |
|
|
-- History:
|
32 |
|
|
-- 14/10/11 AM: Creation
|
33 |
|
|
-- ---------------------
|
34 |
|
|
-- xx/xx/xx AM:
|
35 |
|
|
--
|
36 |
|
|
--------------------------------------------------------------------------------
|
37 |
|
|
entity cp_CLAAdder is
|
38 |
|
|
generic
|
39 |
|
|
(
|
40 |
|
|
GEN_WIDTH_DATA : positive := 8
|
41 |
|
|
);
|
42 |
|
|
port (
|
43 |
|
|
--------------------------------------------------------------------------------
|
44 |
|
|
-- Signaux Fonctionels
|
45 |
|
|
--------------------------------------------------------------------------------
|
46 |
|
|
CarryIn_i : in std_ulogic;
|
47 |
|
|
sX_i : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
48 |
|
|
sY_i : in std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
|
49 |
|
|
|
50 |
|
|
CarryOut_o : out std_ulogic;
|
51 |
|
|
Result_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0)
|
52 |
|
|
);
|
53 |
|
|
end cp_CLAAdder;
|
54 |
|
|
|
55 |
|
|
--------------------------------------------------------------------------------
|
56 |
|
|
-- Architecture: RTL
|
57 |
|
|
-- of entity : cp_CLAAdder
|
58 |
|
|
--------------------------------------------------------------------------------
|
59 |
|
|
architecture rtl of cp_CLAAdder is
|
60 |
|
|
|
61 |
|
|
--------------------------------------------------------------------------------
|
62 |
|
|
-- Définition des fonctions
|
63 |
|
|
--------------------------------------------------------------------------------
|
64 |
|
|
|
65 |
|
|
--------------------------------------------------------------------------------
|
66 |
|
|
-- Définition des constantes
|
67 |
|
|
--------------------------------------------------------------------------------
|
68 |
|
|
|
69 |
|
|
--------------------------------------------------------------------------------
|
70 |
|
|
-- Définition des signaux interne
|
71 |
|
|
--------------------------------------------------------------------------------
|
72 |
|
|
signal iCarry: std_ulogic_vector (GEN_WIDTH_DATA downto 0);
|
73 |
|
|
|
74 |
|
|
--------------------------------------------------------------------------------
|
75 |
|
|
-- Déclaration des composants
|
76 |
|
|
--------------------------------------------------------------------------------
|
77 |
|
|
component cp_FullAdder
|
78 |
|
|
port (
|
79 |
|
|
--------------------------------------------------------------------------------
|
80 |
|
|
-- Signaux Fonctionels
|
81 |
|
|
--------------------------------------------------------------------------------
|
82 |
|
|
Ci_i : in std_ulogic;
|
83 |
|
|
A_i : in std_ulogic;
|
84 |
|
|
B_i : in std_ulogic;
|
85 |
|
|
|
86 |
|
|
Co_o : out std_ulogic;
|
87 |
|
|
S_o : out std_ulogic
|
88 |
|
|
);
|
89 |
|
|
end component;
|
90 |
|
|
|
91 |
|
|
begin
|
92 |
|
|
|
93 |
|
|
--------------------------------------------------------------------------------
|
94 |
|
|
-- Full adder
|
95 |
|
|
--------------------------------------------------------------------------------
|
96 |
|
|
Adder_Gen: for i in 0 to GEN_WIDTH_DATA-1 generate
|
97 |
|
|
|
98 |
|
|
U_FullAdder : cp_FullAdder
|
99 |
|
|
port map(
|
100 |
|
|
--------------------------------------------------------------------------------
|
101 |
|
|
-- Signaux Fonctionels
|
102 |
|
|
--------------------------------------------------------------------------------
|
103 |
|
|
Ci_i => iCarry(i) ,
|
104 |
|
|
A_i => sX_i(i) ,
|
105 |
|
|
B_i => sY_i(i) ,
|
106 |
|
|
|
107 |
|
|
Co_o => iCarry(i+1) ,
|
108 |
|
|
S_o => Result_o(i)
|
109 |
|
|
);
|
110 |
|
|
end generate Adder_Gen;
|
111 |
|
|
|
112 |
|
|
iCarry(0) <= CarryIn_i;
|
113 |
|
|
CarryOut_o <= iCarry(GEN_WIDTH_DATA);
|
114 |
|
|
|
115 |
|
|
end rtl;
|
116 |
|
|
|