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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [tags/] [start_version/] [rtl/] [vhdl/] [core/] [adder_n.vhd] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 JonasDC
---------------------------------------------------------------------- 
2
----                                                              ---- 
3
----  adder_n.vhd                                                 ---- 
4
----                                                              ---- 
5
----  This file is part of the                                    ----
6
----    Modular Simultaneous Exponentiation Core project          ---- 
7
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
8
----                                                              ---- 
9
----  Description                                                 ---- 
10
----    This file contains the implementation of a n-bit adder    ----
11
----    using the adder blocks.                                   ----
12
----    used as the montgommery multiplier pre- and post-         ----
13
----    computation adder                                         ---- 
14
----                                                              ---- 
15
----  Dependencies:                                               ---- 
16
----   - adder_block                                              ---- 
17
----                                                              ---- 
18
----  Author(s):                                                  ----
19
----      - Geoffrey Ottoy, DraMCo research group                 ----
20
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
21
----                                                              ---- 
22
---------------------------------------------------------------------- 
23
----                                                              ---- 
24
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
25
----                                                              ---- 
26
---- This source file may be used and distributed without         ---- 
27
---- restriction provided that this copyright statement is not    ---- 
28
---- removed from the file and that any derivative work contains  ---- 
29
---- the original copyright notice and the associated disclaimer. ---- 
30
----                                                              ---- 
31
---- This source file is free software; you can redistribute it   ---- 
32
---- and/or modify it under the terms of the GNU Lesser General   ---- 
33
---- Public License as published by the Free Software Foundation; ---- 
34
---- either version 2.1 of the License, or (at your option) any   ---- 
35
---- later version.                                               ---- 
36
----                                                              ---- 
37
---- This source is distributed in the hope that it will be       ---- 
38
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
39
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
40
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
41
---- details.                                                     ---- 
42
----                                                              ---- 
43
---- You should have received a copy of the GNU Lesser General    ---- 
44
---- Public License along with this source; if not, download it   ---- 
45
---- from http://www.opencores.org/lgpl.shtml                     ---- 
46
----                                                              ---- 
47
----------------------------------------------------------------------
48
 
49
library IEEE;
50
use IEEE.STD_LOGIC_1164.ALL;
51
use IEEE.STD_LOGIC_ARITH.ALL;
52
use IEEE.STD_LOGIC_UNSIGNED.ALL;
53
 
54
---- Uncomment the following library declaration if instantiating
55
---- any Xilinx primitives in this code.
56
--library UNISIM;
57
--use UNISIM.VComponents.all;
58
 
59
entity adder_n is
60
        generic ( width : integer := 1536;
61
                block_width : integer := 8
62
        );
63
   Port ( core_clk : in STD_LOGIC;
64
                          a : in  STD_LOGIC_VECTOR((width-1) downto 0);
65
           b : in  STD_LOGIC_VECTOR((width-1) downto 0);
66
                          cin : in STD_LOGIC;
67
                          cout : out STD_LOGIC;
68
           s : out  STD_LOGIC_VECTOR((width-1) downto 0)
69
        );
70
end adder_n;
71
 
72
architecture Structural of adder_n is
73
        component adder_block
74
        generic ( width : integer := 32
75
        );
76
   Port ( core_clk : in STD_LOGIC;
77
                          a : in  STD_LOGIC_VECTOR((width-1) downto 0);
78
           b : in  STD_LOGIC_VECTOR((width-1) downto 0);
79
                          cin : in STD_LOGIC;
80
                          cout : out STD_LOGIC;
81
           s : out  STD_LOGIC_VECTOR((width-1) downto 0)
82
        );
83
        end component;
84
 
85
        constant nr_of_blocks : integer := width/block_width;
86
        signal carry : std_logic_vector(nr_of_blocks downto 0);
87
begin
88
 
89
        carry(0) <= cin;
90
 
91
        adder_block_chain: for i in 0 to (nr_of_blocks-1) generate
92
                adder_blocks: adder_block
93
                generic map( width => block_width
94
                )
95
                port map( core_clk => core_clk,
96
                                        a => a((((i+1)*block_width)-1) downto (i*block_width)),
97
                                        b => b((((i+1)*block_width)-1) downto (i*block_width)),
98
                                        cin => carry(i),
99
                                        cout => carry(i+1),
100
                                        s => s((((i+1)*block_width)-1) downto (i*block_width))
101
                );
102
        end generate;
103
 
104
        cout <= carry(nr_of_blocks);
105
 
106
end Structural;

powered by: WebSVN 2.1.0

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