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

Subversion Repositories minimips_superscalar

[/] [minimips_superscalar/] [tags/] [P1/] [sources/] [minimips.vhd] - Blame information for rev 31

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 mcafruni
------------------------------------------------------------------------------------
2
--                                                                                --
3
--    Copyright (c) 2004, Hangouet Samuel                                         --
4
--                  , Jan Sebastien                                               --
5
--                  , Mouton Louis-Marie                                          --
6
--                  , Schneider Olivier     all rights reserved                   --
7
--                                                                                --
8
--    This file is part of miniMIPS.                                              --
9
--                                                                                --
10
--    miniMIPS is free software; you can redistribute it and/or modify            --
11
--    it under the terms of the GNU General Public License as published by        --
12
--    the Free Software Foundation; either version 2 of the License, or           --
13
--    (at your option) any later version.                                         --
14
--                                                                                --
15
--    miniMIPS is distributed in the hope that it will be useful,                 --
16
--    but WITHOUT ANY WARRANTY; without even the implied warranty of              --
17
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               --
18
--    GNU General Public License for more details.                                --
19
--                                                                                --
20
--    You should have received a copy of the GNU General Public License           --
21
--    along with miniMIPS; if not, write to the Free Software                     --
22
--    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   --
23
--                                                                                --
24
------------------------------------------------------------------------------------
25
 
26
 
27
-- If you encountered any problem, please contact :
28
--
29
--   lmouton@enserg.fr
30
--   oschneid@enserg.fr
31
--   shangoue@enserg.fr
32
--
33
 
34
 
35
--------------------------------------------------------------------------
36
--                                                                      --
37
--                                                                      --
38
--           miniMIPS Processor : miniMIPS processor                    --
39
--                                                                      --
40
--                                                                      --
41
--                                                                      --
42
-- Authors : Hangouet  Samuel                                           --
43
--           Jan       Sébastien                                        --
44
--           Mouton    Louis-Marie                                      --
45
--           Schneider Olivier                                          --
46
--                                                                      --
47
--                                                          june 2003   --
48
--------------------------------------------------------------------------
49
 
50
library ieee;
51
use ieee.std_logic_1164.all;
52
 
53
library work;
54
use work.pack_mips.all;
55
 
56
entity minimips is
57
port (
58
    clock    : in std_logic;
59
    clock2   : in std_logic;
60
    reset    : in std_logic;
61
 
62
    -- Ram connexion
63
    ram_req  : out std_logic;
64
    ram_adr  : out bus32;
65
    ram_r_w  : out std_logic;
66
    ram_data : inout bus32;
67
    ram_ack  : in std_logic;
68
 
69
    ram_req2  : out std_logic;
70
    ram_adr2  : out bus32;
71
    ram_r_w2  : out std_logic;
72
    ram_data2 : inout bus32;
73
    ram_ack2  : in std_logic;
74
 
75
    -- Hardware interruption
76
    it_mat   : in std_logic
77
);
78
end minimips;
79
 
80
architecture rtl of minimips is
81
 
82
    -- General signals
83
    signal stop_all : std_logic;            -- Lock the pipeline evolution
84
    signal stop_all2 : std_logic;           -- Lock the pipeline evolution
85
 
86
    signal it_mat_clk : std_logic;          -- Synchronised hardware interruption
87
    signal stop_pf : std_logic;             -- Lock the pc
88
    signal stop_pf2 : std_logic;            -- Lock the pc
89
    signal genop : std_logic;               -- envoi de nops
90
    signal genop2 : std_logic;              -- envoi de nops
91
    -- interface PF - EI
92
    signal PF_pc : bus32;                   -- PC value
93
    signal PF_pc_4 : bus32;
94
    signal pplc : bus1;                     -- sinal de conflito entre os pipes
95
    signal pplc2 : bus1;                    -- sinal de conflito entre os pipes
96
 
97
    -- interface Controler - EI
98
    signal CTE_instr : bus32;               -- Instruction from the memory
99
    signal ETC_adr : bus32;                 -- Address to read in memory
100
 
101
    -- interface Controler - EI2
102
    signal CTE_instr2 : bus32;               -- Instruction from the memory
103
    signal ETC_adr2 : bus32;                 -- Address to read in memory
104
 
105
    -- interface EI - DI
106
    signal EI_instr : bus32;                -- Read interface
107
    signal EI_adr : bus32;                  -- Address from the read instruction
108
    signal EI_it_ok : std_logic;            -- Allow hardware interruptions
109
 
110
    -- interface EI2 - DI2
111
    signal EI_instr2 : bus32;                -- Read interface
112
    signal EI_adr2 : bus32;                  -- Address from the read instruction
113
    signal EI_it_ok2 : std_logic;            -- Allow hardware interruptions
114
 
115
    -- DI output
116
    signal bra_detect : std_logic;          -- Branch detection in the current instruction
117
 
118
    -- DI2 output
119
    signal bra_detect2 : std_logic;          -- Branch detection in the current instruction
120
 
121
    -- Asynchronous connexion with the bypass unit
122
    signal adr_reg1 : adr_reg_type;         -- Operand 1 address
123
    signal adr_reg2 : adr_reg_type;         -- Operand 2 address
124
    signal use1 : std_logic;                -- Operand 1 utilisation
125
    signal use2 : std_logic;                -- Operand 2 utilisation
126
    signal data1 : bus32;                   -- First register value
127
    signal data2 : bus32;                   -- Second register value
128
    signal alea : std_logic;                -- Unresolved hazards detected
129
 
130
    -- Asynchronous connexion with the bypass unit
131
    signal adr_reg3 : adr_reg_type;         -- Operand 1 address
132
    signal adr_reg4 : adr_reg_type;         -- Operand 2 address
133
    signal use3 : std_logic;                -- Operand 3 utilisation
134
    signal use4 : std_logic;                -- Operand 4 utilisation
135
    signal data3 : bus32;                   -- 3th register value
136
    signal data4 : bus32;                   -- 4th register value
137
    signal alea2 : std_logic;                -- Unresolved hazards detected 2nd pipe
138
 
139
    -- interface DI - EX
140
    signal DI_bra : std_logic;              -- Branch decoded                                        
141
    signal DI_link : std_logic;             -- A link for that instruction                           
142
    signal DI_op1 : bus32;                  -- operand 1 for alu                                     
