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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_resmux_ix1.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2016 Stefano Tonello                          --
6
--                                                             --
7
-- This source file may be used and distributed without        --
8
-- restriction provided that this copyright statement is not   --
9
-- removed from the file and that any derivative work contains --
10
-- the original copyright notice and the associated disclaimer.--
11
--                                                             --
12
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY         --
13
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   --
14
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   --
15
-- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      --
16
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         --
17
-- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    --
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   --
19
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        --
20
-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  --
21
-- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  --
22
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  --
23
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         --
24
-- POSSIBILITY OF SUCH DAMAGE.                                 --
25
--                                                             --
26
-----------------------------------------------------------------
27
 
28
---------------------------------------------------------------
29
-- RV01 result mux (IX1 stage)
30
---------------------------------------------------------------
31
 
32
library IEEE;
33
use IEEE.std_logic_1164.all;
34
use IEEE.numeric_std.all;
35
 
36
library work;
37
use work.RV01_CONSTS_PKG.all;
38
use work.RV01_TYPES_PKG.all;
39
use work.RV01_IDEC_PKG.all;
40
 
41
entity RV01_RESMUX_IX1 is
42
  generic(
43
    PXE : std_logic := '1';
44
    DXE : std_logic := '1';
45
    NW : natural := 2
46
  );
47
  port(
48
    OPA0_V_i : in std_logic;
49
    OPA1_V_i : in std_logic;
50
    OPA0_i : in SDWORD_T;
51
    OPA1_i : in SDWORD_T;
52
    OPB0_V_i : in std_logic;
53
    OPB1_V_i : in std_logic;
54
    OPB0_i : in SDWORD_T;
55
    OPB1_i : in SDWORD_T;
56
    SHF_RES0_i : in SDWORD_T;
57
    SHF_RES1_i : in SDWORD_T;
58
    PA0_ALU_RES_i : in SDWORD_T;
59
    PA1_ALU_RES_i : in SDWORD_T;
60
    DIV_V_i : in std_logic;
61
    DIV_RES_i : in SDWORD_T;
62
    PASEL0_i : in std_logic_vector(4-1 downto 0);
63
    PASEL1_i : in std_logic_vector(4-1 downto 0);
64
    FWDE_i : in std_logic_vector(NW-1 downto 0);
65
    DSA0_i : in std_logic;
66
    DSB0_i : in std_logic;
67
    DSA1_i : in std_logic;
68
    DSB1_i : in std_logic;
69
    INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
70
    IX3_DRD0_i : in SDWORD_T;
71
    IX3_DRD1_i : in SDWORD_T;
72
    IX3_V_i : in std_logic_vector(NW-1 downto 0);
73
    IX3_INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
74
 
75
    FWDX_o : out std_logic_vector(NW-1 downto 0);
76
    PA0_RES_o : out SDWORD_T;
77
    PA1_RES_o : out SDWORD_T;
78
    OPA0_V_o : out std_logic;
79
    OPA1_V_o : out std_logic;
80
    OPA0_o : out SDWORD_T;
81
    OPA1_o : out SDWORD_T;
82
    OPB0_V_o : out std_logic;
83
    OPB1_V_o : out std_logic;
84
    OPB0_o : out SDWORD_T;
85
    OPB1_o : out SDWORD_T;
86
    DRD0_V_o : out std_logic;
87
    DRD1_V_o : out std_logic;
88
    DRD0_o : out SDWORD_T;
89
    DRD1_o : out SDWORD_T
90
  );
91
end RV01_RESMUX_IX1;
92
 
93
architecture ARC of RV01_RESMUX_IX1 is
94
 
95
  component RV01_PIPE_A_RMX_X2 is
96
    generic(
97
      NW : natural := 2
98
    );
