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 37

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