143
    signal DI_op2 : bus32;                  -- operand 2 for alu                                     
144
    signal DI_code_ual : alu_ctrl_type;     -- Alu operation                                         
145
    signal DI_offset : bus32;               -- Offset for the address calculation                    
146
    signal DI_adr_reg_dest : adr_reg_type;  -- Address of the destination register of the result     
147
    signal DI_ecr_reg : std_logic;          -- Effective writing of the result                       
148
    signal DI_mode : std_logic;             -- Address mode (relative to pc or indexed to a register)
149
    signal DI_op_mem : std_logic;           -- Memory operation request                              
150
    signal DI_r_w : std_logic;              -- Type of memory operation (reading or writing)         
151
    signal DI_adr : bus32;                  -- Address of the decoded instruction                    
152
    signal DI_exc_cause : bus32;            -- Potential exception detected                          
153
    signal DI_level : level_type;           -- Availability of the result for the data bypass        
154
    signal DI_it_ok : std_logic;            -- Allow hardware interruptions
155
 
156
    -- interface DI2 - EX2
157
    signal DI_bra2 : std_logic;              -- Branch decoded                                        
158
    signal DI_link2 : std_logic;             -- A link for that instruction                           
159
    signal DI_op3 : bus32;                  -- operand 1 for alu 2                                     
160
    signal DI_op4 : bus32;                  -- operand 2 for alu 2                                    
161
    signal DI_code_ual2 : alu_ctrl_type;     -- Alu operation                                         
162
    signal DI_offset2 : bus32;               -- Offset for the address calculation                    
163
    signal DI_adr_reg_dest2 : adr_reg_type;  -- Address of the destination register of the result     
164
    signal DI_ecr_reg2 : std_logic;          -- Effective writing of the result                       
165
    signal DI_mode2 : std_logic;             -- Address mode (relative to pc or indexed to a register)
166
    signal DI_op_mem2 : std_logic;           -- Memory operation request                              
167
    signal DI_r_w2 : std_logic;              -- Type of memory operation (reading or writing)         
168
    signal DI_adr2 : bus32;                  -- Address of the decoded instruction                    
169
    signal DI_exc_cause2 : bus32;            -- Potential exception detected                          
170
    signal DI_level2 : level_type;           -- Availability of the result for the data bypass        
171
    signal DI_it_ok2 : std_logic;            -- Allow hardware interruptions 
172
 
173
    -- interface EX - MEM
174
    signal EX_adr : bus32;                  -- Instruction address                       
175
    signal EX_bra_confirm : std_logic;      -- Branch execution confirmation             
176
    signal EX_data_ual : bus32;             -- Ual result                                
177
    signal EX_adresse : bus32;              -- Address calculation result    
178
    signal ex_adresse_p1p2_s  : bus32;      -- resultado do calculo do endereco do desvio + 4 para pipe 2          
179
    signal EX_adr_reg_dest : adr_reg_type;  -- Destination register for the result       
180
    signal EX_ecr_reg : std_logic;          -- Effective writing of the result           
181
    signal EX_op_mem : std_logic;           -- Memory operation needed                   
182
    signal EX_r_w : std_logic;              -- Type of memory operation (read or write)  
183
    signal EX_exc_cause : bus32;            -- Potential cause exception                 
184
    signal EX_level : level_type;           -- Availability stage of result for bypassing
185
    signal EX_it_ok : std_logic;            -- Allow hardware interruptions
186
 
187
    -- interface EX2 - MEM
188
    signal EX_adr2 : bus32;                  -- Instruction address                       
189
    signal EX_bra_confirm2 : std_logic;      -- Branch execution confirmation             
190
    signal EX_data_ual2 : bus32;             -- Ual result                                
191
    signal EX_adresse2 : bus32;              -- Address calculation result   
192
    signal ex_adresse_p2p1_s  : bus32;       -- resultado do calculo do endereco do desvio + 4 para pipe 1        
193
    signal EX_adr_reg_dest2 : adr_reg_type;  -- Destination register for the result       
194
    signal EX_ecr_reg2 : std_logic;          -- Effective writing of the result           
195
    signal EX_op_mem2 : std_logic;           -- Memory operation needed                   
196
    signal EX_r_w2 : std_logic;              -- Type of memory operation (read or write)  
197
    signal EX_exc_cause2 : bus32;            -- Potential cause exception                 
198
    signal EX_level2 : level_type;           -- Availability stage of result for bypassing
199
    signal EX_it_ok2 : std_logic;            -- Allow hardware interruptions
200
 
201
    -- interface Controler - MEM
202
    signal MTC_data : bus32;                -- Data to write in memory 
203
    signal MTC_adr : bus32;                 -- Address for memory      
204
    signal MTC_r_w : std_logic;             -- Read/Write in memory    
205
    signal MTC_req : std_logic;             -- Request access to memory
206
    signal CTM_data : bus32;                -- Data from memory        
207
 
208
    -- interface Controler2 - MEM
209
    signal MTC_data2 : bus32;                -- Data to write in memory 
210
    signal MTC_adr2 : bus32;                 -- Address for memory      
211
    signal MTC_r_w2 : std_logic;             -- Read/Write in memory    
212
    signal MTC_req2 : std_logic;             -- Request access to memory
213
    signal CTM_data2 : bus32;                -- Data from memory  
214
 
215
    -- interface MEM - REG
216
    signal MEM_adr : bus32;                 -- Instruction address                            
217
    signal MEM_adr_reg_dest : adr_reg_type; -- Destination register address                   
218
    signal MEM_ecr_reg : std_logic;         -- Writing of the destination register            
219
    signal MEM_data_ecr : bus32;            -- Data to write (from alu or memory)             
220
    signal MEM_exc_cause : bus32;           -- Potential exception cause                      
221
    signal MEM_level : level_type;          -- Availability stage for the result for bypassing
222
    signal MEM_it_ok : std_logic;           -- Allow hardware interruptions
223
 
224
    -- connexion to the register banks
225
 
226
      -- Writing commands in the register banks
227
    signal write_data : bus32;              -- Data to write                                
228
    signal write_adr : bus5;                -- Address of the register to write             
229
    signal write_GPR : std_logic;           -- Selection in the internal registers          
230
    signal write_SCP : std_logic;           -- Selection in the coprocessor system registers
