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 12

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 12 JonasDC
----    Adder block with a flipflop for the carry out so result   ----
10
----    is available after 1 clock cycle                          ----
11 3 JonasDC
----    for use in the montgommery multiplier pre and post        ----
12
----    computation adders                                        ----
13
----                                                              ----
14
----  Dependencies:                                               ----
15
----    - cell_1b_adder                                           ----
16
----    - d_flip_flop                                             ----
17
----                                                              ---- 
18
----  Authors:                                                    ----
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 2 JonasDC
 
49 3 JonasDC
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.std_logic_arith.all;
52
use ieee.std_logic_unsigned.all;
53 2 JonasDC
 
54 3 JonasDC
library mod_sim_exp;
55
use mod_sim_exp.mod_sim_exp_pkg.all;
56
 
57 9 JonasDC
-- (width)-bit full adder block using cell_1b_adders
58 12 JonasDC
-- with buffered carry out -> result after 1 clock cycle
59 2 JonasDC
entity adder_block is
60 3 JonasDC
  generic (
61 9 JonasDC
    width : integer := 32 --adder operand widths
62 3 JonasDC
  );
63
  port (
64 9 JonasDC
    -- clock input
65
    core_clk : in std_logic;
66
    -- adder input operands a, b (width)-bit
67
    a : in std_logic_vector((width-1) downto 0);
68
    b : in std_logic_vector((width-1) downto 0);
69
    -- carry in, out
70
    cin   : in std_logic;
71
    cout  : out std_logic;
72
    -- adder result out (width)-bit
73
    r : out std_logic_vector((width-1) downto 0)
74 3 JonasDC
  );
75 2 JonasDC
end adder_block;
76
 
77 3 JonasDC
 
78 2 JonasDC
architecture Structural of adder_block is
79 12 JonasDC
  -- vector for the carry bits
80 3 JonasDC
  signal carry : std_logic_vector(width downto 0);
81 2 JonasDC
begin
82 9 JonasDC
  -- carry in
83 3 JonasDC
  carry(0) <= cin;
84
 
85 9 JonasDC
  -- structure of (width) cell_1b_adders
86 3 JonasDC
  adder_chain : for i in 0 to (width-1) generate
87
    adders : cell_1b_adder
88
    port map(
89 9 JonasDC
      a    => a(i),
90
      b    => b(i),
91
      cin  => carry(i),
92
      cout => carry(i+1),
93
      r    => r(i)
94 3 JonasDC
    );
95
  end generate;
96 9 JonasDC
 
97
  -- buffer the carry every clock cycle
98
  carry_reg : d_flip_flop
99 3 JonasDC
  port map(
100
    core_clk => core_clk,
101
    reset    => '0',
102
    din      => carry(width),
103
    dout     => cout
104
  );
105
 
106
end Structural;

powered by: WebSVN 2.1.0

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