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_ix2.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 (IX2 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_FUNCS_PKG.all;
40
use work.RV01_IDEC_PKG.all;
41
 
42
entity RV01_RESMUX_IX2 is
43
  generic(
44
    PXE : std_logic := '1';
45
    DXE : std_logic := '1';
46
    NW : natural := 2
47
  );
48
  port(
49
    OPA0_V_i : in std_logic;
50
    OPA1_V_i : in std_logic;
51
    OPA0_i : in SDWORD_T;
52
    OPA1_i : in SDWORD_T;
53
    OPB0_V_i : in std_logic;
54
    OPB1_V_i : in std_logic;
55
    OPB0_i : in SDWORD_T;
56
    OPB1_i : in SDWORD_T;
57
    DRD0_V_i : in std_logic;
58
    DRD1_V_i : in std_logic;
59
    DRD0_i : in SDWORD_T;
60
    DRD1_i : in SDWORD_T;
61
    DDAT0_i : in std_logic_vector(SDLEN-1 downto 0);
62
    DDAT1_i : in std_logic_vector(SDLEN-1 downto 0);
63
    PA0_ALU_RES_i : in SDWORD_T;
64
    PA1_ALU_RES_i : in SDWORD_T;
65
    PB0_RES_i : in SDWORD_T;
66
    PC1P4_i : in unsigned(SDLEN-1 downto 0);
67
    PASEL0_i : in std_logic_vector(4-1 downto 0);
68
    PASEL1_i : in std_logic_vector(4-1 downto 0);
69
    FWDE_i : in std_logic_vector(NW-1 downto 0);
70
    INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
71
    IX3_DRD0_i : in SDWORD_T;
72
    IX3_DRD1_i : in SDWORD_T;
73
    IX3_V_i : in std_logic_vector(NW-1 downto 0);
74
    IX3_INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
75
 
76
    FWDX_o : out std_logic_vector(NW-1 downto 0);
77
    PA0_RES_o : out SDWORD_T;
78
    PA1_RES_o : out SDWORD_T;
79
    OPA0_V_o : out std_logic;
80
    OPA1_V_o : out std_logic;
81
    OPA0_o : out SDWORD_T;
82
    OPA1_o : out SDWORD_T;
83
    OPB0_V_o : out std_logic;
84
    OPB1_V_o : out std_logic;
85
    OPB0_o : out SDWORD_T;
86
    OPB1_o : out SDWORD_T;
87
    DRD0_o : out SDWORD_T;
88
    DRD1_o : out SDWORD_T
89
  );
90
end RV01_RESMUX_IX2;
91
 
92
architecture ARC of RV01_RESMUX_IX2 is
93
 
94
  component RV01_PIPE_A_RMX_X2 is
95
    generic(
96
      NW : natural := 2
97
    );
98
    port(
99
      OPA_V_i :  in std_logic;
100
      OPB_V_i :  in std_logic;
101
      OPA_i : in SDWORD_T;
102
      OPB_i : in SDWORD_T;
103
      INSTR_i : in DEC_INSTR_T;
104
      IX3_V_i : in std_logic_vector(NW-1 downto 0);
105
      IX3_INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
106
      IX3_RES0_i : in SDWORD_T;
107
      IX3_RES1_i : in SDWORD_T;
108
 
109
      OPA_V_o :  out std_logic;
110
      OPB_V_o :  out std_logic;
111
      OPA_o : out SDWORD_T;
112
      OPB_o : out SDWORD_T
113
  );
114
  end component;
115
 
116
  signal PA0_RES : SDWORD_T;
117
  signal PA1_RES : SDWORD_T;
118
  signal NOLD0_RES : SDWORD_T;
119
  signal NOLD1_RES : SDWORD_T;
120
 
121
begin
122
 
123
  -------------------------------------------
124
  -- Delayed execution disabled
125
  -------------------------------------------
126
 
127
  GDX2_0 : if(DXE = '0') generate
128
 
129
  PA0_RES <=
130
    to_signed(DDAT0_i) when (PASEL0_i(3) = '1') else
131
    DRD0_i;
132
 
133
  GPX_0_1 : if(PXE = '1') generate
134
 
135
  PA1_RES <=
136
    to_signed(DDAT1_i) when (PASEL1_i(3) = '1') else
137
    DRD1_i;
138
 
139
  end generate; -- GPX_0_1
140
 
141
  GPX_0_0 : if(PXE = '0') generate
142
 
143
  PA1_RES <= (others => '0');
144
 
145
  end generate; -- GPX_0_0
146
 
147
  -- Pipe #0 result can be provided by pipe-A #0 or pipe-B.
148
 
149
  DRD0_o <=
150
    to_signed(DDAT0_i) when (PASEL0_i(3) = '1' and FWDE_i(0) = '1') else
151
    DRD0_i when DRD0_V_i = '1' else
152
    PB0_RES_i;
153
 
154
  -- Pipe #1 result can be provided by pipe-A #0 or
155
  -- by jal/jalr return address (for slot #0 this is
156
  -- supplied by pipe-B).
157
 
158
  GPX_1_1 : if(PXE = '1') generate
159
 
160
  DRD1_o <=
161
    to_signed(DDAT1_i) when (PASEL1_i(3) = '1' and FWDE_i(1) = '1') else
162
    DRD1_i when DRD1_V_i = '1' else
163
    to_signed(PC1P4_i);
164
 
165
  end generate; -- GPX_1_1
166
 
167
  GPX_1_0 : if(PXE = '0') generate
168
 
169
  DRD1_o <= (others => '0');
170
 
171
  end generate; -- GPX_1_0
172
 
173
  OPA0_V_o <= '0';
174
  OPB0_V_o <= '0';
175
  OPA0_o <= (others => '0');
176
  OPB0_o <= (others => '0');
177
  OPA1_V_o <= '0';
178
  OPB1_V_o <= '0';
179
  OPA1_o <= (others => '0');
180
  OPB1_o <= (others => '0');
181
 
182
  end generate; -- GDX2_0
183
 
184
  -------------------------------------------
185
  -- Delayed execution enabled
186
  -------------------------------------------
187
 
188
  GDX2_1 : if(DXE = '1') generate
189
 
190
  -- Note: IX2_PA*_RES are used for forwarding!
191
 
192
  -- Code re-written for timing optimization
193
 
194
  PA0_RES <=
195
    to_signed(DDAT0_i) when (PASEL0_i(3) = '1') else
196
    NOLD0_RES;
197
 
198
  -- "no-load" result
199
  NOLD0_RES <=
200
    PA0_ALU_RES_i when (PASEL0_i(0) = '1' or PASEL0_i(2) = '1') else
201
    DRD0_i;
202
 
203
  GPX_1_1 : if(PXE = '1') generate
204
 
205
  -- Code re-written for timing optimization
206
 
207
  PA1_RES <=
208
    to_signed(DDAT1_i) when (PASEL1_i(3) = '1') else
209
    NOLD1_RES;
210
 
211
  -- "no-load" result
212
  NOLD1_RES <=
213
    PA1_ALU_RES_i when (PASEL1_i(0) = '1' or PASEL1_i(2) = '1') else
214
    DRD1_i;
215
 
216
  end generate; -- GPX_1_1
217
 
218
  GPX_1_0 : if(PXE = '0') generate
219
 
220
  PA1_RES <= (others => '0');
221
 
222
  end generate; -- GPX_1_0
223
 
224
  -- Pipe #0 result can be provided by pipe-A #0, pipe-B
225
  -- and divider unit.
226
 
227
  DRD0_o <= PA0_RES when FWDE_i(0) = '1'
228
    else DRD0_i when DRD0_V_i = '1'
229
    else PB0_RES_i;
230
 
231
  -- Pipe #1 result can be provided by pipe-A #0 or
232
  -- by jal/jalr return address (for slot #0 this is
233
  -- supplied by pipe-B).
234
 
235
  GPX_2_1 : if(PXE = '1') generate
236
 
237
  DRD1_o <= PA1_RES when FWDE_i(1) = '1'
238
    else DRD1_i when DRD1_V_i = '1'
239
    else to_signed(PC1P4_i);
240
 
241
  end generate; -- GPX_2_1
242
 
243
  GPX_2_0 : if(PXE = '0') generate
244
 
245
  DRD1_o <= (others => '0');
246
 
247
  end generate; -- GPX_2_0
248
 
249
  U_PA0RMX_X2: RV01_PIPE_A_RMX_X2
250
    generic map(
251
      NW => NW
252
    )
253
    port map(
254
      OPA_V_i => OPA0_V_i,
255
      OPB_V_i => OPB0_V_i,
256
      OPA_i => OPA0_i,
257
      OPB_i => OPB0_i,
258
      INSTR_i => INSTR_i(0),
259
      IX3_V_i => IX3_V_i,
260
      IX3_INSTR_i => IX3_INSTR_i,
261
      IX3_RES0_i => IX3_DRD0_i,
262
      IX3_RES1_i => IX3_DRD1_i,
263
 
264
      OPA_V_o => OPA0_V_o,
265
      OPB_V_o => OPB0_V_o,
266
      OPA_o => OPA0_o,
267
      OPB_o => OPB0_o
268
  );
269
 
270
  GPX_3_1 : if(PXE = '1') generate
271
 
272
  U_PA1RMX_X2: RV01_PIPE_A_RMX_X2
273
    generic map(
274
      NW => NW
275
    )
276
    port map(
277
      OPA_V_i => OPA1_V_i,
278
      OPB_V_i => OPB1_V_i,
279
      OPA_i => OPA1_i,
280
      OPB_i => OPB1_i,
281
      INSTR_i => INSTR_i(1),
282
      IX3_V_i => IX3_V_i,
283
      IX3_INSTR_i => IX3_INSTR_i,
284
      IX3_RES0_i => IX3_DRD0_i,
285
      IX3_RES1_i => IX3_DRD1_i,
286
 
287
      OPA_V_o => OPA1_V_o,
288
      OPB_V_o => OPB1_V_o,
289
      OPA_o => OPA1_o,
290
      OPB_o => OPB1_o
291
  );
292
 
293
  end generate; -- GPX_3_1
294
 
295
  GPX_3_0 : if(PXE = '0') generate
296
 
297
  OPA1_V_o <= '0';
298
  OPB1_V_o <= '0';
299
  OPA1_o <= (others => '0');
300
  OPB1_o <= (others => '0');
301
 
302
  end generate; -- GPX_3_0
303
 
304
  end generate; -- GDX2_1 
305
 
306
  PA0_RES_o <= PA0_RES;
307
  PA1_RES_o <= PA1_RES;
308
 
309
  FWDX_o(0) <= '1';
310
  FWDX_o(1) <= PXE;
311
 
312
end ARC;

powered by: WebSVN 2.1.0

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