231
 
232
      -- Reading commands for Reading in the registers
233
    signal read_adr1 : bus5;                -- Address of the first register to read
234
    signal read_adr2 : bus5;                -- Address of the second register to read
235
    signal read_data1_GPR : bus32;          -- Value of operand 1 from the internal registers
236
    signal read_data1_SCP : bus32;          -- Value of operand 2 from the internal registers
237
    signal read_data2_GPR : bus32;          -- Value of operand 1 from the coprocessor system registers
238
    signal read_data2_SCP : bus32;          -- Value of operand 2 from the coprocessor system registers
239
 
240
    -- interface MEM - REG duplicado as entradas e saidas do REG
241
    signal MEM_adr2 : bus32;                 -- Instruction address                            
242
    signal MEM_adr_reg_dest2 : adr_reg_type; -- Destination register address                   
243
    signal MEM_ecr_reg2 : std_logic;         -- Writing of the destination register            
244
    signal MEM_data_ecr2 : bus32;            -- Data to write (from alu or memory)             
245
    signal MEM_exc_cause2 : bus32;           -- Potential exception cause                      
246
    signal MEM_level2 : level_type;          -- Availability stage for the result for bypassing
247
    signal MEM_it_ok2 : std_logic;           -- Allow hardware interruptions
248
 
249
    -- connexion to the register banks
250
 
251
      -- Writing commands in the register banks
252
    signal write_data2 : bus32;              -- Data to write                                
253
    signal write_adr2 : bus5;                -- Address of the register to write             
254
    signal write_GPR2 : std_logic;           -- Selection in the internal registers          
255
    signal write_SCP2 : std_logic;           -- Selection in the coprocessor system registers
256
 
257
      -- Reading commands for Reading in the registers
258
    signal read_adr3 : bus5;                -- Address of the first register to read
259
    signal read_adr4 : bus5;                -- Address of the second register to read
260
    signal read_data3_GPR : bus32;          -- Value of operand 1 from the internal registers
261
    signal read_data3_SCP : bus32;          -- Value of operand 2 from the internal registers
262
    signal read_data4_GPR : bus32;          -- Value of operand 1 from the coprocessor system registers
263
    signal read_data4_SCP : bus32;          -- Value of operand 2 from the coprocessor system registers
264
 
265
    -- Interruption controls
266
    signal vecteur_it    : bus32;           -- Interruption vector         
267
    signal interrupt, interrupt1, interrupt2 : std_logic;       -- Interruption to take into account
268
    signal vecteur_it2    : bus32;           -- Interruption vector 
269
 
270
    -- Sinais atrasados meio ciclo
271
    signal DI_bra_D          : std_logic;
272
    signal bra_detect_D      : std_logic;
273
    signal EX_bra_confirm_D  : std_logic;
274
    signal alea_D            : std_logic;
275
    signal alea2_D           : std_logic;
276
    signal EX_bra_confirm2_D : std_logic;
277
    signal bra_detect2_D     : std_logic;
278
    signal DI_bra2_D         : std_logic;
279
    signal branch1           : std_logic;
280
    signal branch2           : std_logic;
281
    signal genop_S            : std_logic;
282
    signal genop2_S           : std_logic;
283
    signal bra_adr_s          : bus32;
284
    signal bra_adr2_s         : bus32;
285
    -- sinais para resolucao de hazard de dados em operacoes logicas e aritmeticas
286
    signal DI_F1_ADR  : adr_reg_type;
287
    signal DI_F2_ADR  : adr_reg_type;
288
    signal DI2_F3_ADR : adr_reg_type;
289
    signal DI2_F4_ADR : adr_reg_type;
290
    signal iload  : bus1;
291
    signal iload2 : bus1;
292
    signal iload_D  : bus1;
293
    signal iload2_D : bus1;
294
    signal istore  : bus1;
295
    signal istore2 : bus1;
296
    signal istore_D  : bus1;
297
    signal istore2_D : bus1;
298
 
299
    signal aleaEI  : bus1;
300
    signal aleaDI  : bus1;
301
    signal alea2EI2 : bus1;
302
    signal alea2DI2 : bus1;
303
    signal ex2_data_hilo : bus64;--resultado da multiplicacao do pieline2 14-12-18
304
    signal ex_data_hilo  : bus64;--resultado da multiplicacao do pieline1
305
    signal clk : bus1;
306
begin                       --                             180°
307
                            --    ____                     ____                ___     ___
308
    clk <= clock or clock2; -- __|35% |________  or ______|35% |________ = ___|   |___|   |___
309
    interrupt <= interrupt1 or interrupt2;
310
    aleaEI  <= alea  or alea2_D; -- 19-09-2018 tinha esquecido
311
    aleaDI  <= alea  or alea2_D;
312
    alea2EI2 <= alea2 or alea_D;
313
    alea2DI2 <= alea2 or alea_D;
314
 
315
    stop_pf  <= DI_bra or DI_bra2_D or bra_detect or bra_detect2_D or alea or alea2_D or istore2 or istore2_D;
316
    genop    <= bra_detect or bra_detect2_D or EX_bra_confirm  or EX_bra_confirm2_D or DI_bra or DI_bra2_D or istore2 or istore2_D;
317
 
318
    stop_pf2 <= DI_bra2 or DI_bra_D or bra_detect2 or bra_detect_D or alea2 or alea_D or istore or istore_D;
319
    genop2   <= bra_detect2 or bra_detect_D or EX_bra_confirm2 or EX_bra_confirm_D or DI_bra2 or DI_bra_D or istore or istore_D;
320
 
321
    branch1 <= EX_bra_confirm  or EX_bra_confirm2_D;
322
    branch2 <= EX_bra_confirm2 or EX_bra_confirm_D;
323
 
324
    -- muxes para selecionar o endereco do branh apropriado 12-08-2018
325
    with EX_bra_confirm2_D select
326
         bra_adr_s <= ex_adresse_p2p1_s when '1',
327
                      EX_adresse  when others;
328
    with EX_bra_confirm_D select
329
         bra_adr2_s <= ex_adresse_p1p2_s when '1',
330
                       EX_adresse2  when others;
331
 
332
    -- Take into account the hardware interruption on rising edge
333
    process (clock)
334
    begin
335
        if clock='1' and clock'event then
336
            it_mat_clk <= it_mat;
