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

Subversion Repositories minimips

[/] [minimips/] [trunk/] [miniMIPS/] [src/] [renvoi.vhd] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 poppy
------------------------------------------------------------------------------------
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 5 poppy
--    it under the terms of the GNU Lesser General Public License as published by --
12
--    the Free Software Foundation; either version 2.1 of the License, or         --
13 2 poppy
--    (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 5 poppy
--    GNU Lesser General Public License for more details.                         --
19 2 poppy
--                                                                                --
20 5 poppy
--    You should have received a copy of the GNU Lesser General Public License    --
21 2 poppy
--    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 : Bypass unit                       --
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
 
52
library IEEE;
53
use IEEE.std_logic_1164.all;
54
use IEEE.numeric_std.all;
55
 
56
library work;
57
use work.pack_mips.all;
58
 
59
entity renvoi is
60
port (
61
    -- Register access signals
62
    adr1 : in adr_reg_type;    -- Operand 1 address
63
    adr2 : in adr_reg_type;    -- Operand 2 address
64
    use1 : in std_logic;       -- Operand 1 utilisation
65
    use2 : in std_logic;       -- Operand 2 utilisation
66
 
67
    data1 : out bus32;         -- First register value
68
    data2 : out bus32;         -- Second register value
69
    alea : out std_logic;      -- Unresolved hazards detected
70
 
71
    -- Bypass signals of the intermediary datas
72
    DI_level : in level_type;  -- Availability level of the data
73
    DI_adr : in adr_reg_type;  -- Register destination of the result
74
    DI_ecr : in std_logic;     -- Writing register request
75
    DI_data : in bus32;        -- Data to used
76
 
77
    EX_level : in level_type;  -- Availability level of the data
78
    EX_adr : in adr_reg_type;  -- Register destination of the result
79
    EX_ecr : in std_logic;     -- Writing register request
80
    EX_data : in bus32;        -- Data to used
81
 
82
    MEM_level : in level_type; -- Availability level of the data
83
    MEM_adr : in adr_reg_type; -- Register destination of the result
84
    MEM_ecr : in std_logic;    -- Writing register request
85
    MEM_data : in bus32;       -- Data to used
86
 
87
    interrupt : in std_logic;  -- Exceptions or interruptions
88
 
89
    -- Connexion to the differents bank of register
90
 
91
      -- Writing commands for writing in the registers
92
    write_data : out bus32;    -- Data to write
93
    write_adr : out bus5;      -- Address of the register to write
94
    write_GPR : out std_logic; -- Selection in the internal registers
95
    write_SCP : out std_logic; -- Selection in the coprocessor system registers
96
 
97
      -- Reading commands for Reading in the registers
98
    read_adr1 : out bus5;      -- Address of the first register to read
99
    read_adr2 : out bus5;      -- Address of the second register to read
100
    read_data1_GPR : in bus32; -- Value of operand 1 from the internal registers
101
    read_data2_GPR : in bus32; -- Value of operand 2 from the internal registers
102
    read_data1_SCP : in bus32; -- Value of operand 1 from the coprocessor system registers
103
    read_data2_SCP : in bus32  -- Value of operand 2 from the coprocessor system registers
104
);
105
end renvoi;
106
 
107
architecture rtl of renvoi is
108
    signal dep_r1 : level_type; -- Dependency level for operand 1
109
    signal dep_r2 : level_type; -- Dependency level for operand 2
110
    signal read_data1 : bus32;  -- Data contained in the register asked by operand 1
111
    signal read_data2 : bus32;  -- Data contained in the register asked by operand 2
112
    signal res_reg, res_mem, res_ex, res_di : std_logic;
113
    signal resolution : bus4;   -- Verification of the resolved hazards
114
 
115
    signal idx1, idx2 : integer range 0 to 3;
116
begin
117
 
118
    -- Connexion of the writing command signals
119
    write_data <= MEM_data;
120
    write_adr <= MEM_adr(4 downto 0);
121
    write_GPR <= not MEM_adr(5) and MEM_ecr when interrupt = '0' else  -- The high bit to 0 selects the internal registers
122
                 '0';
123
    write_SCP <= MEM_adr(5) and MEM_ecr;      -- The high bit to 1 selects the coprocessor system registers
124
 
125
    -- Connexion of the writing command signals
126
    read_adr1 <= adr1(4 downto 0);            -- Connexion of the significative address bits
127
    read_adr2 <= adr2(4 downto 0);            -- Connexion of the significative address bits
128
 
129
    -- Evaluation of the level of dependencies
130
    dep_r1 <= LVL_REG when adr1(4 downto 0)="00000" or use1='0' else -- No dependency with register 0
131
              LVL_DI  when adr1=DI_adr  and DI_ecr ='1' else         -- Dependency with DI stage
132
              LVL_EX  when adr1=EX_adr  and EX_ecr ='1' else         -- Dependency with DI stage
133
              LVL_MEM when adr1=MEM_adr and MEM_ecr='1' else         -- Dependency with DI stage
134
              LVL_REG;                                               -- No dependency detected
135
 
136
    dep_r2 <= LVL_REG when adr2(4 downto 0)="00000" or use2='0' else -- No dependency with register 0
137
              LVL_DI  when adr2=DI_adr  and DI_ecr ='1' else         -- Dependency with DI stage
138
              LVL_EX  when adr2=EX_adr  and EX_ecr ='1' else         -- Dependency with DI stage
139
              LVL_MEM when adr2=MEM_adr and MEM_ecr='1' else         -- Dependency with DI stage
140
              LVL_REG;                                               -- No dependency detected
141
 
142
    -- Elaboration of the signals with the datas form the bank registers
143
    read_data1 <= read_data1_GPR when adr1(5)='0' else       -- Selection of the internal registers
144
                  read_data1_SCP when adr1(5)='1' else       -- Selection of the coprocessor registers
145
                  (others => '0');
146
 
147
    read_data2 <= read_data2_GPR when adr2(5)='0' else       -- Selection of the internal registers   
148
                  read_data2_SCP when adr2(5)='1' else       -- Selection of the coprocessor registers
149
                  (others => '0');
150
 
151
    -- Bypass the datas (the validity is tested later when detecting the hazards)
152
    data1 <= read_data1 when dep_r1=LVL_REG else
153
             MEM_data   when dep_r1=LVL_MEM else
154
             EX_data    when dep_r1=LVL_EX  else
155
             DI_data;
156
 
157
    data2 <= read_data2 when dep_r2=LVL_REG else
158
             MEM_data   when dep_r2=LVL_MEM else
159
             EX_data    when dep_r2=LVL_EX  else
160
             DI_data;
161
 
162
    -- Detection of a potential unresolved hazard
163
    res_reg <= '1'; -- This hazard is always resolved
164
    res_mem <= '1' when MEM_level>=LVL_MEM else '0';
165
    res_ex  <= '1' when EX_level >=LVL_EX  else '0';
166
    res_di  <= '1' when DI_level >=LVL_DI  else '0';
167
 
168
    -- Table defining the resolved hazard for each stage
169
    resolution <= res_di & res_ex & res_mem & res_reg;
170
 
171
    -- Verification of the validity of the transmitted datas (test the good resolution of the hazards)
172
    idx1 <= to_integer(unsigned(dep_r1(1 downto 0)));
173
    idx2 <= to_integer(unsigned(dep_r2(1 downto 0)));
174
    alea <= not resolution(idx1) or not resolution(idx2);
175
 
176
end rtl;

powered by: WebSVN 2.1.0

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