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/] [stepping_logic.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: stepping_logic.vhd / entity stepping_logic
6
-- 
7
-- Last Modified:       23/01/2012 
8
-- 
9
-- Description:         stepping logic for the pipelined montgomery multiplier
10
--
11
--
12
-- Dependencies:        counter_sync
13
--
14
-- Revision:
15
-- Revision 5.01 - defined integer range for t_sel and n_sel resulting in less LUTs
16
-- Revision 5.00 - made the reset value changeable in runtime
17
-- Revision 4.01 - Delayed ready pulse with 1 clk cylce. This delay is necessary
18
--                 for the reduction to complete.
19
-- Revision 4.00 - Changed design to fit new pipeline-architecture
20
--                 (i.e. 1 clock cycle / stage)
21
-- Revision 3.00 - Removed second delay on next_x
22
-- Revision 2.00 - Changed operation to give a pulse on stepping_done when pipeline
23
--                 operation has finished
24
--      Revision 1.00 - Architecture
25
--      Revision 0.01 - File Created
26
--
27
--
28
------------------------------------------------------------------------------------
29
--
30
-- NOTICE:
31
--
32
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
33
-- by other third parties!
34
--
35
------------------------------------------------------------------------------------
36
library IEEE;
37
use IEEE.STD_LOGIC_1164.ALL;
38
use IEEE.STD_LOGIC_ARITH.ALL;
39
use IEEE.STD_LOGIC_UNSIGNED.ALL;
40
 
41
---- Uncomment the following library declaration if instantiating
42
---- any Xilinx primitives in this code.
43
--library UNISIM;
44
--use UNISIM.VComponents.all;
45
 
46
entity stepping_logic is
47
        generic( n : integer := 1536; -- max nr of steps required to complete a multiplication
48
                                t : integer := 192 -- total nr of steps in the pipeline
49
        );
50
   port(    core_clk : in  STD_LOGIC;
51
                              start : in  STD_LOGIC;
52
                              reset : in  STD_LOGIC;
53
                                        t_sel : in integer range 0 to t; -- nr of stages in the pipeline piece
54
                                        n_sel : in integer range 0 to n; -- nr of steps required for a complete multiplication
55
        start_first_stage : out STD_LOGIC;
56
       stepping_done : out STD_LOGIC
57
        );
58
end stepping_logic;
59
 
60
architecture Behavioral of stepping_logic is
61
        component d_flip_flop
62
   port(core_clk : in  STD_LOGIC;
63
                          reset : in  STD_LOGIC;
64
                            din : in  STD_LOGIC;
65
                      dout : out STD_LOGIC
66
        );
67
        end component;
68
 
69
        component counter_sync
70
        generic(max_value : integer := 16
71
        );
72
   port(reset_value : in integer;
73
             core_clk : in  STD_LOGIC;
74
                             ce : in  STD_LOGIC;
75
                          reset : in  STD_LOGIC;
76
                  overflow : out STD_LOGIC
77
        );
78
        end component;
79
 
80
        signal laststeps_in_i : std_logic := '0';
81
        signal laststeps_out_i : std_logic := '0';
82
        signal start_stop_in_i : std_logic := '0';
83
        signal start_stop_out_i : std_logic := '0';
84
        signal steps_in_i : std_logic := '0';
85
        signal steps_out_i : std_logic := '0';
86
        signal substeps_in_i : std_logic := '0';
87
        signal substeps_out_i : std_logic := '0';
88
        signal done_reg_in_i : std_logic := '0';
89
        signal done_reg_out_i : std_logic := '0';
90
        signal start_first_stage_i : std_logic := '0';
91
        signal start_i : std_logic := '0';
92
 
93
begin
94
        start_i <= start;
95
 
96
        -- map outputs
97
        start_first_stage <= start_first_stage_i;
98
        stepping_done <= laststeps_out_i;
99
 
100
        -- internal signals
101
        start_stop_in_i <= start_i or (start_stop_out_i and not steps_out_i);
102
        substeps_in_i <= start_stop_in_i;
103
        steps_in_i <= substeps_out_i;
104
        done_reg_in_i <= steps_out_i or (done_reg_out_i and not laststeps_out_i);
105
        laststeps_in_i <= done_reg_in_i;
106
        start_first_stage_i <= start_i or steps_in_i;
107
        --start_first_stage_i <= steps_in_i;
108
 
109
        done_reg: d_flip_flop
110
   port map(core_clk => core_clk,
111
                          reset => reset,
112
                            din => done_reg_in_i,
113
                      dout => done_reg_out_i
114
        );
115
 
116
        start_stop_reg: d_flip_flop
117
   port map(core_clk => core_clk,
118
                          reset => reset,
119
                            din => start_stop_in_i,
120
                      dout => start_stop_out_i
121
        );
122
 
123
        -- for counting the last steps
124
        laststeps_counter: counter_sync
125
        generic map(max_value => t
126
        )
127
   port map(reset_value => t_sel,
128
                        core_clk => core_clk,
129
                             ce => laststeps_in_i,
130
                          reset => reset,
131
                  overflow => laststeps_out_i
132
        );
133
 
134
        -- counter for keeping track of the steps
135
        steps_counter: counter_sync
136
        generic map(max_value => n
137
        )
138
   port map(reset_value => (n_sel),
139
                        core_clk => core_clk,
140
                             ce => steps_in_i,
141
                          reset => reset,
142
                  overflow => steps_out_i
143
        );
144
 
145
        -- makes sure we don't start too early with a new step
146
        substeps_counter: counter_sync
147
        generic map(max_value => 2
148
        )
149
   port map(reset_value => 2,
150
                        core_clk => core_clk,
151
                             ce => substeps_in_i,
152
                          reset => reset,
153
                  overflow => substeps_out_i
154
        );
155
 
156
end Behavioral;

powered by: WebSVN 2.1.0

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