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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [core/] [adder_block.vhd] - Blame information for rev 9

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

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

powered by: WebSVN 2.1.0

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