99
    port(
100
      OPA_V_i :  in std_logic;
101
      OPB_V_i :  in std_logic;
102
      OPA_i : in SDWORD_T;
103
      OPB_i : in SDWORD_T;
104
      INSTR_i : in DEC_INSTR_T;
105
      IX3_V_i : in std_logic_vector(NW-1 downto 0);
106
      IX3_INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
107
      IX3_RES0_i : in SDWORD_T;
108
      IX3_RES1_i : in SDWORD_T;
109
 
110
      OPA_V_o :  out std_logic;
111
      OPB_V_o :  out std_logic;
112
      OPA_o : out SDWORD_T;
113
      OPB_o : out SDWORD_T
114
  );
115
  end component;
116
 
117
  signal PA0_RES : SDWORD_T;
118
  signal PA1_RES : SDWORD_T;
119
 
120
begin
121
 
122
  -------------------------------------------
123
  -- Delayed execution disabled
124
  -------------------------------------------
125
 
126
  PA0_RES <=
127
    SHF_RES0_i when(PASEL0_i(1) = '1') else
128
    PA0_ALU_RES_i;
129
 
130
  GPX_3_1 : if(PXE = '1') generate
131
 
132
  PA1_RES <=
133
    SHF_RES1_i when(PASEL1_i(1) = '1') else
134
    PA1_ALU_RES_i;
135
 
136
  end generate; -- GPX_3_1
137
 
138
  GPX_3_0 : if(PXE = '0') generate
139
 
140
 
141
  PA1_RES <= (others => '0');
142
 
143
  end generate; -- GPX_3_0
144
 
145
  PA0_RES_o <= PA0_RES;
146
 
147
  PA1_RES_o <= PA1_RES;
148
 
149
  GDX1_0 : if(DXE = '0') generate
150
 
151
  -- If delayed execution is not enabled, when pipe-A
152
  -- instructions reach IX1 stage their operand are
153
  -- already available and therefore they can safely
154
  -- executed and their result forwarded to ID stage.
155
 
156
  -- Result forwarding flags
157
  FWDX_o(0) <= FWDE_i(0);
158
  FWDX_o(1) <= FWDE_i(1) and DXE;
159
 
160
  -- Slot #0 instruction can be provided by pipe-A or by
161
  -- divider.
162
 
163
  DRD0_o <=
164
    DIV_RES_i when (DIV_V_i = '1') else
165
    PA0_RES;
166
 
167
  -- Slot #0 result valid flag
168
  DRD0_V_o <= '1' when (
169
    DIV_V_i = '1' or (
170
      PASEL0_i(0) = '1' or
171
      PASEL0_i(1) = '1' or
172
      PASEL0_i(2) = '1'
173
    )
174
  ) else '0';
175
 
176
  GPX_4_1 : if(PXE = '1') generate
177
 
178
  -- Slot #1 instruction can be provided by pipe-A only.
179
 
180
  DRD1_o <= PA1_RES;
181
 
182
  -- Slot #1 result valid flag
183
  DRD1_V_o <= '1' when (
184
    PASEL1_i(0) = '1' or
185
    PASEL1_i(1) = '1' or
186
    PASEL1_i(2) = '1'
187
  ) else '0';
188
 
189
  end generate; -- GPX_4_1
190
 
191
  GPX_4_0 : if(PXE = '0') generate
192
 
193
  DRD1_o <= (others => '0');
194
  DRD1_V_o <= '0';
195
 
196
  end generate; -- GPX_4_0
197
 
198
  OPA0_V_o <= '0';
199
  OPA1_V_o <= '0';
200
  OPA0_o <= (others => '0');
201
  OPA1_o <= (others => '0');
202
  OPB0_V_o <= '0';
203
  OPB1_V_o <= '0';
204
  OPB0_o <= (others => '0');
205
  OPB1_o <= (others => '0');
206
 
207
  end generate; -- GDX1_0
208
 
209
  -------------------------------------------
210
  -- Delayed execution enabled
211
  -------------------------------------------
212
 
213
  GDX1_1 : if(DXE = '1') generate
214
 
215
  -- If delayed execution is enabled, when pipe-A
216
  -- instructions reach IX1 stage their operand are
217
  -- available only if their valid bits are set.
218
 
