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

Subversion Repositories minimips_superscalar

[/] [minimips_superscalar/] [tags/] [P1/] [sources/] [bus_ctrl01.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
--             miniMIPS Processor : bus controler                       --
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
 
58
entity bus_ctrl01 is
59
port
60
(
61
    clock : std_logic;
62
    reset : std_logic;
63
 
64
    -- Interruption in the pipeline
65
    interrupt      : in std_logic;
66
 
67
    -- Interface for the Instruction Extraction Stage
68
    adr_from_ei    : in bus32;      -- The address of the data to read
69
    instr_to_ei    : out bus32;     -- Instruction from the memory
70
 
71
    -- Interface with the MEMory Stage
72
    req_from_mem   : in std_logic;  -- Request to access the ram
73
    r_w_from_mem   : in std_logic;  -- Read/Write request
74
    adr_from_mem   : in bus32;      -- Address in ram
75
    data_from_mem  : in bus32;      -- Data to write in ram
76
    data_to_mem    : out bus32;     -- Data from the ram to the MEMory stage
77
 
78
    -- RAM interface signals
79
    req_to_ram     : out std_logic;  -- Request to ram
80
    adr_to_ram     : out bus32;     -- Address of the data to read or write
81
    r_w_to_ram     : out std_logic; -- Read/Write request
82
    ack_from_ram   : in std_logic;  -- Acknowledge from the memory
83
    data_inout_ram : inout bus32;   -- Data from/to the memory
84
 
85
    -- Pipeline progress control signal
86
    stop_all       : out std_logic
87
);
88
end bus_ctrl01;
89
 
90
 
91
architecture rtl of bus_ctrl01 is
92
 
93
    type ctrl_state is ( ST1, ST2 );
94
    signal cs, ns : ctrl_state;
95
    signal ei_buffer : bus32;       -- Buffer storing the data for EI
96
 
97
    signal r_w : std_logic;         -- Current utilisation of the tristate bus
98
    signal data_in : bus32;         -- Data read on the tristate bus
99
    signal req_allowed : std_logic;
100
 
101
begin
102
 
103
    -- Read/write on the tristate bus
104
    process (r_w, data_from_mem, data_inout_ram)
105
    begin
106
        r_w_to_ram <= r_w;
107
        if r_w='0' then -- Reads bus
108
            data_inout_ram <= (others => 'Z');
109
            data_in <= data_inout_ram;
110
        else            -- Writing of the data from the MEM stage
111
            data_inout_ram <= data_from_mem;
112
            data_in <= (others => '0');
113
        end if;
114
    end process;
115
 
116
    process (clock)
117
    begin
118
        if rising_edge(clock) then
119
            if reset='1' then
120
                cs <= ST1;
121
                ei_buffer <= (others => '0');
122
            else
123
                if cs=ST1 then
124
                    -- Storing of the data to send to EI stage
125
                    ei_buffer <= data_in;
126
                end if;
127
 
128
                cs <= ns;
129
            end if;
130
        end if;
131
    end process;
132
 
133
    process (clock, ack_from_ram)
134
    begin
135
        if ack_from_ram = '0' then
136
            req_allowed <= '0'; -- bloqueia nova requisicao
137
        elsif rising_edge(clock) then
138
            if ack_from_ram = '1' then
139
                req_allowed <= '1'; -- libera nova requisicao
140
            end if;
141
        end if;
142
    end process;
143
 
144
    process (req_allowed, ack_from_ram)
145
    begin
146
        if req_allowed = '1' then
147
            req_to_ram <= '1'; -- nova requisicao
148
        elsif ack_from_ram = '0' then
149
            req_to_ram <= '1'; -- nova requisicao
150
        else
151
            req_to_ram <= '0'; -- sem requisicao
152
        end if;
153
    end process;
154
 
155
    process (cs, interrupt, adr_from_ei, req_from_mem, r_w_from_mem, adr_from_mem, ack_from_ram)
156
    begin
157
        if interrupt = '1' then -- An interruption is detected
158
            ns <= ST1;       -- Get back to the reading request
159
            stop_all <= '0'; -- The pipeline is unlock for taking in account the interruption
160
            adr_to_ram <= adr_from_ei;
161
            r_w <= '0';
162
        else
163
            case cs is
164
 
165
                when ST1 => -- First step the reading for EI
166
                    adr_to_ram <= adr_from_ei;
167
                    r_w <= '0';
168
 
169
                    if ack_from_ram='1' then
170
 
171
                        if req_from_mem='1' then
172
                            -- If request from MEM, then step 2
173
                            ns <= ST2;
174
                            stop_all <= '1';
175
                        else
176
                            -- else next reading for EI
177
                            ns <= ST1;
178
                            stop_all <= '0';
179
                        end if;
180
                    else
181
                        -- Wait the end of the reading
182
                        ns <= ST1;
183
                        stop_all <= '1';
184
                    end if;
185
 
186
                when ST2 => -- Treat the request from the MEM stage
187
                    adr_to_ram <= adr_from_mem;
188
                    r_w <= r_w_from_mem;
189
 
190
                    -- Wait the acknowledge from the RAM
191
                    if ack_from_ram='1' then
192
                        ns <= ST1;
193
                        stop_all <= '0';
194
                    else
195
                        ns <= ST2;
196
                        stop_all <= '1';
197
                    end if;
198
            end case;
199
        end if;
200
    end process;
201
    data_to_mem <= data_in;
202
    instr_to_ei <= ei_buffer when cs=ST2 else data_in;
203
 
204
end rtl;

powered by: WebSVN 2.1.0

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