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

Subversion Repositories minimips_superscalar

[/] [minimips_superscalar/] [trunk/] [sources/] [pps_ex_2.vhd] - Blame information for rev 20

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 : Execution stage 2                   --
5
-- based on miniMIPS Processor                                          --
6
--                                                                      --
7
--                                                                      --
8
-- Author : Miguel Cafruni                                              --
9
-- miguel_cafruni@hotmail.com                                           --
10
--                                                      December 2018   --
11
--------------------------------------------------------------------------
12
 
13
library IEEE;
14
use IEEE.std_logic_1164.all;
15
use IEEE.numeric_std.all;
16
 
17
library work;
18
use work.pack_mips.all;
19
use work.alu2;
20
 
21
entity pps_ex_2 is
22
port(
23
    clock : in std_logic;
24
    clock2 : in std_logic;
25
    reset : in std_logic;
26
    stop_all : in std_logic; -- 07-08-2018
27
    stop_all2 : in std_logic;           -- Unconditionnal locking of outputs
28
    clear : in std_logic;               -- Clear the pipeline stage
29
 
30
    -- Datas from DI stage
31
    DI_bra : in std_logic;              -- Branch instruction
32
    DI_link : in std_logic;             -- Branch with link
33
    DI_op1 : in bus32;                  -- Operand 1 for alu (vem zero quando a instrucao eh um J (jump)
34
    DI_op2 : in bus32;                  -- Operand 2 for alu
35
    DI_code_ual : in alu_ctrl_type;     -- Alu operation
36
    DI_offset : in bus32;               -- Offset for address calculation
37
    DI_adr_reg_dest : in adr_reg_type;  -- Destination register address for the result
38
    DI_ecr_reg : in std_logic;          -- Effective writing of the result
39
    DI_mode : in std_logic;             -- Address mode (relative to pc ou index by a register)
40
    DI_op_mem : in std_logic;           -- Memory operation
41
    DI_r_w : in std_logic;              -- Type of memory operation (read or write)
42
    DI_adr : in bus32;                  -- Instruction address
43
    DI_exc_cause : in bus32;            -- Potential cause exception
44
    DI_level : in level_type;           -- Availability stage of the result for bypassing
45
    DI_it_ok : in std_logic;            -- Allow hardware interruptions
46
 
47
    EX_data_hilo : in bus64;--resultado da multiplicacao do pieline 1
48
    EX2_data_hilo : out bus64;
49
    -- Synchronous outputs to MEM stage
50
    EX_adr : out bus32;                 -- Instruction address
51
    EX_bra_confirm : out std_logic;     -- Branch execution confirmation
52
    EX_data_ual : out bus32;            -- Ual result
53
    EX_adresse : out bus32;             -- Address calculation result
54
    EX_adresse_p2p1 : out bus32;        -- resultado do calculo do endereco do desvio + 4 para pipe 1
55
    EX_adr_reg_dest : out adr_reg_type; -- Destination register for the result
56
    EX_ecr_reg : out std_logic;         -- Effective writing of the result
57
    EX_op_mem : out std_logic;          -- Memory operation needed
58
    EX_r_w : out std_logic;             -- Type of memory operation (read or write)
59
    EX_exc_cause : out bus32;           -- Potential cause exception
60
    EX_level : out level_type;          -- Availability stage of result for bypassing
61
    EX_it_ok : out std_logic            -- Allow hardware interruptions
62
);
63
end entity;
64
 
65
 
66
architecture rtl of pps_ex_2 is
67
 
68
component alu2
69
    port (
70
        clock : in bus1;
71
        reset : in bus1;
72
        op1 : in bus32; -- Operand 1
73
        op2 : in bus32; -- Operand 2
74
        ctrl : in alu_ctrl_type; -- Operation
75
        hilo_p1 : in bus64;
76
        hilo_p2p1 : out bus64;
77
        res : out bus32; -- Result
78
        overflow : out bus1 -- Overflow
79
    );
80
    end component;
81
 
82
    signal res_ual         : bus32;      -- Alu result output
83
    signal base_adr        : bus32;      -- Output of the address mode mux selection
84
 
85
    signal pre_ecr_reg     : std_logic;  -- Output of mux selection for writing command to register
86
    signal pre_data_ual    : bus32;      -- Mux selection of the data to write
87
    signal pre_bra_confirm : std_logic;  -- Result of the test in alu when branch instruction
88
    signal pre_exc_cause   : bus32;      -- Preparation of the exception detection signal
89
    signal overflow_ual    : std_logic;  -- Dectection of the alu overflow
90
    signal ex_address_p2p1   : bus32;
91
    signal hilo_p2p1_s  : bus64;
92
begin
93
 
94
    -- Alu instantiation
95
    U1_alu_2 : alu2 port map (clock => clock2, reset => reset, op1=>DI_op1, op2=>DI_op2, ctrl=>DI_code_ual,
96
                                res=>res_ual, overflow=>overflow_ual, hilo_p1=>EX_data_hilo, hilo_p2p1=>hilo_p2p1_s);
97
 
98
    -- Calculation of the future outputs
99
    base_adr <= DI_op1 when DI_mode='0' else DI_adr;
100
    pre_ecr_reg <= DI_ecr_reg when DI_link='0' else pre_bra_confirm;
101
    pre_data_ual <= res_ual when DI_link='0' else bus32(unsigned(DI_adr) + 8);
102
    pre_bra_confirm <= DI_bra and res_ual(0);
103
    pre_exc_cause <= DI_exc_cause when DI_exc_cause/=IT_NOEXC else
104
                     IT_OVERF when overflow_ual='1' else
105
                     IT_NOEXC;
106
 
107
    -- Set the synchronous outputs
108
    process(clock2) is
109
    begin
110
        if falling_edge(clock2) then
111
            if reset='1' then
112
                EX_adr <= (others => '0');
113
                EX_bra_confirm <= '0';
114
                EX_data_ual <= (others => '0');
115
                EX_adresse <= (others => '0');
116
                EX_adr_reg_dest <= (others => '0');
117
                EX_ecr_reg <= '0';
118
                EX_op_mem <= '0';
119
                EX_r_w <= '0';
120
                EX_exc_cause <= IT_NOEXC;
121
                EX_level <= LVL_DI;
122
                EX_it_ok <= '0';
123
            elsif stop_all2 = '0' then
124
                if clear = '1' then -- Clear the stage
125
                    EX_adr <= DI_adr;
126
                    EX_bra_confirm <= '0';
127
                    EX_data_ual <= (others => '0');
128
                    EX_adresse <= (others => '0');
129
                    EX_adr_reg_dest <= (others => '0');
130
                    EX_ecr_reg <= '0';
131
                    EX_op_mem <= '0';
132
                    EX_r_w <= '0';
133
                    EX_exc_cause <= IT_NOEXC;
134
                    EX_level <= LVL_DI;
135
                    EX_it_ok <= '0';
136
                else -- Normal evolution
137
                    EX_adr <= DI_adr;
138
                    EX_bra_confirm <= pre_bra_confirm;
139
                    EX_data_ual <= pre_data_ual;
140
                    EX_adr_reg_dest <= DI_adr_reg_dest;
141
                    EX_ecr_reg <= pre_ecr_reg;
142
                    EX_op_mem <= DI_op_mem;
143
                    EX_r_w <= DI_r_w;
144
                    EX_exc_cause <= pre_exc_cause;
145
                    EX_level <= DI_level;
146
                    EX_it_ok <= DI_it_ok;
147
                              EX_adresse <= bus32(unsigned(DI_offset) + unsigned(base_adr)); -- calculo do endereco do branch fora da ULA, [offset + pc atual] (BNE), ou [offset + 0] (J)
148
                         ex_address_p2p1 <= bus32(unsigned(DI_offset) + unsigned(base_adr));
149
                end if;
150
            end if;
151
        end if;
152
 
153
        if rising_edge(clock) then
154
                if reset = '1' then
155
                        EX_adresse_p2p1 <= (others => '0');
156
                        EX2_data_hilo <= (others => '0');
157
                elsif stop_all = '0' then -- sinal stop_all do pipe 1
158
                        EX2_data_hilo <= hilo_p2p1_s;
159
                        EX_adresse_p2p1 <= bus32(unsigned(ex_address_p2p1) + 4); --*** endereco alvo para o pipe 1 ***
160
                end if;
161
 
162
        end if;
163
    end process;
164
 
165
end architecture;

powered by: WebSVN 2.1.0

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