337
        end if;
338
    end process;
339
 
340
    U1_pf : pps_pf port map (
341
        clock => clock,
342
        clock2 => clock2,
343
        reset => reset,
344
        stop_all => stop_all,               -- Unconditionnal locking of the pipeline stage
345
        stop_all2 => stop_all2,
346
        -- entrees asynchrones
347
        bra_adr => bra_adr_s,--EX_adresse,              -- Branch
348
        bra_cmd => branch1,          -- Address to load when an effective branch
349
        exch_adr => vecteur_it,             -- Exception branch
350
        exch_cmd => interrupt,              -- Exception vector
351
        -- entrees asynchrones 24\03\18
352
        bra_adr2 => bra_adr2_s,-- EX_adresse2,              -- Branch
353
        bra_cmd2 => branch2,          -- Address to load when an effective branch
354
        exch_adr2 => vecteur_it2,             -- Exception branch
355
        exch_cmd2 => interrupt2,              -- Exception vector
356
        -- Lock the stage                                    
357
        stop_pf => stop_pf,
358
        stop_pf2 => stop_pf2,--estava errado 'stop_pf' corrigido em 03-04-18
359
        -- Synchronous output to EI stage
360
        PF_pc => PF_pc,                     -- PC value
361
        PF_pc_4 => PF_pc_4
362
    );
363
 
364
 
365
    U2_ei : pps_ei port map (
366
        clock => clock,
367
        reset => reset,
368
        clear => interrupt,         -- Clear the pipeline stage                      
369
        stop_all => stop_all,       -- Evolution locking signal                      
370
 
371
        -- Asynchronous inputs
372
        stop_ei => aleaEI,            -- Lock the EI_adr and Ei_instr registers        
373
        genop => genop,             -- Send nops                                     
374
 
375
        -- interface Controler - EI
376
        CTE_instr => CTE_instr,     -- Instruction from the memory                   
377
        ETC_adr => ETC_adr,         -- Address to read in memory                     
378
 
379
        -- Synchronous inputs from PF stage
380
        PF_pc => PF_pc,             -- Current value of the pc                       
381
 
382
        -- Synchronous outputs to DI stage
383
        EI_instr => EI_instr,       -- Read interface                                
384
        EI_adr => EI_adr,           -- Address from the read instruction             
385
        EI_it_ok => EI_it_ok        -- Allow hardware interruptions
386
    );
387
 
388
 
389
    U3_di : pps_di port map (
390
        clock => clock,
391
        reset => reset,
392
        stop_all => stop_all,               -- Unconditionnal locking of the outputs
393
        clear => interrupt,                 -- Clear the pipeline stage (nop in the outputs)
394
 
395
        -- Asynchronous outputs
396
        bra_detect => bra_detect,           -- Branch detection in the current instruction
397
 
398
        -- Asynchronous connexion with the register management and data bypass unit
399
        adr_reg1 => adr_reg1,               -- Address of the first register operand
400
        adr_reg2 => adr_reg2,               -- Address of the second register operand
401
        use1 => use1,                       -- Effective use of operand 1
402
        use2 => use2,                       -- Effective use of operand 2
403
        iload => iload,
404
        istore => istore,
405
        stop_di => aleaDI,                    -- Unresolved detected : send nop in the pipeline
406
        data1 => data1,                     -- Operand register 1
407
        data2 => data2,                     -- Operand register 2
408
 
409
        -- Datas from EI stage
410
        EI_adr => EI_adr,                   -- Address of the instruction
411
        EI_instr => EI_instr,               -- The instruction to decode
412
        EI_it_ok => EI_it_ok,               -- Allow hardware interruptions
413
 
414
        -- Synchronous output to EX stage
415
        DI_bra => DI_bra,                   -- Branch decoded 
416
        DI_link => DI_link,                 -- A link for that instruction
417
        DI_op1 => DI_op1,                   -- operand 1 for alu
418
        DI_op2 => DI_op2,                   -- operand 2 for alu
419
        DI_code_ual => DI_code_ual,         -- Alu operation
420
        DI_offset => DI_offset,             -- Offset for the address calculation
421
        DI_adr_reg_dest => DI_adr_reg_dest, -- Address of the destination register of the result
422
        DI_ecr_reg => DI_ecr_reg,           -- Effective writing of the result
423
        DI_mode => DI_mode,                 -- Address mode (relative to pc or indexed to a register)
424
        DI_op_mem => DI_op_mem,             -- Memory operation request
425
        DI_r_w => DI_r_w,                   -- Type of memory operation (reading or writing)
426
        DI_adr => DI_adr,                   -- Address of the decoded instruction
427
        DI_exc_cause => DI_exc_cause,       -- Potential exception detected
428
        DI_level => DI_level,               -- Availability of the result for the data bypass
429
        DI_it_ok => DI_it_ok,                -- Allow hardware interruptions
430
        DI_SRC1 => DI_F1_ADR,
431
        DI_SRC2 => DI_F2_ADR
432
    );
433
 
434
 
