OpenCores
URL https://opencores.org/ocsvn/mod_sim_exp/mod_sim_exp/trunk

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [tags/] [start_version/] [rtl/] [vhdl/] [core/] [last_stage.vhd] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 JonasDC
------------------------------------------------------------------------------------ 
2
--                      
3
-- Geoffrey Ottoy - DraMCo research group
4
--
5
-- Module Name: last_stage.vhd / entity last_stage
6
-- 
7
-- Last Modified:       24/11/2011 
8
-- 
9
-- Description:         last stage for use in the montgommery multiplier systolic
10
--                                              array pipeline
11
--
12
--
13
-- Dependencies:        standard_cell_block
14
--                                              cell_1b
15
--
16
-- Revision:
17
-- Revision 5.00 - Removed input registers and used start signal as load_out_regs
18
-- Revision 4.01 - Remove "done" input
19
-- Revision 4.00 - Removed "a" input with internal feedback
20
-- Revision 3.03 - fixed switched last two bits
21
-- Revision 3.02 - removed "ready" output signal
22
-- Revision 3.01 - replaced the behavioral description of the registers with a
23
--                 component instantiation
24
-- Revision 3.00 - added registers to store input values xin, cin, qin (because they
25
--                                          can change during operation)
26
-- Revision 2.00 - changed indices in signals my, y and m
27
-- Revision 1.03 - added done pulse
28
-- Revision 1.02 - appended "_i" to name of all internal signals
29
-- Revision 1.01 - ready is '1' after reset
30
--      Revision 1.00 - Architecture
31
--      Revision 0.01 - File Created
32
--
33
--
34
------------------------------------------------------------------------------------
35
--
36
-- NOTICE:
37
--
38
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
39
-- by other third parties!
40
--
41
------------------------------------------------------------------------------------
42
library IEEE;
43
use IEEE.STD_LOGIC_1164.ALL;
44
use IEEE.STD_LOGIC_ARITH.ALL;
45
use IEEE.STD_LOGIC_UNSIGNED.ALL;
46
 
47
---- Uncomment the following library declaration if instantiating
48
---- any Xilinx primitives in this code.
49
--library UNISIM;
50
--use UNISIM.VComponents.all;
51
 
52
entity last_stage is
53
        generic(width : integer := 16 -- must be the same as width of the standard stage
54
        );
55
   port(core_clk : in  STD_LOGIC;
56
                             my : in  STD_LOGIC_VECTOR((width-1) downto 0);
57
               y : in  STD_LOGIC_VECTOR((width-2) downto 0);
58
               m : in  STD_LOGIC_VECTOR((width-2) downto 0);
59
             xin : in  STD_LOGIC;
60
             qin : in  STD_LOGIC;
61
                            cin : in  STD_LOGIC;
62
                          start : in  STD_LOGIC;
63
                          reset : in  STD_LOGIC;
64
                        --  ready : out STD_LOGIC;
65
                         --  done : out STD_LOGIC;
66
               r : out STD_LOGIC_VECTOR((width+1) downto 0)
67
        );
68
end last_stage;
69
 
70
architecture Structural of last_stage is
71
 
72
        component d_flip_flop
73
   port(core_clk : in  STD_LOGIC;
74
                          reset : in  STD_LOGIC;
75
                            din : in  STD_LOGIC;
76
                      dout : out STD_LOGIC
77
        );
78
        end component;
79
 
80
        component register_1b
81
   port(core_clk : in  STD_LOGIC;
82
                             ce : in  STD_LOGIC;
83
                          reset : in  STD_LOGIC;
84
                            din : in  STD_LOGIC;
85
                      dout : out STD_LOGIC
86
        );
87
        end component;
88
 
89
        component register_n
90
        generic( n : integer := 4
91
        );
92
   port(core_clk : in  STD_LOGIC;
93
                             ce : in  STD_LOGIC;
94
                          reset : in  STD_LOGIC;
95
                            din : in  STD_LOGIC_VECTOR((n-1) downto 0);
96
                      dout : out STD_LOGIC_VECTOR((n-1) downto 0)
97
        );
98
        end component;
99
 
100
        component standard_cell_block
101
        generic ( width : integer := 32
102
        );
103
   Port ( my : in  STD_LOGIC_VECTOR((width-1) downto 0);
104
           y : in  STD_LOGIC_VECTOR((width-1) downto 0);
105
           m : in  STD_LOGIC_VECTOR((width-1) downto 0);
106
           x : in  STD_LOGIC;
107
           q : in  STD_LOGIC;
108
                          a : in  STD_LOGIC_VECTOR((width-1) downto 0);
109
                          cin : in STD_LOGIC;
110
                          cout : out STD_LOGIC;
111
           r : out  STD_LOGIC_VECTOR((width-1) downto 0));
112
        end component;
