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

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

Line No. Rev Author Line
1 25 JonasDC
----------------------------------------------------------------------  
2
----  sys_pipeline                                                ---- 
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
----    the pipelined systolic array for a montgommery multiplier ----
10
----                                                              ----
11
----  Dependencies:                                               ----
12
----    - sys_stage                                               ----
13
----    - register_n                                              ----
14
----    - d_flip_flop                                             ----
15
----    - cell_1b_adder                                           ----
16
----    - cell_1b_mux                                             ----
17
----                                                              ----
18
----  Authors:                                                    ----
19
----      - Geoffrey Ottoy, DraMCo research group                 ----
20
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
21
----                                                              ---- 
22
---------------------------------------------------------------------- 
23
----                                                              ---- 
24
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
25
----                                                              ---- 
26
---- This source file may be used and distributed without         ---- 
27
---- restriction provided that this copyright statement is not    ---- 
28
---- removed from the file and that any derivative work contains  ---- 
29
---- the original copyright notice and the associated disclaimer. ---- 
30
----                                                              ---- 
31
---- This source file is free software; you can redistribute it   ---- 
32
---- and/or modify it under the terms of the GNU Lesser General   ---- 
33
---- Public License as published by the Free Software Foundation; ---- 
34
---- either version 2.1 of the License, or (at your option) any   ---- 
35
---- later version.                                               ---- 
36
----                                                              ---- 
37
---- This source is distributed in the hope that it will be       ---- 
38
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
39
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
40
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
41
---- details.                                                     ---- 
42
----                                                              ---- 
43
---- You should have received a copy of the GNU Lesser General    ---- 
44
---- Public License along with this source; if not, download it   ---- 
45
---- from http://www.opencores.org/lgpl.shtml                     ---- 
46
----                                                              ---- 
47
----------------------------------------------------------------------
48
 
49
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.std_logic_unsigned.all;
52
 
53
library mod_sim_exp;
54
use mod_sim_exp.mod_sim_exp_pkg.all;
55
 