435
    U4_ex : pps_ex port map (
436
        clock => clock,
437
        clock2 => clock2,
438
        reset => reset,
439
        stop_all => stop_all,
440
        stop_all2 => stop_all2,               -- Unconditionnal locking of outputs
441
        clear => interrupt,                 -- Clear the pipeline stage
442
 
443
        -- Datas from DI stage
444
        DI_bra => DI_bra,                   -- Branch instruction
445
        DI_link => DI_link,                 -- Branch with link
446
        DI_op1 => DI_op1,                   -- Operand 1 for alu
447
        DI_op2 => DI_op2,                   -- Operand 2 for alu
448
        DI_code_ual => DI_code_ual,         -- Alu operation
449
        DI_offset => DI_offset,             -- Offset for address calculation
450
        DI_adr_reg_dest => DI_adr_reg_dest, -- Destination register address for the result
451
        DI_ecr_reg => DI_ecr_reg,           -- Effective writing of the result
452
        DI_mode => DI_mode,                 -- Address mode (relative to pc ou index by a register)
453
        DI_op_mem => DI_op_mem,             -- Memory operation
454
        DI_r_w => DI_r_w,                   -- Type of memory operation (read or write)
455
        DI_adr => DI_adr,                   -- Instruction address
456
        DI_exc_cause => DI_exc_cause,       -- Potential cause exception
457
        DI_level => DI_level,               -- Availability stage of the result for bypassing
458
        DI_it_ok => DI_it_ok,               -- Allow hardware interruptions
459
 
460
        EX2_data_hilo =>  ex2_data_hilo,    -- entrada p resultado do hilo p2  
461
        EX_data_hilo =>   ex_data_hilo,     -- saida p resultado do hilo p1                                                                                       
462
        -- Synchronous outputs to MEM stage
463
        EX_adr => EX_adr,                   -- Instruction address
464
        EX_bra_confirm => EX_bra_confirm,   -- Branch execution confirmation
465
        EX_data_ual => EX_data_ual,         -- Ual result
466
        EX_adresse => EX_adresse,           -- Address calculation result
467
        EX_adresse_p1p2 => ex_adresse_p1p2_s, --resultado do calculo do endereco do desvio + 4 para pipe 2. 12-08-2018
468
        EX_adr_reg_dest => EX_adr_reg_dest, -- Destination register for the result
469
        EX_ecr_reg => EX_ecr_reg,           -- Effective writing of the result
470
        EX_op_mem => EX_op_mem,             -- Memory operation needed
471
        EX_r_w => EX_r_w,                   -- Type of memory operation (read or write)
472
        EX_exc_cause => EX_exc_cause,       -- Potential cause exception
473
        EX_level => EX_level,               -- Availability stage of result for bypassing
474
        EX_it_ok => EX_it_ok                -- Allow hardware interruptions
475
    );
476
 
477
 
478
    U5_mem : pps_mem port map (
479
        clock => clock,
480
        clock2 => clock2,
481
        reset => reset,
482
        stop_all => stop_all,               -- Unconditionnal locking of the outputs
483
        stop_all2 => stop_all2,
484
 
485
        clear => interrupt,                 -- Clear the pipeline stage
486
 
487
        -- Interface with the control bus
488
        MTC_data => MTC_data,               -- Data to write in memory
489
        MTC_adr => MTC_adr,                 -- Address for memory
490
        MTC_r_w => MTC_r_w,                 -- Read/Write in memory
491
        MTC_req => MTC_req,                 -- Request access to memory
492
        CTM_data => CTM_data,               -- Data from memory
493
 
494
        -- Datas from Execution stage
495
        EX_adr => EX_adr,                   -- Instruction address
496
        EX_data_ual => EX_data_ual,         -- Result of alu operation
497
        EX_adresse => EX_adresse,           -- Result of the calculation of the address
498
        EX_adresse_p1p2 => ex_adresse_p1p2_s, --resultado do calculo do endereco do desvio + 4 para pipe 2. 12-08-2018
499
        EX_bra_confirm => EX_bra_confirm,   -- Confirmacao do branch no pipe 1 (26-07-18)
500
        EX_adr_reg_dest => EX_adr_reg_dest, -- Destination register address for the result
501
        EX_ecr_reg => EX_ecr_reg,           -- Effective writing of the result
502
        EX_op_mem => EX_op_mem,             -- Memory operation needed
503
        EX_r_w => EX_r_w,                   -- Type of memory operation (read or write)
504
        EX_exc_cause => EX_exc_cause,       -- Potential exception cause
505
        EX_level => EX_level,               -- Availability stage for the result for bypassing
506
        EX_it_ok => EX_it_ok,               -- Allow hardware interruptions
507
 
508
        -- Synchronous outputs for bypass unit
509
        MEM_adr => MEM_adr,                 -- Instruction address
510
        MEM_adr_reg_dest=>MEM_adr_reg_dest, -- Destination register address
511
        MEM_ecr_reg => MEM_ecr_reg,         -- Writing of the destination register
512
        MEM_data_ecr => MEM_data_ecr,       -- Data to write (from alu or memory)
513
        MEM_exc_cause => MEM_exc_cause,     -- Potential exception cause
514
        MEM_level => MEM_level,             -- Availability stage for the result for bypassing
515
        MEM_it_ok => MEM_it_ok,             -- Allow hardware interruptions
516
                -- duplicacao
517
        -- Interface with the control bus
518
        MTC_data2 => MTC_data2,               -- Data to write in memory
519
        MTC_adr2 => MTC_adr2,                 -- Address for memory
520
        MTC_r_w2 => MTC_r_w2,                 -- Read/Write in memory
521
        MTC_req2 => MTC_req2,                 -- Request access to memory
522
        CTM_data2 => CTM_data2,               -- Data from memory
523
 
524
        -- Datas from Execution 2 stage
525
        EX_adr2 => EX_adr2,                   -- Instruction address
526
        EX_data_ual2 => EX_data_ual2,         -- Result of alu operation
527
        EX_adresse2 => EX_adresse2,           -- Result of the calculation of the address
528
        EX_adresse_p2p1 => ex_adresse_p2p1_s, --resultado do calculo do endereco do desvio + 4 para pipe 1. 12-08-2018
529
        EX_bra_confirm2 => EX_bra_confirm2,   -- Confirmacao do branch no pipe 2 (26-07-18)
530
        EX_adr_reg_dest2 => EX_adr_reg_dest2, -- Destination register address for the result
531
        EX_ecr_reg2 => EX_ecr_reg2,           -- Effective writing of the result
532
        EX_op_mem2 => EX_op_mem2,             -- Memory operation needed
533
        EX_r_w2 => EX_r_w2,                   -- Type of memory operation (read or write)
534
        EX_exc_cause2 => EX_exc_cause2,       -- Potential exception cause
535
        EX_level2 => EX_level2,               -- Availability stage for the result for bypassing
536
        EX_it_ok2 => EX_it_ok2,               -- Allow hardware interruptions
537
 
538
        -- Synchronous outputs for bypass unit
539
        MEM_adr2 => MEM_adr2,                 -- Instruction address
540
        MEM_adr_reg_dest2=>MEM_adr_reg_dest2, -- Destination register address
541
        MEM_ecr_reg2 => MEM_ecr_reg2,         -- Writing of the destination register
542
        MEM_data_ecr2 => MEM_data_ecr2,       -- Data to write (from alu or memory)
543
        MEM_exc_cause2 => MEM_exc_cause2,     -- Potential exception cause
544
        MEM_level2 => MEM_level2,             -- Availability stage for the result for bypassing
545
        MEM_it_ok2 => MEM_it_ok2             -- Allow hardware interruptions
546
    );
