------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
--
|
--
|
-- Geoffrey Ottoy - DraMCo research group
|
-- Geoffrey Ottoy - DraMCo research group
|
--
|
--
|
-- Module Name: adder_block.vhd / entity adder_block
|
-- Module Name: adder_block.vhd / entity adder_block
|
--
|
--
|
-- Last Modified: 25/11/2011
|
-- Last Modified: 25/11/2011
|
--
|
--
|
-- Description: adder block for use in the montgommery multiplier pre- and post-
|
-- Description: adder block for use in the montgommery multiplier pre- and post-
|
-- computation adders
|
-- computation adders
|
--
|
--
|
--
|
--
|
-- Dependencies: cell_1b_adder,
|
-- Dependencies: cell_1b_adder,
|
-- d_flip_flop
|
-- d_flip_flop
|
--
|
--
|
-- Revision:
|
-- Revision:
|
-- Revision 1.00 - Architecture
|
-- Revision 1.00 - Architecture
|
-- Revision 0.01 - File Created
|
-- Revision 0.01 - File Created
|
--
|
--
|
--
|
--
|
------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
--
|
--
|
-- NOTICE:
|
-- NOTICE:
|
--
|
--
|
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
|
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
|
-- by other third parties!
|
-- by other third parties!
|
--
|
--
|
------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
library IEEE;
|
library IEEE;
|
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_1164.ALL;
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|
|
---- Uncomment the following library declaration if instantiating
|
---- Uncomment the following library declaration if instantiating
|
---- any Xilinx primitives in this code.
|
---- any Xilinx primitives in this code.
|
--library UNISIM;
|
--library UNISIM;
|
--use UNISIM.VComponents.all;
|
--use UNISIM.VComponents.all;
|
|
|
entity adder_block is
|
entity adder_block is
|
generic ( width : integer := 32
|
generic ( width : integer := 32
|
);
|
);
|
Port ( core_clk : in STD_LOGIC;
|
Port ( core_clk : in STD_LOGIC;
|
a : in STD_LOGIC_VECTOR((width-1) downto 0);
|
a : in STD_LOGIC_VECTOR((width-1) downto 0);
|
b : in STD_LOGIC_VECTOR((width-1) downto 0);
|
b : in STD_LOGIC_VECTOR((width-1) downto 0);
|
cin : in STD_LOGIC;
|
cin : in STD_LOGIC;
|
cout : out STD_LOGIC;
|
cout : out STD_LOGIC;
|
s : out STD_LOGIC_VECTOR((width-1) downto 0)
|
s : out STD_LOGIC_VECTOR((width-1) downto 0)
|
);
|
);
|
end adder_block;
|
end adder_block;
|
|
|
architecture Structural of adder_block is
|
architecture Structural of adder_block is
|
component cell_1b_adder
|
component cell_1b_adder
|
Port ( a : in STD_LOGIC;
|
Port ( a : in STD_LOGIC;
|
mux_result : in STD_LOGIC;
|
mux_result : in STD_LOGIC;
|
cin : in STD_LOGIC;
|
cin : in STD_LOGIC;
|
cout : out STD_LOGIC;
|
cout : out STD_LOGIC;
|
r : out STD_LOGIC);
|
r : out STD_LOGIC);
|
end component;
|
end component;
|
|
|
component d_flip_flop
|
component d_flip_flop
|
port(core_clk : in STD_LOGIC;
|
port(core_clk : in STD_LOGIC;
|
reset : in STD_LOGIC;
|
reset : in STD_LOGIC;
|
din : in STD_LOGIC;
|
din : in STD_LOGIC;
|
dout : out STD_LOGIC
|
dout : out STD_LOGIC
|
);
|
);
|
end component;
|
end component;
|
|
|
signal carry : std_logic_vector(width downto 0);
|
signal carry : std_logic_vector(width downto 0);
|
begin
|
begin
|
|
|
carry(0) <= cin;
|
carry(0) <= cin;
|
|
|
adder_chain: for i in 0 to (width-1) generate
|
adder_chain: for i in 0 to (width-1) generate
|
adders: cell_1b_adder
|
adders: cell_1b_adder
|
port map(a => a(i),
|
port map(a => a(i),
|
mux_result => b(i),
|
mux_result => b(i),
|
cin => carry(i),
|
cin => carry(i),
|
cout => carry(i+1),
|
cout => carry(i+1),
|
r => s(i)
|
r => s(i)
|
);
|
);
|
end generate;
|
end generate;
|
|
|
delay_1_cycle: d_flip_flop
|
delay_1_cycle: d_flip_flop
|
port map(core_clk => core_clk,
|
port map(core_clk => core_clk,
|
reset => '0',
|
reset => '0',
|
din => carry(width),
|
din => carry(width),
|
dout => cout
|
dout => cout
|
);
|
);
|
|
|
|
|