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

powered by: WebSVN 2.1.0

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