547
 
548
 
549
    U6_renvoi : renvoi port map (
550
        -- Register access signals
551
        adr1 => adr_reg1,                   -- Operand 1 address
552
        adr2 => adr_reg2,                   -- Operand 2 address
553
        use1 => use1,                       -- Operand 1 utilisation
554
        use2 => use2,                       -- Operand 2 utilisation
555
 
556
        data1 => data1,                     -- First register value
557
        data2 => data2,                     -- Second register value
558
        alea => alea,                       -- Unresolved hazards detected
559
 
560
        -- Bypass signals of the intermediary datas
561
        DI_level => DI_level,               -- Availability level of the data
562
        DI_adr => DI_adr_reg_dest,          -- Register destination of the result
563
        DI_ecr => DI_ecr_reg,               -- Writing register request
564
        DI_data => DI_op2,                  -- Data to used
565
 
566
        EX_level => EX_level,               -- Availability level of the data
567
        EX_adr => EX_adr_reg_dest,          -- Register destination of the result
568
        EX_ecr => EX_ecr_reg,               -- Writing register request
569
        EX_data => EX_data_ual,             -- Data to used
570
 
571
        MEM_level => MEM_level,             -- Availability level of the data
572
        MEM_adr => MEM_adr_reg_dest,        -- Register destination of the result
573
        MEM_ecr => MEM_ecr_reg,             -- Writing register request
574
        MEM_data => MEM_data_ecr,           -- Data to used
575
 
576
        interrupt => interrupt,             -- Exceptions or interruptions
577
 
578
        -- Connexion to the differents bank of register
579
 
580
          -- Writing commands for writing in the registers
581
        write_data => write_data,           -- Data to write
582
        write_adr => write_adr,             -- Address of the register to write
583
        write_GPR => write_GPR,             -- Selection in the internal registers
584
        write_SCP => write_SCP,             -- Selection in the coprocessor system registers
585
 
586
          -- Reading commands for Reading in the registers
587
        read_adr1 => read_adr1,             -- Address of the first register to read
588
        read_adr2 => read_adr2,             -- Address of the second register to read
589
        read_data1_GPR => read_data1_GPR,   -- Value of operand 1 from the internal registers
590
        read_data1_SCP => read_data1_SCP,   -- Value of operand 2 from the internal registers
591
        read_data2_GPR => read_data2_GPR,   -- Value of operand 1 from the coprocessor system registers
592
        read_data2_SCP => read_data2_SCP,    -- Value of operand 2 from the coprocessor system registers
593
        -- duplicacao
594
        -- Register access signals
595
        adr3 => adr_reg3,                   -- Operand 1 address
596
        adr4 => adr_reg4,                   -- Operand 2 address
597
        use12 => use3,                       -- Operand 1 utilisation
598
        use22 => use4,                       -- Operand 2 utilisation
599
 
600
        data3 => data3,                     -- First register value
601
        data4 => data4,                     -- Second register value
602
        alea2 => alea2,                       -- Unresolved hazards detected
603
 
604
        -- Bypass signals of the intermediary datas
605
        DI_level2 => DI_level2,               -- Availability level of the data
606
        DI_adr2 => DI_adr_reg_dest2,          -- Register destination of the result
607
        DI_ecr2 => DI_ecr_reg2,               -- Writing register request
608
        DI_data2 => DI_op4,                  -- Data to used
609
 
610
        EX_level2 => EX_level2,               -- Availability level of the data
611
        EX_adr2 => EX_adr_reg_dest2,          -- Register destination of the result
612
        EX_ecr2 => EX_ecr_reg2,               -- Writing register request
613
        EX_data2 => EX_data_ual2,             -- Data to used
614
 
615
        MEM_level2 => MEM_level2,             -- Availability level of the data
616
        MEM_adr2 => MEM_adr_reg_dest2,        -- Register destination of the result
617
        MEM_ecr2 => MEM_ecr_reg2,             -- Writing register request
618
        MEM_data2 => MEM_data_ecr2,           -- Data to used
619
 
620
 
621
        -- Connexion to the differents bank of register
622
 
623
          -- Writing commands for writing in the registers
624
        write_data2 => write_data2,           -- Data to write
625
        write_adr2 => write_adr2,             -- Address of the register to write
626
        write_GPR2 => write_GPR2,             -- Selection in the internal registers
627
        write_SCP2 => write_SCP,             -- Selection in the coprocessor system registers
628
 
629
          -- Reading commands for Reading in the registers
630
        read_adr3 => read_adr3,             -- Address of the first register to read
631
        read_adr4 => read_adr4,             -- Address of the second register to read
632
        read_data3_GPR => read_data3_GPR,   -- Value of operand 1 from the internal registers
633
        read_data3_SCP => read_data3_SCP,   -- Value of operand 2 from the internal registers
634
        read_data4_GPR => read_data4_GPR,   -- Value of operand 1 from the coprocessor system registers
635
        read_data4_SCP => read_data4_SCP    -- Value of operand 2 from the coprocessor system registers
636
    );
637
 
638
 
639
    U7_banc : banc port map(
640
        clock => clock,
641
        clock2 => clock2,
642
        reset => reset,
643
 
644
        -- Register addresses to read
645
        reg_src1 => read_adr1,
646
        reg_src2 => read_adr2,
647
 
648
        -- Register address to write and its data
649
        reg_dest => write_adr,
650
        donnee   => write_data,
651
 
652
        -- Write signal
653
        cmd_ecr  => write_GPR,
654
 
655
        -- Bank outputs
656
        data_src1 => read_data1_GPR,
657
        data_src2 => read_data2_GPR,
658
 
659
        -- Register addresses to read
660
        reg_src3 => read_adr3,
661
        reg_src4 => read_adr4,
662
 
663
        -- Register address to write and its data
664
        reg_dest2 => write_adr2,
665
        donnee2   => write_data2,
666
 
667
        -- Write signal
668
        cmd_ecr2  => write_GPR2,
669
 
670
        -- Bank outputs
671
        data_src3 => read_data3_GPR,
672
        data_src4 => read_data4_GPR
673
    );
674
 
675
 