219
  -- Note: IX1_PA*_RES are used for forwarding only!
220
 
221
  U_PA0RMX_X1: RV01_PIPE_A_RMX_X2
222
    generic map(
223
      NW => NW
224
    )
225
    port map(
226
      OPA_V_i => OPA0_V_i,
227
      OPB_V_i => OPB0_V_i,
228
      OPA_i => OPA0_i,
229
      OPB_i => OPB0_i,
230
      INSTR_i => INSTR_i(0),
231
      IX3_V_i => IX3_V_i,
232
      IX3_INSTR_i => IX3_INSTR_i,
233
      IX3_RES0_i => IX3_DRD0_i,
234
      IX3_RES1_i => IX3_DRD1_i,
235
 
236
      OPA_V_o => OPA0_V_o,
237
      OPB_V_o => OPB0_V_o,
238
      OPA_o => OPA0_o,
239
      OPB_o => OPB0_o
240
  );
241
 
242
  GPX_4_1 : if(PXE = '1') generate
243
 
244
  U_PA1RMX_X1: RV01_PIPE_A_RMX_X2
245
    generic map(
246
      NW => NW
247
    )
248
    port map(
249
      OPA_V_i => OPA1_V_i,
250
      OPB_V_i => OPB1_V_i,
251
      OPA_i => OPA1_i,
252
      OPB_i => OPB1_i,
253
      INSTR_i => INSTR_i(1),
254
      IX3_V_i => IX3_V_i,
255
      IX3_INSTR_i => IX3_INSTR_i,
256
      IX3_RES0_i => IX3_DRD0_i,
257
      IX3_RES1_i => IX3_DRD1_i,
258
 
259
      OPA_V_o => OPA1_V_o,
260
      OPB_V_o => OPB1_V_o,
261
      OPA_o => OPA1_o,
262
      OPB_o => OPB1_o
263
  );
264
 
265
  end generate; -- GPX_4_1
266
 
267
  GPX_4_0 : if(PXE = '0') generate
268
 
269
  OPA1_V_o <= '0';
270
  OPB1_V_o <= '0';
271
  OPA1_o <= (others => '0');
272
  OPB1_o <= (others => '0');
273
 
274
  end generate; -- GPX_4_0
275
 
276
  -- Result of instruction #0/1 is forwardable if
277
  -- instruction is of forwardable type and if
278
  -- both operands to ALU/SHFU are valid.
279
 
280
  FWDX_o(0) <=
281
    FWDE_i(0) and
282
    (OPA0_V_i and not(DSA0_i)) and
283
    (OPB0_V_i and not(DSB0_i));
284
 
285
  FWDX_o(1) <=
286
    FWDE_i(1) and
287
    (OPA1_V_i and not(DSA1_i)) and
288
    (OPB1_V_i and not(DSB1_i)) and
289
    PXE;
290
 
291
  -- Slot #0 instruction result can be provided
292
  -- by shifter or by divider.
293
 
294
  DRD0_o <= DIV_RES_i when (DIV_V_i = '1') else SHF_RES0_i;
295
 
296
  -- Slot #0 result valid flag
297
  DRD0_V_o <= '1' when (DIV_V_i = '1' or PASEL0_i(1) = '1') else '0';
298
 
299
  GPX_5_1 : if(PXE = '1') generate
300
 
301
  -- Slot #1 instruction result can be provided
302
  -- by shifter only.
303
 
304
  DRD1_o <= SHF_RES1_i;
305
 
306
  -- Slot #1 result valid flag
307
  DRD1_V_o <= '1' when (PASEL1_i(1) = '1') else '0';
308
 
309
  end generate; -- GPX_5_1
310
 
311
  GPX_5_0 : if(PXE = '0') generate
312
 
313
  DRD1_o <= (others => '0');
314
  DRD1_V_o <= '0';
315
 
316
  end generate; -- GPX_5_0
317
 
318
  end generate; -- GDX1_1
319
 
320
end ARC;

powered by: WebSVN 2.1.0

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