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 45

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
 
58 24 JonasDC
-- toplevel of the modular simultaneous exponentiation core
59
-- contains an operand and modulus ram, multiplier, an exponent fifo
60
-- and control logic
61
entity mod_sim_exp_core is
62 43 JonasDC
  generic(
63
    C_NR_BITS_TOTAL   : integer := 1536;
64
    C_NR_STAGES_TOTAL : integer := 96;
65
    C_NR_STAGES_LOW   : integer := 32;
66
    C_SPLIT_PIPELINE  : boolean := true
67
  );
68 3 JonasDC
  port(
69
    clk   : in  std_logic;
70
    reset : in  std_logic;
71
      -- operand memory interface (plb shared memory)
72 24 JonasDC
    write_enable : in  std_logic; -- write data to operand ram
73
    data_in      : in  std_logic_vector (31 downto 0);  -- operand ram data in
74
    rw_address   : in  std_logic_vector (8 downto 0);   -- operand ram address bus
75
    data_out     : out std_logic_vector (31 downto 0);  -- operand ram data out
76
    collision    : out std_logic; -- write collision
77 3 JonasDC
      -- op_sel fifo interface
78 24 JonasDC
    fifo_din    : in  std_logic_vector (31 downto 0); -- exponent fifo data in
79
    fifo_push   : in  std_logic;  -- push data in exponent fifo
80
    fifo_full   : out std_logic;  -- high if fifo is full
81
    fifo_nopush : out std_logic;  -- high if error during push
82
      -- control signals
83
    start          : in  std_logic; -- start multiplication/exponentiation
84 45 JonasDC
    exp_m          : in  std_logic; -- single multiplication if low, exponentiation if high
85 24 JonasDC
    ready          : out std_logic; -- calculations done
86
    x_sel_single   : in  std_logic_vector (1 downto 0); -- single multiplication x operand selection
87
    y_sel_single   : in  std_logic_vector (1 downto 0); -- single multiplication y operand selection
88
    dest_op_single : in  std_logic_vector (1 downto 0); -- result destination operand selection
89
    p_sel          : in  std_logic_vector (1 downto 0); -- pipeline part selection
90 3 JonasDC
    calc_time      : out std_logic
91
  );
92 24 JonasDC
end mod_sim_exp_core;
93 2 JonasDC
 
94 3 JonasDC
 
95 24 JonasDC
architecture Structural of mod_sim_exp_core is
96
  -- data busses
97 43 JonasDC
  signal xy   : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0);  -- x and y operand data bus RAM -> multiplier
98
  signal m    : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0);  -- modulus data bus RAM -> multiplier
99
  signal r    : std_logic_vector(C_NR_BITS_TOTAL-1 downto 0);  -- result data bus RAM <- multiplier
100 24 JonasDC
 
101
  -- control signals
102
  signal op_sel           : std_logic_vector(1 downto 0); -- operand selection 
103
  signal result_dest_op   : std_logic_vector(1 downto 0); -- result destination operand
104 3 JonasDC
  signal mult_ready       : std_logic;
105
  signal start_mult       : std_logic;
106 24 JonasDC
  signal load_x         : std_logic;
107 3 JonasDC
  signal load_result      : std_logic;
108 24 JonasDC
 
109
  -- fifo signals
110 3 JonasDC
  signal fifo_empty : std_logic;
111
  signal fifo_pop   : std_logic;
112
  signal fifo_nopop : std_logic;
113
  signal fifo_dout  : std_logic_vector(31 downto 0);
114 2 JonasDC
begin
115
 
116 3 JonasDC
  -- The actual multiplier
117 36 JonasDC
  the_multiplier : mont_multiplier
118 24 JonasDC
  generic map(
119 43 JonasDC
    n  => C_NR_BITS_TOTAL,
120
    t  => C_NR_STAGES_TOTAL,
121
    tl => C_NR_STAGES_LOW,
122
    split => C_SPLIT_PIPELINE
123 3 JonasDC
  )
124
  port map(
125
    core_clk => clk,
126 24 JonasDC
    xy       => xy,
127 3 JonasDC
    m        => m,
128
    r        => r,
129
    start    => start_mult,
130
    reset    => reset,
131
    p_sel    => p_sel,
132 24 JonasDC
    load_x   => load_x,
133 3 JonasDC
    ready    => mult_ready
134
  );
135
 
136
  -- Block ram memory for storing the operands and the modulus
137 34 JonasDC
  the_memory : operand_mem
138
  generic map(
139 43 JonasDC
    n => C_NR_BITS_TOTAL
140 34 JonasDC
  )
141 24 JonasDC
  port map(
142 3 JonasDC
    data_in        => data_in,
143
    data_out       => data_out,
144
    rw_address     => rw_address,
145 39 JonasDC
    write_enable   => write_enable,
146 3 JonasDC
    op_sel         => op_sel,
147 24 JonasDC
    xy_out         => xy,
148 3 JonasDC
    m              => m,
149
    result_in      => r,
150
    load_result    => load_result,
151 24 JonasDC
    result_dest_op => result_dest_op,
152 3 JonasDC
    collision      => collision,
153
    clk            => clk
154
  );
155 39 JonasDC
 
156 45 JonasDC
        result_dest_op <= dest_op_single when exp_m = '0' else "11"; -- in autorun mode we always store the result in operand3
157 2 JonasDC
 
158 3 JonasDC
  -- A fifo for auto-run operand selection
159 24 JonasDC
  the_exponent_fifo : fifo_primitive
160
  port map(
161 3 JonasDC
    clk    => clk,
162
    din    => fifo_din,
163
    dout   => fifo_dout,
164
    empty  => fifo_empty,
165
    full   => fifo_full,
166
    push   => fifo_push,
167
    pop    => fifo_pop,
168
    reset  => reset,
169
    nopop  => fifo_nopop,
170
    nopush => fifo_nopush
171
  );
172 2 JonasDC
 
173 3 JonasDC
  -- The control logic for the core
174 24 JonasDC
  the_control_unit : mont_ctrl
175
  port map(
176 3 JonasDC
    clk              => clk,
177
    reset            => reset,
178
    start            => start,
179
    x_sel_single     => x_sel_single,
180
    y_sel_single     => y_sel_single,
181 45 JonasDC
    run_auto         => exp_m,
182 3 JonasDC
    op_buffer_empty  => fifo_empty,
183
    op_sel_buffer    => fifo_dout,
184
    read_buffer      => fifo_pop,
185
    done             => ready,
186
    calc_time        => calc_time,
187
    op_sel           => op_sel,
188 24 JonasDC
    load_x           => load_x,
189 3 JonasDC
    load_result      => load_result,
190
    start_multiplier => start_mult,
191
    multiplier_ready => mult_ready
192
  );
193 2 JonasDC
 
194 24 JonasDC
end Structural;

powered by: WebSVN 2.1.0

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