676
    U8_syscop : syscop port map (
677
        clock         => clock,
678
        clock2        => clock2,
679
        reset         => reset,
680
 
681
        -- Datas from the pipeline
682
        MEM_adr       => MEM_adr,           -- Address (PC) of the current instruction in the pipeline end -> responsible of the exception
683
        MEM_exc_cause => MEM_exc_cause,     -- Potential cause exception of that instruction
684
        MEM_it_ok     => MEM_it_ok,         -- Allow hardware interruptions
685
 
686
        -- Hardware interruption P1
687
        it_mat        => it_mat_clk,        -- Hardware interruption detected
688
 
689
        -- Interruption controls P1
690
        interrupt     => interrupt1,         -- Interruption to take into account
691
        vecteur_it    => vecteur_it,        -- Interruption vector
692
 
693
        -- Writing request in register bank
694
        write_data    => write_data,        -- Data to write
695
        write_adr     => write_adr,         -- Address of the register to write
696
        write_SCP     => write_SCP,         -- Writing request
697
 
698
        -- Reading request in register bank
699
        read_adr1     => read_adr1,         -- Address of the first register
700
        read_adr2     => read_adr2,         -- Address of the second register
701
        read_data1    => read_data1_SCP,    -- Value of register 1
702
        read_data2    => read_data2_SCP,     -- Value of register 2
703
--mod
704
        MEM_adr2       => MEM_adr2,
705
        MEM_exc_cause2 => MEM_exc_cause2,
706
        MEM_it_ok2     => MEM_it_ok2,
707
 
708
        -- Hardware interruption P2
709
        it_mat2        => it_mat_clk,        -- Hardware interruption detected
710
 
711
        -- Interruption controls P2
712
        interrupt2     => interrupt2,         -- Interruption to take into account
713
        vecteur_it2    => vecteur_it2,        -- Interruption vector
714
 
715
        write_data2    => write_data2,
716
        write_adr2     => write_adr2,
717
        write_SCP2     => write_SCP2,
718
 
719
        read_adr3     => read_adr3,
720
        read_adr4     => read_adr4,
721
        read_data3    => read_data3_SCP,
722
        read_data4    => read_data4_SCP
723
    );
724
 
725
 
726
    U9_bus_ctrl01 : bus_ctrl01 port map (
727
        clock          => clock,
728
        reset          => reset,
729
 
730
        -- Interruption in the pipeline
731
        interrupt      => interrupt,
732
 
733
        -- Interface for the Instruction Extraction Stage
734
        adr_from_ei    => ETC_adr,          -- The address of the data to read
735
        instr_to_ei    => CTE_instr,        -- Instruction from the memory                                                      
736
        -- Interface with the MEMory Stage
737
        req_from_mem   => MTC_req,          -- Request to access the ram
738
        r_w_from_mem   => MTC_r_w,          -- Read/Write request
739
        adr_from_mem   => MTC_adr,          -- Address in ram
740
        data_from_mem  => MTC_data,         -- Data to write in ram
741
        data_to_mem    => CTM_data,         -- Data from the ram to the MEMory stage      
742
 
743
        -- RAM interface signals
744
        req_to_ram     => ram_req,          -- Request to ram
745
        adr_to_ram     => ram_adr,          -- Address of the data to read or write
746
        r_w_to_ram     => ram_r_w,          -- Read/Write request
747
        ack_from_ram   => ram_ack,          -- Acknowledge from the memory
748
        data_inout_ram => ram_data,         -- Data from/to the memory
749
 
750
        -- Pipeline progress control signal
751
        stop_all       => stop_all
752
    );
753
 
754
 
755
    U10_ei_2 :  pps_ei_2 port map (
756
        clock => clock2,
757
        reset => reset,
758
        clear => interrupt,         -- Clear the pipeline stage                      
759
        stop_all2 => stop_all2,       -- Evolution locking signal                      
760
 
761
        -- Asynchronous inputs
762
        stop_ei => alea2EI2,            -- Lock the EI_adr and Ei_instr registers        
763
        genop => genop2,             -- Send nops                                     
764
 
765
        -- interface Controler - EI
766
        CTE_instr => CTE_instr2,     -- Instruction from the memory                   
767
        ETC_adr => ETC_adr2,         -- Address to read in memory (ja feito pelo EI)                     
768
 
769
        -- Synchronous inputs from PF stage
770
        PF_pc => PF_pc_4,             -- Current value of the pc + 4                     
771
 
772
        -- Synchronous outputs to DI stage
773
        EI_instr => EI_instr2,       -- Read interface                                
774
        EI_adr => EI_adr2,           -- Address from the read instruction             
775
        EI_it_ok => EI_it_ok2        -- Allow hardware interruptions
776
    );
777
 
778
 
779
    U11_di2 : pps_di_2 port map (
780
        clock => clock2,
781
        reset => reset,
782
        stop_all2 => stop_all2,               -- Unconditionnal locking of the outputs
783
        clear => interrupt,                 -- Clear the pipeline stage (nop in the outputs)
784
 
785
        -- Asynchronous outputs
786
        bra_detect => bra_detect2,           -- Branch detection in the current instruction
787
 
788
        -- Asynchronous connexion with the register management and data bypass unit
789
        adr_reg1 => adr_reg3,               -- Address of the first register operand
790
        adr_reg2 => adr_reg4,               -- Address of the second register operand
791
        use1 => use3,                       -- Effective use of operand 1
792
        use2 => use4,                       -- Effective use of operand 2
793
        iload2 => iload2,
794
        istore2 => istore2,
795
        stop_di => alea2DI2,                    -- Unresolved detected : send nop in the pipeline
796
        data1 => data3,                     -- Operand register 1
797
        data2 => data4,                     -- Operand register 2
798
 
799
        -- Datas from EI stage
800
        EI_adr => EI_adr2,                   -- Address of the instruction
801
        EI_instr => EI_instr2,               -- The instruction to decode
802
        EI_it_ok => EI_it_ok2,               -- Allow hardware interruptions
803
 
804
        -- Synchronous output to EX2 stage
805
        DI_bra => DI_bra2,                   -- Branch decoded 
806
        DI_link => DI_link2,                 -- A link for that instruction
807
        DI_op1 => DI_op3,                   -- operand 1 for alu
808
        DI_op2 => DI_op4,                   -- operand 2 for alu
809
        DI_code_ual => DI_code_ual2,         -- Alu operation
810
        DI_offset => DI_offset2,             -- Offset for the address calculation
811
        DI_adr_reg_dest => DI_adr_reg_dest2, -- Address of the destination register of the result
812
        DI_ecr_reg => DI_ecr_reg2,           -- Effective writing of the result
813
        DI_mode => DI_mode2,                 -- Address mode (relative to pc or indexed to a register)
814
        DI_op_mem => DI_op_mem2,             -- Memory operation request
815
        DI_r_w => DI_r_w2,                   -- Type of memory operation (reading or writing)
816
        DI_adr => DI_adr2,                   -- Address of the decoded instruction
817
        DI_exc_cause => DI_exc_cause2,       -- Potential exception detected
818
        DI_level => DI_level2,               -- Availability of the result for the data bypass
819
        DI_it_ok => DI_it_ok2,               -- Allow hardware interruptions
820
        DI2_SRC3 => DI2_F3_ADR,
821
        DI2_SRC4 => DI2_F4_ADR
822
    );
