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

Subversion Repositories minimips_superscalar

[/] [minimips_superscalar/] [trunk/] [sources/] [pps_ex.vhd] - Blame information for rev 3

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                     --
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.alu;
20
 
21
entity pps_ex is
22
port(
23
    clock : in std_logic;
24
    clock2 : in std_logic;
25
    reset : in std_logic;
26
    stop_all : in std_logic;            -- Unconditionnal locking of outputs
27
    stop_all2 : in std_logic; -- 07-08-2018
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
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
    EX2_data_hilo : in bus64;--resultado da multiplicacao do pieline2
47
    EX_data_hilo : out bus64;
48
    -- Synchronous outputs to MEM stage
49
    EX_adr : out bus32;                 -- Instruction address
50
    EX_bra_confirm : out std_logic;     -- Branch execution confirmation
51
    EX_data_ual : out bus32;            -- Ual result
52
    EX_adresse : out bus32;             -- Address calculation result
53
    EX_adresse_p1p2 : out bus32;        -- resultado do calculo do endereco do desvio + 4 para pipe 2
54
    EX_adr_reg_dest : out adr_reg_type; -- Destination register for the result
55
    EX_ecr_reg : out std_logic;         -- Effective writing of the result
56
    EX_op_mem : out std_logic;          -- Memory operation needed
57
    EX_r_w : out std_logic;             -- Type of memory operation (read or write)
58
    EX_exc_cause : out bus32;           -- Potential cause exception
59
    EX_level : out level_type;          -- Availability stage of result for bypassing
60
    EX_it_ok : out std_logic            -- Allow hardware interruptions
61
);
62
end entity;
63
 
64
 
65
architecture rtl of pps_ex is
66
 
67
component alu
68
    port (
69
        clock : in bus1;
70
        reset : in bus1;
71
        op1 : in bus32;                 -- Operand 1
72
        op2 : in bus32;                 -- Operand 2
73
        ctrl : in alu_ctrl_type;        -- Operation
74
        hilo_p2 : in bus64;
75
        hilo_p1p2 : out bus64;
76
        res : out bus32;                -- Result
77
        overflow : out bus1             -- Overflow
78
    );
79
    end component;
80
 
81
    signal res_ual         : bus32;      -- Alu result output
82
    signal base_adr        : bus32;      -- Output of the address mode mux selection
83
    signal pre_ecr_reg     : std_logic;  -- Output of mux selection for writing command to register
84
    signal pre_data_ual    : bus32;      -- Mux selection of the data to write
85
    signal pre_bra_confirm : std_logic;  -- Result of the test in alu when branch instruction
86
    signal pre_exc_cause   : bus32;      -- Preparation of the exception detection signal
87
    signal overflow_ual    : std_logic;  -- Dectection of the alu overflow
88
    signal ex_address_p1p2   : bus32;
89
    signal hilo_p1p2_s : bus64;
90
begin
91
 
92
    -- Alu instantiation
93
    U1_alu : alu port map (clock => clock, reset => reset, op1=>DI_op1, op2=>DI_op2, ctrl=>DI_code_ual,
94
                                res=>res_ual, overflow=>overflow_ual, hilo_p2=>EX2_data_hilo, hilo_p1p2=>hilo_p1p2_s);
95
 
96
    -- Calculation of the future outputs
97
    base_adr <= DI_op1 when DI_mode='0' else DI_adr; -- *** base_adr = DI_op1 = 0 na instrucao JAL ***
98
    pre_ecr_reg <= DI_ecr_reg when DI_link='0' else pre_bra_confirm;
99
    pre_data_ual <= res_ual when DI_link='0' else bus32(unsigned(DI_adr) + 8); --***Endereco de retorno (link address) gravado pela instrucao JAL no registrador D_31, que depois sera usado pela intrucao de retorno da rotina, JR.***
100
    pre_bra_confirm <= DI_bra and res_ual(0);
101
    pre_exc_cause <= DI_exc_cause when DI_exc_cause/=IT_NOEXC else
102
                     IT_OVERF when overflow_ual='1' else
103
                     IT_NOEXC;
104
 
105
    -- Set the synchronous outputs
106
    process(clock) is
107
    begin
108
        if rising_edge(clock) then
109
            if reset='1' then
110
                EX_adr <= (others => '0');
111
                EX_bra_confirm <= '0';
112
                EX_data_ual <= (others => '0');
113
                EX_adresse <= (others => '0');
114
                EX_adr_reg_dest <= (others => '0');
115
                EX_ecr_reg <= '0';
116
                EX_op_mem <= '0';
117
                EX_r_w <= '0';
118
                EX_exc_cause <= IT_NOEXC;
119
                EX_level <= LVL_DI;
120
                EX_it_ok <= '0';
121
            elsif stop_all = '0' then
122
                if clear = '1' then -- Clear the stage
123
                    EX_adr <= DI_adr;
124
                    EX_bra_confirm <= '0';
125
                    EX_data_ual <= (others => '0');
126
                    EX_adresse <= (others => '0');
127
                    EX_adr_reg_dest <= (others => '0');
128
                    EX_ecr_reg <= '0';
129
                    EX_op_mem <= '0';
130
                    EX_r_w <= '0';
131
                    EX_exc_cause <= IT_NOEXC;
132
                    EX_level <= LVL_DI;
133
                    EX_it_ok <= '0';
134
                else -- Normal evolution 
135
                    EX_adr <= DI_adr;
136
                    EX_bra_confirm <= pre_bra_confirm;
137
                    EX_data_ual <= pre_data_ual;
138
                    EX_adr_reg_dest <= DI_adr_reg_dest;
139
                    EX_ecr_reg <= pre_ecr_reg;
140
                    EX_op_mem <= DI_op_mem;
141
                    EX_r_w <= DI_r_w;
142
                    EX_exc_cause <= pre_exc_cause;
143
                    EX_level <= DI_level;
144
                    EX_it_ok <= DI_it_ok;
145
                              EX_adresse <= bus32(unsigned(DI_offset) + unsigned(base_adr)); --*** base_adr = DI_op1 = 0 na instrucao JAL, para calcular o endereco alvo ***
146
                              ex_address_p1p2 <= bus32(unsigned(DI_offset) + unsigned(base_adr));
147
                end if;
148
            end if;
149
        end if;
150
 
151
        if falling_edge(clock2) then
152
                if reset = '1' then
153
                        EX_adresse_p1p2 <= (others => '0');
154
                        EX_data_hilo <= (others => '0');
155
                elsif stop_all2 = '0' then -- sinal stop_all do pipe 2
156
                        EX_data_hilo <= hilo_p1p2_s;
157
                        EX_adresse_p1p2 <= bus32(unsigned(ex_address_p1p2) + 4); --*** endereco alvo para o pipe 2 ***
158
                end if;
159
        end if;
160
 
161
    end process;
162
 
163
end architecture;

powered by: WebSVN 2.1.0

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