OpenCores
URL https://opencores.org/ocsvn/hwlu/hwlu/trunk

Subversion Repositories hwlu

[/] [hwlu/] [trunk/] [rtl/] [vhdl/] [csa8.vhd] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kavi
----==============================================================----
2
----                                                              ----
3
---- Filename: csa8.vhd                                           ----
4
---- Module description: Top-level module of 8-bit carry-select   ----
5
----                     adder                                    ----
6
----                                                              ----
7
---- Author: Nikolaos Kavvadias                                   ----
8
----         nkavv@skiathos.physics.auth.gr                       ----
9
----                                                              ---- 
10
----                                                              ----
11
---- Downloaded from: http://wwww.opencores.org/cores/hwlu        ----
12
----                                                              ----
13
---- To Do:                                                       ----
14 4 kavi
----         Add a parameterized version of a fast adder          ---- 
15
----         (probably a carry select adder).                     ----
16 2 kavi
----                                                              ----
17
---- Author: Nikolaos Kavvadias                                   ----
18
----         nkavv@skiathos.physics.auth.gr                       ----
19
----                                                              ----
20
----==============================================================----
21
----                                                              ----
22
---- Copyright (C) 2004 Nikolaos Kavvadias                        ----
23
----                    nick-kavi.8m.com                          ----
24
----                    nkavv@skiathos.physics.auth.gr            ----
25
----                    nick_ka_vi@hotmail.com                    ----
26
----                                                              ----
27
---- This source file may be used and distributed without         ----
28
---- restriction provided that this copyright statement is not    ----
29
---- removed from the file and that any derivative work contains  ----
30
---- the original copyright notice and the associated disclaimer. ----
31
----                                                              ----
32
---- This source file is free software; you can redistribute it   ----
33
---- and/or modify it under the terms of the GNU Lesser General   ----
34
---- Public License as published by the Free Software Foundation; ----
35
---- either version 2.1 of the License, or (at your option) any   ----
36
---- later version.                                               ----
37
----                                                              ----
38
---- This source is distributed in the hope that it will be       ----
39
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
40
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
41
---- PURPOSE. See the GNU Lesser General Public License for more  ----
42
---- details.                                                     ----
43
----                                                              ----
44
---- You should have received a copy of the GNU Lesser General    ----
45
---- Public License along with this source; if not, download it   ----
46
---- from <http://www.opencores.org/lgpl.shtml>                   ----
47
----                                                              ----
48
----==============================================================----
49
--
50
-- CVS Revision History
51
--    
52
 
53
library IEEE;
54
use IEEE.std_logic_1164.all;
55
 
56
 
57
entity add is
58
  generic (
59
    DW : integer := 8
60
  );
61
  port (
62
    a   : in std_logic_vector(DW-1 downto 0);
63
    b   : in std_logic_vector(DW-1 downto 0);
64
    sum : out std_logic_vector(DW-1 downto 0)
65
  );
66
end add;
67
 
68
architecture structural of add is
69
-- Component declarations
70
component fa
71
  port (
72
    a  : in std_logic;
73
    b  : in std_logic;
74
    ci : in std_logic;
75
    s  : out std_logic;
76
    co : out std_logic
77
  );
78
end component;
79 4 kavi
--             
80 2 kavi
component mux2_1
81
  generic (
82
    DW : integer := 8
83
  );
84
  port (
85
    in0  : in std_logic_vector(DW-1 downto 0);
86
    in1  : in std_logic_vector(DW-1 downto 0);
87
    sel  : in std_logic;
88
        mout : out std_logic_vector(DW-1 downto 0)
89
  );
90
end component;
91 4 kavi
--                              
92
-- Constant declarations
93
constant zero_1b : std_logic := '0';
94
constant one_1b  : std_logic := '1';
95 2 kavi
--
96
-- Signal declarations
97
signal carry : std_logic_vector(4 downto 0);
98 4 kavi
signal c_up_ci0 : std_logic_vector(4 downto 0);
99
signal c_up_ci1 : std_logic_vector(4 downto 0);
100 2 kavi
signal s_up_ci0 : std_logic_vector(3 downto 0);
101
signal s_up_ci1 : std_logic_vector(3 downto 0);
102 4 kavi
--
103 2 kavi
begin
104
 
105
  carry(0) <= '0';
106
  --
107 4 kavi
 
108 2 kavi
  U_fa0_3_cells : for i in 0 to 3 generate
109
    U_fa : fa
110
      port map (
111
        a => a(i),
112
        b => b(i),
113
        ci => carry(i),
114
        s => sum(i),
115
        co => carry(i+1)
116
      );
117
  end generate U_fa0_3_cells;
118 4 kavi
 
119
  c_up_ci0(0) <= zero_1b;
120
  c_up_ci1(0) <= one_1b;
121 2 kavi
 
122
  U_fa4_7_ci0_cells : for i in 0 to 3 generate
123 4 kavi
    U_fa : fa
124 2 kavi
      port map (
125
        a => a(i+4),
126
        b => b(i+4),
127 4 kavi
        ci => c_up_ci0(i),
128
        s => s_up_ci0(i),
129
        co => c_up_ci0(i+1)
130 2 kavi
      );
131
  end generate U_fa4_7_ci0_cells;
132
 
133
  U_fa4_7_ci1_cells : for i in 0 to 3 generate
134 4 kavi
    U_fa : fa
135 2 kavi
      port map (
136
        a => a(i+4),
137
        b => b(i+4),
138 4 kavi
        ci => c_up_ci1(i),
139
        s => s_up_ci1(i),
140
        co => c_up_ci1(i+1)
141
      );
142 2 kavi
  end generate U_fa4_7_ci1_cells;
143 4 kavi
 
144
  U_mux_s_up : mux2_1
145
    generic map (
146
      DW => 4
147
    )
148
    port map (
149
      in0 => s_up_ci0(3 downto 0),
150
      in1 => s_up_ci1(3 downto 0),
151
      sel => carry(4),
152
      mout => sum(7 downto 4)
153
    );
154 2 kavi
 
155
end structural;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.