823
 
824
 
825
    U12_ex2 : pps_ex_2 port map (
826
        clock => clock,
827
        clock2 => clock2,
828
        reset => reset,
829
        stop_all => stop_all,
830
        stop_all2 => stop_all2,               -- Unconditionnal locking of outputs
831
        clear => interrupt,                 -- Clear the pipeline stage
832
 
833
        -- Datas from DI2 stage
834
        DI_bra => DI_bra2,                   -- Branch instruction
835
        DI_link => DI_link2,                 -- Branch with link
836
        DI_op1 => DI_op3,                   -- Operand 1 for alu 
837
        DI_op2 => DI_op4,                   -- Operand 2 for alu
838
        DI_code_ual => DI_code_ual2,         -- Alu operation
839
        DI_offset => DI_offset2,             -- Offset for address calculation
840
        DI_adr_reg_dest => DI_adr_reg_dest2, -- Destination register address for the result
841
        DI_ecr_reg => DI_ecr_reg2,           -- Effective writing of the result
842
        DI_mode => DI_mode2,                 -- Address mode (relative to pc ou index by a register)
843
        DI_op_mem => DI_op_mem2,             -- Memory operation
844
        DI_r_w => DI_r_w2,                   -- Type of memory operation (read or write)
845
        DI_adr => DI_adr2,                   -- Instruction address
846
        DI_exc_cause => DI_exc_cause2,       -- Potential cause exception
847
        DI_level => DI_level2,               -- Availability stage of the result for bypassing
848
        DI_it_ok => DI_it_ok2,               -- Allow hardware interruptions
849
 
850
        EX2_data_hilo =>  ex2_data_hilo,     -- saida p resultado do hilo p2  
851
        EX_data_hilo =>   ex_data_hilo,      -- entrada p resultado do hilo p1  
852
        -- Synchronous outputs to MEM stage
853
        EX_adr => EX_adr2,                   -- Instruction address
854
        EX_bra_confirm => EX_bra_confirm2,   -- Branch execution confirmation
855
        EX_data_ual => EX_data_ual2,         -- Ual result
856
        EX_adresse => EX_adresse2,           -- Address calculation result
857
        EX_adresse_p2p1 => ex_adresse_p2p1_s, --resultado do calculo do endereco do desvio + 4 para pipe 1. 12-08-2018
858
        EX_adr_reg_dest => EX_adr_reg_dest2, -- Destination register for the result
859
        EX_ecr_reg => EX_ecr_reg2,           -- Effective writing of the result
860
        EX_op_mem => EX_op_mem2,             -- Memory operation needed
861
        EX_r_w => EX_r_w2,                   -- Type of memory operation (read or write)
862
        EX_exc_cause => EX_exc_cause2,       -- Potential cause exception
863
        EX_level => EX_level2,               -- Availability stage of result for bypassing
864
        EX_it_ok => EX_it_ok2                -- Allow hardware interruptions
865
    );
866
 
867
 U13_bus_ctrl02 : bus_ctrl02 port map (
868
        clock          => clock2,
869
        reset          => reset,
870
 
871
        -- Interruption in the pipeline
872
        interrupt      => interrupt,
873
 
874
        -- Interface for the Instruction Extraction Stage
875
        adr_from_ei    => ETC_adr2,          -- The address of the data to read
876
        instr_to_ei    => CTE_instr2,        -- Instruction from the memory                                                         
877
        -- Interface with the MEMory Stage
878
        req_from_mem   => MTC_req2,          -- Request to access the ram
879
        r_w_from_mem   => MTC_r_w2,          -- Read/Write request
880
        adr_from_mem   => MTC_adr2,          -- Address in ram
881
        data_from_mem  => MTC_data2,         -- Data to write in ram
882
        data_to_mem    => CTM_data2,         -- Data from the ram to the MEMory stage     
883
 
884
        -- RAM interface signals
885
        req_to_ram     => ram_req2,          -- Request to ram
886
        adr_to_ram     => ram_adr2,          -- Address of the data to read or write
887
        r_w_to_ram     => ram_r_w2,          -- Read/Write request
888
        ack_from_ram   => ram_ack2,          -- Acknowledge from the memory
889
        data_inout_ram => ram_data2,         -- Data from/to the memory
890
 
891
        -- Pipeline progress control signal
892
        stop_all       => stop_all2
893
    );
894
 
895
U15_delay_gate : delay_gate port map (
896
        clock => clk,
897
        in1   => DI_bra,
898
        in2   => bra_detect,
899
        in3   => EX_bra_confirm,
900
        in4   => alea,
901
        in5   => alea2,
902
        in6   => EX_bra_confirm2,
903
        in7   => bra_detect2,
904
        in8   => DI_bra2,
905
        in9   => istore,
906
        in10  => istore2,
907
        in11  => iload,
908
        in12  => iload2,
909
        out1  => DI_bra_D,
910
        out2  => bra_detect_D,
911
        out3  => EX_bra_confirm_D,
912
        out4  => alea_D,
913
        out5  => alea2_D,
914
        out6  => EX_bra_confirm2_D,
915
        out7  => bra_detect2_D,
916
        out8  => DI_bra2_D,
917
        out9  => istore_D,
918
        out10 => istore2_D,
919
        out11 => iload_D,
920
        out12 => iload2_D
921
    );
922
end rtl;

powered by: WebSVN 2.1.0

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