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/] [mod_sim_exp_core.vhd] - Blame information for rev 69

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

Line No. Rev Author Line
1 3 JonasDC
----------------------------------------------------------------------  
2 24 JonasDC
----  mod_sim_exp_core                                            ---- 
3 3 JonasDC
----                                                              ---- 
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
----    toplevel of a modular simultaneous exponentiation core    ----
10
----    using a pipelined montgommery multiplier with split       ----
11 24 JonasDC
----    pipeline and auto-run support                             ----
12 3 JonasDC
----                                                              ----
13
----  Dependencies:                                               ----
14
----    - mont_mult_sys_pipeline                                  ----
15
----    - operand_mem                                             ----
16
----    - fifo_primitive                                          ----
17
----    - mont_ctrl                                               ----
18
----                                                              ----
19
----  Authors:                                                    ----
20
----      - Geoffrey Ottoy, DraMCo research group                 ----
21
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
22
----                                                              ---- 
23
---------------------------------------------------------------------- 
24
----                                                              ---- 
25
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
26
----                                                              ---- 
27
---- This source file may be used and distributed without         ---- 
28
---- restriction provided that this copyright statement is not    ---- 
29
---- removed from the file and that any derivative work contains  ---- 
30
---- the original copyright notice and the associated disclaimer. ---- 
31
----                                                              ---- 
32
---- This source file is free software; you can redistribute it   ---- 
33
---- and/or modify it under the terms of the GNU Lesser General   ---- 
34
---- Public License as published by the Free Software Foundation; ---- 
35
---- either version 2.1 of the License, or (at your option) any   ---- 
36
---- later version.                                               ---- 
37
----                                                              ---- 
38
---- This source is distributed in the hope that it will be       ---- 
39
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
40
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
41
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
42
---- details.                                                     ---- 
43
----                                                              ---- 
44
---- You should have received a copy of the GNU Lesser General    ---- 
45
---- Public License along with this source; if not, download it   ---- 
46
---- from http://www.opencores.org/lgpl.shtml                     ---- 
47
----                                                              ---- 
48
----------------------------------------------------------------------
49 2 JonasDC
 
50 3 JonasDC
library ieee;
51
use ieee.std_logic_1164.all;
52
use ieee.std_logic_arith.all;
53
use ieee.std_logic_unsigned.all;
54 2 JonasDC
 
55 3 JonasDC
library mod_sim_exp;
56
use mod_sim_exp.mod_sim_exp_pkg.all;
57 63 JonasDC
use mod_sim_exp.std_functions.all;
58 3 JonasDC
 
59 24 JonasDC
-- toplevel of the modular simultaneous exponentiation core
60
-- contains an operand and modulus ram, multiplier, an exponent fifo
61
-- and control logic
62
entity mod_sim_exp_core is
63 43 JonasDC
  generic(
64
    C_NR_BITS_TOTAL   : integer := 1536;
65
    C_NR_STAGES_TOTAL : integer := 96;
66
    C_NR_STAGES_LOW   : integer := 32;
67 63 JonasDC
    C_SPLIT_PIPELINE  : boolean := true;
68
    C_NR_OP           : integer := 4;
69
    C_NR_M            : integer := 2;
70 69 JonasDC
    C_FIFO_DEPTH      : integer := 32;
71
    C_MEM_STYLE       : string  := "xil_prim"; -- xil_prim, generic, asym are valid options
72
    C_DEVICE          : string  := "xilinx"   -- xilinx, altera are valid options
73 43 JonasDC
  );
74 3 JonasDC
  port(
75
    clk   : in  std_logic;
76
    reset : in  std_logic;
77
      -- operand memory interface (plb shared memory)
78 24 JonasDC
    write_enable : in  std_logic; -- write data to operand ram
79
    data_in      : in  std_logic_vector (31 downto 0);  -- operand ram data in
80 69 JonasDC
    rw_address   : in  std_logic_vector (log2(C_NR_OP)+log2(C_NR_BITS_TOTAL/32) downto 0); -- operand ram address bus
81 24 JonasDC
    data_out     : out std_logic_vector (31 downto 0);  -- operand ram data out
82
    collision    : out std_logic; -- write collision
83 3 JonasDC
      -- op_sel fifo interface
84 24 JonasDC
    fifo_din    : in  std_logic_vector (31 downto 0); -- exponent fifo data in
85
    fifo_push   : in  std_logic;  -- push data in exponent fifo
86
    fifo_full   : out std_logic;  -- high if fifo is full
87
    fifo_nopush : out std_logic;  -- high if error during push
88
      -- control signals
89
    start          : in  std_logic; -- start multiplication/exponentiation
90 45 JonasDC
    exp_m          : in  std_logic; -- single multiplication if low, exponentiation if high
91 24 JonasDC
    ready          : out std_logic; -- calculations done
92 63 JonasDC
    x_sel_single   : in  std_logic_vector (log2(C_NR_OP)-1 downto 0); -- single multiplication x operand selection
93
    y_sel_single   : in  std_logic_vector (log2(C_NR_OP)-1 downto 0); -- single multiplication y operand selection
94
    dest_op_single : in  std_logic_vector (log2(C_NR_OP)-1 downto 0); -- result destination operand selection
95 24 JonasDC
    p_sel          : in  std_logic_vector (1 downto 0); -- pipeline part selection
96 63 JonasDC
    calc_time      : out std_logic;
97 69 JonasDC
    modulus_sel    : in std_logic_vector(log2(C_NR_M)-1 downto 0) -- selects which modulus to use for multiplications
98 3 JonasDC
  );