56
-- the pipelined systolic array for a montgommery multiplier
57
-- contains a structural description of the pipeline using the systolic stages
58
entity sys_pipeline is
59
        generic(
60
    n  : integer := 1536; -- width of the operands (# bits)
61
    t  : integer := 192;  -- total number of stages (divider of n) >= 2
62
    tl : integer := 64    -- lower number of stages (best take t = sqrt(n))
63
  );
64
  port(
65
    -- clock input
66
    core_clk : in  std_logic;
67
    -- modulus and y opperand input (n)-bit
68
    y        : in  std_logic_vector((n-1) downto 0);
69
    m        : in  std_logic_vector((n-1) downto 0);
70
    -- x operand input (serial)
71
    xi       : in  std_logic;
72
    next_x   : out std_logic; -- next x operand bit
73
    -- control signals
74
    start    : in  std_logic; -- start multiplier
75
    reset    : in  std_logic;
76
    p_sel    : in  std_logic_vector(1 downto 0); -- select which piece of the pipeline will be used
77
    -- result out
78
    r        : out std_logic_vector((n-1) downto 0)
79
  );
80
end sys_pipeline;
81
 
82
architecture Structural of sys_pipeline is
83
  constant s : integer := n/t;
84
 
85
 
86
  signal m_i           : std_logic_vector(n downto 0);
87
  signal y_i           : std_logic_vector(n downto 0);
88
 
89
  -- systolic stages signals
90
  signal my_cin_stage  : std_logic_vector((t-1) downto 0);
91
  signal my_cout_stage : std_logic_vector((t-1) downto 0);
92
  signal xin_stage     : std_logic_vector((t-1) downto 0);
93
  signal qin_stage     : std_logic_vector((t-1) downto 0);
94
  signal xout_stage    : std_logic_vector((t-1) downto 0);
95
  signal qout_stage    : std_logic_vector((t-1) downto 0);
96
  signal a_msb_stage   : std_logic_vector((t-1) downto 0);
97
  signal a_0_stage     : std_logic_vector((t-1) downto 0);
98
  signal cin_stage     : std_logic_vector((t-1) downto 0);
99
  signal cout_stage    : std_logic_vector((t-1) downto 0);
100
  signal red_cin_stage : std_logic_vector((t-1) downto 0);
101
  signal red_cout_stage : std_logic_vector((t-1) downto 0);
102
  signal start_stage   : std_logic_vector((t-1) downto 0);
103
  signal done_stage    : std_logic_vector((t-1) downto 0);
104
  signal r_sel         : std_logic;
105
 
106
  -- first cell signals
107
  signal my0_mux_result : std_logic;
108
  signal my0 : std_logic;
109
 
110
begin
111
 
112
  m_i <= '0' & m;
113
  y_i <= '0' & y;
114
 
115
  -- generate the stages for the full pipeline
116
  pipeline_stages : for i in 0 to (t-1) generate
117
    stage : sys_stage
118
    generic map(
119
      width => s
120
    )
121
    port map(
122
      core_clk => core_clk,
123
      y        => y_i((i+1)*s downto (i*s)+1),
124
      m        => m_i((i+1)*s downto (i*s)),
125
      my_cin   => my_cin_stage(i),
126
      my_cout  => my_cout_stage(i),
127
      xin      => xin_stage(i),
128
      qin      => qin_stage(i),
129
      xout     => xout_stage(i),
130
      qout     => qout_stage(i),
131
      a_0      => a_0_stage(i),
132
      a_msb    => a_msb_stage(i),
133
      cin      => cin_stage(i),
134
      cout     => cout_stage(i),
135
      red_cin  => red_cin_stage(i),
136
      red_cout => red_cout_stage(i),
137
      start    => start_stage(i),
138
      reset    => reset,
139
      done     => done_stage(i),
140
      r_sel    => r_sel,
141
      r        => r(((i+1)*s)-1 downto (i*s))
142
    );
143
  end generate;
144
 
145
  -- link stages to eachother
146
  stage_connect : for i in 1 to (t-1) generate
147
    my_cin_stage(i) <= my_cout_stage(i-1);
148
    cin_stage(i) <= cout_stage(i-1);
149
    xin_stage(i) <= xout_stage(i-1);
150
    qin_stage(i) <= qout_stage(i-1);
151
    red_cin_stage(i) <= red_cout_stage(i-1);
152
    start_stage(i) <= done_stage(i-1);
153
    a_msb_stage(i-1) <= a_0_stage(i);
154
  end generate;
155
 
156
  -- first cell logic
157
  --------------------
158 31 JonasDC
  first_stage : sys_first_cell_logic
159
  port map (
160
    m0       => m_i(0),
161
    y0       => y_i(0),
162
    my_cout  => my_cin_stage(0),
163
    xi       => xi,
164
    xout     => xin_stage(0),
165
    qout     => qin_stage(0),
166
    cout     => cin_stage(0),
167
    a_0      => a_0_stage(0),
168
    red_cout => red_cin_stage(0)
169 25 JonasDC
  );
170
 
171 31 JonasDC
  start_stage(0) <= start;
172 25 JonasDC
  next_x <= done_stage(0);
173
 
174
  -- last cell logic
175
  -------------------
176 30 JonasDC
  last_cell : sys_last_cell_logic
177
  port map (
178 25 JonasDC
    core_clk => core_clk,
179
    reset    => reset,
180 30 JonasDC
    a_0      => a_msb_stage(t-1),
181
    cin      => cout_stage(t-1),
182
    red_cin  => red_cout_stage(t-1),
183
    r_sel    => r_sel,
184
    start    => done_stage(t-1)
185 25 JonasDC
  );
186
 
187
end Structural;

powered by: WebSVN 2.1.0

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