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 3

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

Line No. Rev Author Line
1 3 JonasDC
----------------------------------------------------------------------  
2
----  stepping_logic                                              ---- 
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
----    stepping logic for the pipelined montgomery multiplier    ----
10
----                                                              ----
11
----  Dependencies:                                               ----
12
----    - d_flip_flop                                             ----
13
----    - counter_sync                                            ----
14
----                                                              ----
15
----  Authors:                                                    ----
16
----      - Geoffrey Ottoy, DraMCo research group                 ----
17
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
18
----                                                              ---- 
19
---------------------------------------------------------------------- 
20
----                                                              ---- 
21
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
22
----                                                              ---- 
23
---- This source file may be used and distributed without         ---- 
24
---- restriction provided that this copyright statement is not    ---- 
25
---- removed from the file and that any derivative work contains  ---- 
26
---- the original copyright notice and the associated disclaimer. ---- 
27
----                                                              ---- 
28
---- This source file is free software; you can redistribute it   ---- 
29
---- and/or modify it under the terms of the GNU Lesser General   ---- 
30
---- Public License as published by the Free Software Foundation; ---- 
31
---- either version 2.1 of the License, or (at your option) any   ---- 
32
---- later version.                                               ---- 
33
----                                                              ---- 
34
---- This source is distributed in the hope that it will be       ---- 
35
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
36
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
37
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
38
---- details.                                                     ---- 
39
----                                                              ---- 
40
---- You should have received a copy of the GNU Lesser General    ---- 
41
---- Public License along with this source; if not, download it   ---- 
42
---- from http://www.opencores.org/lgpl.shtml                     ---- 
43
----                                                              ---- 
44
----------------------------------------------------------------------
45 2 JonasDC
 
46 3 JonasDC
library ieee;
47
use ieee.std_logic_1164.all;
48
use ieee.std_logic_arith.all;
49
use ieee.std_logic_unsigned.all;
50 2 JonasDC
 
51 3 JonasDC
library mod_sim_exp;
52
use mod_sim_exp.mod_sim_exp_pkg.all;
53
 
54
 
55 2 JonasDC
entity stepping_logic is
56 3 JonasDC
  generic(
57
    n : integer := 1536; -- max nr of steps required to complete a multiplication
58
    t : integer := 192 -- total nr of steps in the pipeline
59
  );
60
  port(
61
    core_clk          : in  std_logic;
62
    start             : in  std_logic;
63
    reset             : in  std_logic;
64
    t_sel             : in integer range 0 to t; -- nr of stages in the pipeline piece
65
    n_sel             : in integer range 0 to n; -- nr of steps required for a complete multiplication
66
    start_first_stage : out std_logic;
67
    stepping_done     : out std_logic
68
  );
69 2 JonasDC
end stepping_logic;
70
 
71 3 JonasDC
 
72 2 JonasDC
architecture Behavioral of stepping_logic is
73 3 JonasDC
  signal laststeps_in_i      : std_logic := '0';
74
  signal laststeps_out_i     : std_logic := '0';
75
  signal start_stop_in_i     : std_logic := '0';
76
  signal start_stop_out_i    : std_logic := '0';
77
  signal steps_in_i          : std_logic := '0';
78
  signal steps_out_i         : std_logic := '0';
79
  signal substeps_in_i       : std_logic := '0';
80
  signal substeps_out_i      : std_logic := '0';
81
  signal done_reg_in_i       : std_logic := '0';
82
  signal done_reg_out_i      : std_logic := '0';
83
  signal start_first_stage_i : std_logic := '0';
84
  signal start_i : std_logic := '0';
85 2 JonasDC
 
86
begin
87
        start_i <= start;
88
 
89
        -- map outputs
90
        start_first_stage <= start_first_stage_i;
91
        stepping_done <= laststeps_out_i;
92
 
93
        -- internal signals
94
        start_stop_in_i <= start_i or (start_stop_out_i and not steps_out_i);
95
        substeps_in_i <= start_stop_in_i;
96
        steps_in_i <= substeps_out_i;
97
        done_reg_in_i <= steps_out_i or (done_reg_out_i and not laststeps_out_i);
98
        laststeps_in_i <= done_reg_in_i;
99
        start_first_stage_i <= start_i or steps_in_i;
100
        --start_first_stage_i <= steps_in_i;
101
 
102 3 JonasDC
  done_reg : d_flip_flop
103
  port map(
104
    core_clk => core_clk,
105
    reset    => reset,
106
    din      => done_reg_in_i,
107
    dout     => done_reg_out_i
108
  );
109
 
110
  start_stop_reg : d_flip_flop
111
  port map(
112
    core_clk => core_clk,
113
    reset    => reset,
114
    din      => start_stop_in_i,
115
    dout     => start_stop_out_i
116
  );
117
 
118
  -- for counting the last steps
119
  laststeps_counter : counter_sync
120
  generic map(
121
    max_value => t
122
  )
123
  port map(
124
    reset_value => t_sel,
125
    core_clk    => core_clk,
126
    ce          => laststeps_in_i,
127
    reset       => reset,
128
    overflow    => laststeps_out_i
129
  );
130
 
131
  -- counter for keeping track of the steps
132
  steps_counter : counter_sync
133
  generic map(
134
    max_value => n
135
  )
136
  port map(
137
    reset_value => (n_sel),
138
    core_clk    => core_clk,
139
    ce          => steps_in_i,
140
    reset       => reset,
141
    overflow    => steps_out_i
142
  );
143
 
144
  -- makes sure we don't start too early with a new step
145
  substeps_counter : counter_sync
146
  generic map(
147
    max_value => 2
148
  )
149
  port map(
150
    reset_value => 2,
151
    core_clk    => core_clk,
152
    ce          => substeps_in_i,
153
    reset       => reset,
154
    overflow    => substeps_out_i
155
  );
156
 
157 2 JonasDC
end Behavioral;

powered by: WebSVN 2.1.0

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