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 2

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

Line No. Rev Author Line
1 2 JonasDC
------------------------------------------------------------------------------------ 
2
--                      
3
-- Geoffrey Ottoy - DraMCo research group
4
--
5
-- Module Name: adder_block.vhd / entity adder_block
6
-- 
7
-- Last Modified:       25/11/2011 
8
-- 
9
-- Description:         adder block for use in the montgommery multiplier pre- and post-
10
--                                              computation adders
11
--
12
--
13
-- Dependencies:        cell_1b_adder,
14
--                                              d_flip_flop
15
--
16
-- Revision:
17
--      Revision 1.00 - Architecture
18
--      Revision 0.01 - File Created
19
--
20
--
21
------------------------------------------------------------------------------------
22
--
23
-- NOTICE:
24
--
25
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
26
-- by other third parties!
27
--
28
------------------------------------------------------------------------------------
29
library IEEE;
30
use IEEE.STD_LOGIC_1164.ALL;
31
use IEEE.STD_LOGIC_ARITH.ALL;
32
use IEEE.STD_LOGIC_UNSIGNED.ALL;
33
 
34
---- Uncomment the following library declaration if instantiating
35
---- any Xilinx primitives in this code.
36
--library UNISIM;
37
--use UNISIM.VComponents.all;
38
 
39
entity adder_block is
40
        generic ( width : integer := 32
41
        );
42
   Port ( core_clk : in STD_LOGIC;
43
                          a : in  STD_LOGIC_VECTOR((width-1) downto 0);
44
           b : in  STD_LOGIC_VECTOR((width-1) downto 0);
45
                          cin : in STD_LOGIC;
46
                          cout : out STD_LOGIC;
47
           s : out  STD_LOGIC_VECTOR((width-1) downto 0)
48
        );
49
end adder_block;
50
 
51
architecture Structural of adder_block is
52
        component cell_1b_adder
53
                 Port ( a : in  STD_LOGIC;
54
                                  mux_result : in  STD_LOGIC;
55
                                  cin : in  STD_LOGIC;
56
                                  cout : out  STD_LOGIC;
57
                                  r : out  STD_LOGIC);
58
        end component;
59
 
60
        component d_flip_flop
61
   port(core_clk : in  STD_LOGIC;
62
                          reset : in  STD_LOGIC;
63
                            din : in  STD_LOGIC;
64
                      dout : out STD_LOGIC
65
        );
66
        end component;
67
 
68
        signal carry : std_logic_vector(width downto 0);
69
begin
70
 
71
        carry(0) <= cin;
72
 
73
        adder_chain: for i in 0 to (width-1) generate
74
                adders: cell_1b_adder
75
                port map(a => a(i),
76
                                        mux_result => b(i),
77
                                        cin => carry(i),
78
                                        cout => carry(i+1),
79
                                        r => s(i)
80
                );
81
        end generate;
82
 
83
        delay_1_cycle: d_flip_flop
84
   port map(core_clk => core_clk,
85
                          reset => '0',
86
                            din => carry(width),
87
                      dout => cout
88
        );
89
 
90
end Structural;

powered by: WebSVN 2.1.0

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