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

Subversion Repositories minimips_superscalar

[/] [minimips_superscalar/] [trunk/] [sources/] [minimips.vhd] - Blame information for rev 2

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

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

powered by: WebSVN 2.1.0

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