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

Subversion Repositories minimips_superscalar

[/] [minimips_superscalar/] [tags/] [P1/] [sources/] [pps_ex_2.vhd] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 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
--                                                                      --
39
--             Processor miniMIPS : Execution stage                     --
40
--                                                                      --
41
--                                                                      --
42
--                                                                      --
43
-- Authors : Hangouet  Samuel                                           --
44
--           Jan       Sébastien                                        --
45
--           Mouton    Louis-Marie                                      --
46
--           Schneider Olivier                                          --
47
--                                                                      --
48
--                                                          june 2003   --
49
--------------------------------------------------------------------------
50
 
51
library IEEE;
52
use IEEE.std_logic_1164.all;
53
use IEEE.numeric_std.all;
54
 
55
library work;
56
use work.pack_mips.all;
57
use work.alu2;
58
 
59
entity pps_ex_2 is
60
port(
61
    clock : in std_logic;
62
    clock2 : in std_logic;
63
    reset : in std_logic;
64
    stop_all : in std_logic; -- 07-08-2018
65
    stop_all2 : in std_logic;           -- Unconditionnal locking of outputs
66
    clear : in std_logic;               -- Clear the pipeline stage
67
 
68
    -- Datas from DI stage
69
    DI_bra : in std_logic;              -- Branch instruction
70
    DI_link : in std_logic;             -- Branch with link
71
    DI_op1 : in bus32;                  -- Operand 1 for alu (vem zero quando a instrucao eh um J (jump)
72
    DI_op2 : in bus32;                  -- Operand 2 for alu
73
    DI_code_ual : in alu_ctrl_type;     -- Alu operation
74
    DI_offset : in bus32;               -- Offset for address calculation
75
    DI_adr_reg_dest : in adr_reg_type;  -- Destination register address for the result
76
    DI_ecr_reg : in std_logic;          -- Effective writing of the result
77
    DI_mode : in std_logic;             -- Address mode (relative to pc ou index by a register)
78
    DI_op_mem : in std_logic;           -- Memory operation
79
    DI_r_w : in std_logic;              -- Type of memory operation (read or write)
80
    DI_adr : in bus32;                  -- Instruction address
81
    DI_exc_cause : in bus32;            -- Potential cause exception
82
    DI_level : in level_type;           -- Availability stage of the result for bypassing
83
    DI_it_ok : in std_logic;            -- Allow hardware interruptions
84
 
85
    EX_data_hilo : in bus64;--resultado da multiplicacao do pieline 1
86
    EX2_data_hilo : out bus64;
87
    -- Synchronous outputs to MEM stage
88
    EX_adr : out bus32;                 -- Instruction address
89
    EX_bra_confirm : out std_logic;     -- Branch execution confirmation
90
    EX_data_ual : out bus32;            -- Ual result
91
    EX_adresse : out bus32;             -- Address calculation result
92
    EX_adresse_p2p1 : out bus32;        -- resultado do calculo do endereco do desvio + 4 para pipe 1
93
    EX_adr_reg_dest : out adr_reg_type; -- Destination register for the result
94
    EX_ecr_reg : out std_logic;         -- Effective writing of the result
95
    EX_op_mem : out std_logic;          -- Memory operation needed
96
    EX_r_w : out std_logic;             -- Type of memory operation (read or write)
97
    EX_exc_cause : out bus32;           -- Potential cause exception
98
    EX_level : out level_type;          -- Availability stage of result for bypassing
99
    EX_it_ok : out std_logic            -- Allow hardware interruptions
100
);
101
end entity;
102
 
103
 
104
architecture rtl of pps_ex_2 is
105
 
106
component alu2
107
    port (
108
        clock : in bus1;
109
        reset : in bus1;
110
        op1 : in bus32; -- Operand 1
111
        op2 : in bus32; -- Operand 2
112
        ctrl : in alu_ctrl_type; -- Operation
113
        hilo_p1 : in bus64;
114
        hilo_p2p1 : out bus64;
115
        res : out bus32; -- Result
116
        overflow : out bus1 -- Overflow
117
    );
118
    end component;
119
 
120
    signal res_ual         : bus32;      -- Alu result output
121
    signal base_adr        : bus32;      -- Output of the address mode mux selection
122
 
123
    signal pre_ecr_reg     : std_logic;  -- Output of mux selection for writing command to register
124
    signal pre_data_ual    : bus32;      -- Mux selection of the data to write
125
    signal pre_bra_confirm : std_logic;  -- Result of the test in alu when branch instruction
126
    signal pre_exc_cause   : bus32;      -- Preparation of the exception detection signal
127
    signal overflow_ual    : std_logic;  -- Dectection of the alu overflow
128
    signal ex_address_p2p1   : bus32;
129
    signal hilo_p2p1_s  : bus64;
130
begin
131
 
132
    -- Alu instantiation
133
    U1_alu_2 : alu2 port map (clock => clock2, reset => reset, op1=>DI_op1, op2=>DI_op2, ctrl=>DI_code_ual,
134
                                res=>res_ual, overflow=>overflow_ual, hilo_p1=>EX_data_hilo, hilo_p2p1=>hilo_p2p1_s);
135
 
136
    -- Calculation of the future outputs
137
    base_adr <= DI_op1 when DI_mode='0' else DI_adr;
138
    pre_ecr_reg <= DI_ecr_reg when DI_link='0' else pre_bra_confirm;
139
    pre_data_ual <= res_ual when DI_link='0' else bus32(unsigned(DI_adr) + 8);
140
    pre_bra_confirm <= DI_bra and res_ual(0);
141
    pre_exc_cause <= DI_exc_cause when DI_exc_cause/=IT_NOEXC else
142
                     IT_OVERF when overflow_ual='1' else
143
                     IT_NOEXC;
144
 
145
    -- Set the synchronous outputs
146
    process(clock2) is
147
    begin
148
        if rising_edge(clock2) then
149
            if reset='1' then
150
                EX_adr <= (others => '0');
151
                EX_bra_confirm <= '0';
152
                EX_data_ual <= (others => '0');
153
                EX_adresse <= (others => '0');
154
                EX_adr_reg_dest <= (others => '0');
155
                EX_ecr_reg <= '0';
156
                EX_op_mem <= '0';
157
                EX_r_w <= '0';
158
                EX_exc_cause <= IT_NOEXC;
159
                EX_level <= LVL_DI;
160
                EX_it_ok <= '0';
161
            elsif stop_all2 = '0' then
162
                if clear = '1' then -- Clear the stage
163
                    EX_adr <= DI_adr;
164
                    EX_bra_confirm <= '0';
165
                    EX_data_ual <= (others => '0');
166
                    EX_adresse <= (others => '0');
167
                    EX_adr_reg_dest <= (others => '0');
168
                    EX_ecr_reg <= '0';
169
                    EX_op_mem <= '0';
170
                    EX_r_w <= '0';
171
                    EX_exc_cause <= IT_NOEXC;
172
                    EX_level <= LVL_DI;
173
                    EX_it_ok <= '0';
174
                else -- Normal evolution
175
                    EX_adr <= DI_adr;
176
                    EX_bra_confirm <= pre_bra_confirm;
177
                    EX_data_ual <= pre_data_ual;
178
                    EX_adr_reg_dest <= DI_adr_reg_dest;
179
                    EX_ecr_reg <= pre_ecr_reg;
180
                    EX_op_mem <= DI_op_mem;
181
                    EX_r_w <= DI_r_w;
182
                    EX_exc_cause <= pre_exc_cause;
183
                    EX_level <= DI_level;
184
                    EX_it_ok <= DI_it_ok;
185
                    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)
186
                    ex_address_p2p1 <= bus32(unsigned(DI_offset) + unsigned(base_adr));
187
                end if;
188
            end if;
189
        end if;
190
    end process;
191
 
192
process(clock)
193
begin
194
        if rising_edge(clock) then
195
                if reset = '1' then
196
                        EX_adresse_p2p1 <= (others => '0');
197
                        EX2_data_hilo <= (others => '0');
198
                elsif stop_all = '0' then -- sinal stop_all do pipe 1
199
                        EX2_data_hilo <= hilo_p2p1_s;
200
                        EX_adresse_p2p1 <= bus32(unsigned(ex_address_p2p1) + 4); --*** endereco alvo para o pipe 1 ***
201
                end if;
202
 
203
        end if;
204
end process;
205
end architecture;

powered by: WebSVN 2.1.0

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