------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
--
|
--
|
-- Geoffrey Ottoy - DraMCo research group
|
-- Geoffrey Ottoy - DraMCo research group
|
--
|
--
|
-- Module Name: stepping_logic.vhd / entity stepping_logic
|
-- Module Name: stepping_logic.vhd / entity stepping_logic
|
--
|
--
|
-- Last Modified: 23/01/2012
|
-- Last Modified: 23/01/2012
|
--
|
--
|
-- Description: stepping logic for the pipelined montgomery multiplier
|
-- Description: stepping logic for the pipelined montgomery multiplier
|
--
|
--
|
--
|
--
|
-- Dependencies: counter_sync
|
-- Dependencies: counter_sync
|
--
|
--
|
-- Revision:
|
-- Revision:
|
-- Revision 5.01 - defined integer range for t_sel and n_sel resulting in less LUTs
|
-- Revision 5.01 - defined integer range for t_sel and n_sel resulting in less LUTs
|
-- Revision 5.00 - made the reset value changeable in runtime
|
-- Revision 5.00 - made the reset value changeable in runtime
|
-- Revision 4.01 - Delayed ready pulse with 1 clk cylce. This delay is necessary
|
-- Revision 4.01 - Delayed ready pulse with 1 clk cylce. This delay is necessary
|
-- for the reduction to complete.
|
-- for the reduction to complete.
|
-- Revision 4.00 - Changed design to fit new pipeline-architecture
|
-- Revision 4.00 - Changed design to fit new pipeline-architecture
|
-- (i.e. 1 clock cycle / stage)
|
-- (i.e. 1 clock cycle / stage)
|
-- Revision 3.00 - Removed second delay on next_x
|
-- Revision 3.00 - Removed second delay on next_x
|
-- Revision 2.00 - Changed operation to give a pulse on stepping_done when pipeline
|
-- Revision 2.00 - Changed operation to give a pulse on stepping_done when pipeline
|
-- operation has finished
|
-- operation has finished
|
-- 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 stepping_logic is
|
entity stepping_logic is
|
generic( n : integer := 1536; -- max nr of steps required to complete a multiplication
|
generic( n : integer := 1536; -- max nr of steps required to complete a multiplication
|
t : integer := 192 -- total nr of steps in the pipeline
|
t : integer := 192 -- total nr of steps in the pipeline
|
);
|
);
|
port( core_clk : in STD_LOGIC;
|
port( core_clk : in STD_LOGIC;
|
start : in STD_LOGIC;
|
start : in STD_LOGIC;
|
reset : in STD_LOGIC;
|
reset : in STD_LOGIC;
|
t_sel : in integer range 0 to t; -- nr of stages in the pipeline piece
|
t_sel : in integer range 0 to t; -- nr of stages in the pipeline piece
|
n_sel : in integer range 0 to n; -- nr of steps required for a complete multiplication
|
n_sel : in integer range 0 to n; -- nr of steps required for a complete multiplication
|
start_first_stage : out STD_LOGIC;
|
start_first_stage : out STD_LOGIC;
|
stepping_done : out STD_LOGIC
|
stepping_done : out STD_LOGIC
|
);
|
);
|
end stepping_logic;
|
end stepping_logic;
|
|
|
architecture Behavioral of stepping_logic is
|
architecture Behavioral of stepping_logic is
|
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;
|
|
|
component counter_sync
|
component counter_sync
|
generic(max_value : integer := 16
|
generic(max_value : integer := 16
|
);
|
);
|
port(reset_value : in integer;
|
port(reset_value : in integer;
|
core_clk : in STD_LOGIC;
|
core_clk : in STD_LOGIC;
|
ce : in STD_LOGIC;
|
ce : in STD_LOGIC;
|
reset : in STD_LOGIC;
|
reset : in STD_LOGIC;
|
overflow : out STD_LOGIC
|
overflow : out STD_LOGIC
|
);
|
);
|
end component;
|
end component;
|
|
|
signal laststeps_in_i : std_logic := '0';
|
signal laststeps_in_i : std_logic := '0';
|
signal laststeps_out_i : std_logic := '0';
|
signal laststeps_out_i : std_logic := '0';
|
signal start_stop_in_i : std_logic := '0';
|
signal start_stop_in_i : std_logic := '0';
|
signal start_stop_out_i : std_logic := '0';
|
signal start_stop_out_i : std_logic := '0';
|
signal steps_in_i : std_logic := '0';
|
signal steps_in_i : std_logic := '0';
|
signal steps_out_i : std_logic := '0';
|
signal steps_out_i : std_logic := '0';
|
signal substeps_in_i : std_logic := '0';
|
signal substeps_in_i : std_logic := '0';
|
signal substeps_out_i : std_logic := '0';
|
signal substeps_out_i : std_logic := '0';
|
signal done_reg_in_i : std_logic := '0';
|
signal done_reg_in_i : std_logic := '0';
|
signal done_reg_out_i : std_logic := '0';
|
signal done_reg_out_i : std_logic := '0';
|
signal start_first_stage_i : std_logic := '0';
|
signal start_first_stage_i : std_logic := '0';
|
signal start_i : std_logic := '0';
|
signal start_i : std_logic := '0';
|
|
|
begin
|
begin
|
start_i <= start;
|
start_i <= start;
|
|
|
-- map outputs
|
-- map outputs
|
start_first_stage <= start_first_stage_i;
|
start_first_stage <= start_first_stage_i;
|
stepping_done <= laststeps_out_i;
|
stepping_done <= laststeps_out_i;
|
|
|
-- internal signals
|
-- internal signals
|
start_stop_in_i <= start_i or (start_stop_out_i and not steps_out_i);
|
start_stop_in_i <= start_i or (start_stop_out_i and not steps_out_i);
|
substeps_in_i <= start_stop_in_i;
|
substeps_in_i <= start_stop_in_i;
|
steps_in_i <= substeps_out_i;
|
steps_in_i <= substeps_out_i;
|
done_reg_in_i <= steps_out_i or (done_reg_out_i and not laststeps_out_i);
|
done_reg_in_i <= steps_out_i or (done_reg_out_i and not laststeps_out_i);
|
laststeps_in_i <= done_reg_in_i;
|
laststeps_in_i <= done_reg_in_i;
|
start_first_stage_i <= start_i or steps_in_i;
|
start_first_stage_i <= start_i or steps_in_i;
|
--start_first_stage_i <= steps_in_i;
|
--start_first_stage_i <= steps_in_i;
|
|
|
done_reg: d_flip_flop
|
done_reg: d_flip_flop
|
port map(core_clk => core_clk,
|
port map(core_clk => core_clk,
|
reset => reset,
|
reset => reset,
|
din => done_reg_in_i,
|
din => done_reg_in_i,
|
dout => done_reg_out_i
|
dout => done_reg_out_i
|
);
|
);
|
|
|
start_stop_reg: d_flip_flop
|
start_stop_reg: d_flip_flop
|
port map(core_clk => core_clk,
|
port map(core_clk => core_clk,
|
reset => reset,
|
reset => reset,
|
din => start_stop_in_i,
|
din => start_stop_in_i,
|
dout => start_stop_out_i
|
dout => start_stop_out_i
|
);
|
);
|
|
|
-- for counting the last steps
|
-- for counting the last steps
|
laststeps_counter: counter_sync
|
laststeps_counter: counter_sync
|
generic map(max_value => t
|
generic map(max_value => t
|
)
|
)
|
port map(reset_value => t_sel,
|
port map(reset_value => t_sel,
|
core_clk => core_clk,
|
core_clk => core_clk,
|
ce => laststeps_in_i,
|
ce => laststeps_in_i,
|
reset => reset,
|
reset => reset,
|
overflow => laststeps_out_i
|
overflow => laststeps_out_i
|
);
|
);
|
|
|
-- counter for keeping track of the steps
|
-- counter for keeping track of the steps
|
steps_counter: counter_sync
|
steps_counter: counter_sync
|
generic map(max_value => n
|
generic map(max_value => n
|
)
|
)
|
port map(reset_value => (n_sel),
|
port map(reset_value => (n_sel),
|
core_clk => core_clk,
|
core_clk => core_clk,
|
ce => steps_in_i,
|
ce => steps_in_i,
|
reset => reset,
|
reset => reset,
|
overflow => steps_out_i
|
overflow => steps_out_i
|
);
|
);
|
|
|
-- makes sure we don't start too early with a new step
|
-- makes sure we don't start too early with a new step
|
substeps_counter: counter_sync
|
substeps_counter: counter_sync
|
generic map(max_value => 2
|
generic map(max_value => 2
|
)
|
)
|
port map(reset_value => 2,
|
port map(reset_value => 2,
|
core_clk => core_clk,
|
core_clk => core_clk,
|
ce => substeps_in_i,
|
ce => substeps_in_i,
|
reset => reset,
|
reset => reset,
|
overflow => substeps_out_i
|
overflow => substeps_out_i
|
);
|
);
|
|
|
|
|