99 24 JonasDC
end mod_sim_exp_core;
100 2 JonasDC
 
101 3 JonasDC
 
102 24 JonasDC
architecture Structural of mod_sim_exp_core is
103
  -- data busses
104 69 JonasDC
  signal xy : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0);  -- x and y operand data bus RAM -> multiplier
105
  signal m  : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0);  -- modulus data bus RAM -> multiplier
106
  signal r  : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0);  -- result data bus RAM <- multiplier
107
 
108 24 JonasDC
  -- control signals
109 69 JonasDC
  signal op_sel         : std_logic_vector(1 downto 0); -- operand selection
110
  signal result_dest_op : std_logic_vector(1 downto 0); -- result destination operand
111
  signal mult_ready     : std_logic;
112
  signal start_mult     : std_logic;
113 24 JonasDC
  signal load_x         : std_logic;
114 69 JonasDC
  signal load_result    : std_logic;
115
 
116 24 JonasDC
  -- fifo signals
117 3 JonasDC
  signal fifo_empty : std_logic;
118
  signal fifo_pop   : std_logic;
119
  signal fifo_nopop : std_logic;
120
  signal fifo_dout  : std_logic_vector(31 downto 0);
121 2 JonasDC
begin
122
 
123 3 JonasDC
  -- The actual multiplier
124 36 JonasDC
  the_multiplier : mont_multiplier
125 24 JonasDC
  generic map(
126 69 JonasDC
    n     => C_NR_BITS_TOTAL,
127
    t     => C_NR_STAGES_TOTAL,
128
    tl    => C_NR_STAGES_LOW,
129 43 JonasDC
    split => C_SPLIT_PIPELINE
130 3 JonasDC
  )
131
  port map(
132
    core_clk => clk,
133 24 JonasDC
    xy       => xy,
134 3 JonasDC
    m        => m,
135
    r        => r,
136
    start    => start_mult,
137
    reset    => reset,
138
    p_sel    => p_sel,
139 24 JonasDC
    load_x   => load_x,
140 3 JonasDC
    ready    => mult_ready
141
  );
142
 
143
  -- Block ram memory for storing the operands and the modulus
144 69 JonasDC
  the_memory : operand_mem
145 34 JonasDC
  generic map(
146 69 JonasDC
    width     => C_NR_BITS_TOTAL,
147
    nr_op     => C_NR_OP,
148
    nr_m      => C_NR_M,
149
    mem_style => C_MEM_STYLE,
150
    device    => C_DEVICE
151 34 JonasDC
  )
152 24 JonasDC
  port map(
153 3 JonasDC
    data_in        => data_in,
154
    data_out       => data_out,
155
    rw_address     => rw_address,
156 39 JonasDC
    write_enable   => write_enable,
157 3 JonasDC
    op_sel         => op_sel,
158 24 JonasDC
    xy_out         => xy,
159 3 JonasDC
    m              => m,
160
    result_in      => r,
161
    load_result    => load_result,
162 24 JonasDC
    result_dest_op => result_dest_op,
163 3 JonasDC
    collision      => collision,
164 63 JonasDC
    clk            => clk,
165
    modulus_sel     => modulus_sel
166 3 JonasDC
  );
167 39 JonasDC
 
168 45 JonasDC
        result_dest_op <= dest_op_single when exp_m = '0' else "11"; -- in autorun mode we always store the result in operand3
169 2 JonasDC
 
170 69 JonasDC
  -- A fifo for exponentiation mode
171
  xil_prim_fifo : if C_MEM_STYLE="xil_prim" generate
172
    the_exponent_fifo : fifo_primitive
173
    port map(
174
      clk    => clk,
175
      din    => fifo_din,
176
      dout   => fifo_dout,
177
      empty  => fifo_empty,
178
      full   => fifo_full,
179
      push   => fifo_push,
180
      pop    => fifo_pop,
181
      reset  => reset,
182
      nopop  => fifo_nopop,
183
      nopush => fifo_nopush
184
    );
185
  end generate;
186
        gen_fifo : if (C_MEM_STYLE="generic") or (C_MEM_STYLE="asym") generate
187
    the_exponent_fifo : fifo_generic
188
    generic map(
189
      depth => C_FIFO_DEPTH
190
    )
191
    port map(
192
      clk    => clk,
193
      din    => fifo_din,
194
      dout   => fifo_dout,
195
      empty  => fifo_empty,
196
      full   => fifo_full,
197
      push   => fifo_push,
198
      pop    => fifo_pop,
199
      reset  => reset,
200
      nopop  => fifo_nopop,
201
      nopush => fifo_nopush
202
    );
203
  end generate;
204
 
205 3 JonasDC
  -- The control logic for the core
206 24 JonasDC
  the_control_unit : mont_ctrl
207
  port map(
208 3 JonasDC
    clk              => clk,
209
    reset            => reset,
210
    start            => start,
211
    x_sel_single     => x_sel_single,
212
    y_sel_single     => y_sel_single,
213 45 JonasDC
    run_auto         => exp_m,
214 3 JonasDC
    op_buffer_empty  => fifo_empty,
215
    op_sel_buffer    => fifo_dout,
216
    read_buffer      => fifo_pop,
217
    done             => ready,
218
    calc_time        => calc_time,
219
    op_sel           => op_sel,
220 24 JonasDC
    load_x           => load_x,
221 3 JonasDC
    load_result      => load_result,
222
    start_multiplier => start_mult,
223
    multiplier_ready => mult_ready
224
  );
225 2 JonasDC
 
226 24 JonasDC
end Structural;

powered by: WebSVN 2.1.0

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