113
 
114
        component cell_1b
115
   port ( my : in  STD_LOGIC;
116
           y : in  STD_LOGIC;
117
           m : in  STD_LOGIC;
118
           x : in  STD_LOGIC;
119
           q : in  STD_LOGIC;
120
                          a : in  STD_LOGIC;
121
                          cin : in STD_LOGIC;
122
                          cout : out STD_LOGIC;
123
           r : out  STD_LOGIC);
124
        end component;
125
 
126
        -- input
127
        signal my_i : std_logic_vector(width downto 0);
128
        signal m_i : std_logic_vector(width downto 0);
129
        signal y_i : std_logic_vector(width downto 0);
130
        signal cin_i : std_logic;
131
        signal xin_i : std_logic;
132
        signal qin_i : std_logic;
133
        signal a_i : std_logic_vector((width) downto 0);
134
--      signal cin_reg_i : std_logic;
135
--      signal xin_reg_i : std_logic;
136
--      signal qin_reg_i : std_logic;
137
--      signal a_reg_i : std_logic_vector((width) downto 0);
138
 
139
        -- output
140
        signal r_i : std_logic_vector((width+1) downto 0);
141
        signal r_reg_i : std_logic_vector((width+1) downto 0);
142
 
143
        -- interconnection
144
        signal cout_i : std_logic;
145
 
146
        -- control signals
147
--      signal load_out_regs_i : std_logic;
148
--      signal done_i : std_logic := '1';
149
        --signal ready_del_i : std_logic := '1';
150
 
151
begin
152
        -- map internal signals to outputs
153
--      done <= done_i;
154
        r <= r_reg_i;
155
                -- two posibilities:
156
        --done <= ready_i and (not ready_del_i); -- slow
157
        --done <= not ready_i; -- faster but not sure if it will work (DONE_PROC can be omitted)
158
 
159
        -- map inputs to internal signals
160
        my_i <= '0' & my;
161
        m_i <= "00" & m;
162
        y_i <= "00" & y;
163
        xin_i <= xin;
164
        qin_i <= qin;
165
        cin_i <= cin;
166
 
167
        a_i <= r_reg_i((width+1) downto 1);
168
 
169
        cell_block: standard_cell_block
170
        generic map( width => width
171
        )
172
   Port map( my => my_i(width-1 downto 0),
173
                         y => y_i(width-1 downto 0),
174
                         m => m_i(width-1 downto 0),
175
--                       x => xin_reg_i,
176
--                       q => qin_reg_i,
177
                         x => xin_i,
178
                         q => qin_i,
179
                         a => a_i((width-1) downto 0),
180
--                       cin => cin_reg_i,
181
                         cin => cin_i,
182
                         cout => cout_i,
183
                         r => r_i((width-1) downto 0)
184
        );
185
 
186
        last_cell: cell_1b
187
   port map( my => my_i(width),
188
           y => y_i(width),
189
           m => m_i(width),
190
--              x => xin_reg_i,
191
--              q => qin_reg_i,
192
                          x => xin_i,
193
           q => qin_i,
194
                          a => a_i(width),
195
                          cin => cout_i,
196
                          cout => r_i(width+1),
197
           r => r_i(width)
198
        );
199
 
200
--      XIN_REG: register_1b
201
--   port map(core_clk => core_clk,
202
--                           ce => start,
203
--                        reset => reset,
204
--                          din => xin_i,
205
--                    dout => xin_reg_i
206
--      );
207
 
208
--      QIN_REG: register_1b
209
--   port map(core_clk => core_clk,
210
--                           ce => start,
211
--                        reset => reset,
212
--                          din => qin_i,
213
--                    dout => qin_reg_i
214
--      );
215
 
216
--      CIN_REG: register_1b
217
--   port map(core_clk => core_clk,
218
--                           ce => start,
219
--                        reset => reset,
220
--                          din => cin_i,
221
--                    dout => cin_reg_i
222
--      );
223
 
224
        -- control
225
--      delay_1_cycle: d_flip_flop
226
--   port map(core_clk => core_clk,
227
--                        reset => reset,
228
--                          din => start,
229
--                    dout => load_out_regs_i
230
--      );
231
 
232
--      done_signal: d_flip_flop
233
--   port map(core_clk => core_clk,
234
--                        reset => reset,
235
--                          din => load_out_regs_i,
236
--                    dout => done_i
237
--      );
238
 
239
        -- output registers
240
        RESULT_REG: register_n
241
        generic map( n => (width+2)
242
        )
243
   port map(core_clk => core_clk,
244
--                           ce => load_out_regs_i,
245
                                  ce => start,
246
                          reset => reset,
247
                            din => r_i,
248
                      dout => r_reg_i
249
        );
250
 
251
end Structural;

powered by: WebSVN 2.1.0

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