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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_pipe_a_rmx_x2.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 madsilicon
-----------------------------------------------------------------
2
--                                                             --
3
-----------------------------------------------------------------
4
--                                                             --
5
-- Copyright (C) 2017 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 REQERRUPTION) 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
-- A-pipeline 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_PIPE_A_RMX_X2 is
43
  generic(
44
    NW : natural := 2
45
  );
46
  port(
47
    OPA_V_i :  in std_logic;
48
    OPB_V_i :  in std_logic;
49
    OPA_i : in SDWORD_T;
50
    OPB_i : in SDWORD_T;
51
    INSTR_i : in DEC_INSTR_T;
52
    IX3_V_i : in std_logic_vector(NW-1 downto 0);
53
    IX3_INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0);
54
    IX3_RES0_i : in SDWORD_T;
55
    IX3_RES1_i : in SDWORD_T;
56
 
57
    OPA_V_o :  out std_logic;
58
    OPB_V_o :  out std_logic;
59
    OPA_o : out SDWORD_T;
60
    OPB_o : out SDWORD_T
61
 
62
  );
63
end RV01_PIPE_A_RMX_X2;
64
 
65
architecture ARC of RV01_PIPE_A_RMX_X2 is
66
 
67
  signal SELA1,SELB1 : std_logic;
68
  signal UOPA,UOPB : SDWORD_T;
69
  signal UOPA_V,UOPB_V : std_logic;
70
 
71
begin
72
 
73
  ------------------------------------
74
  -- Notes
75
  ------------------------------------
76
 
77
  -- Stage IX3 provides (up to) two results per cycle,
78
  -- requiring a mux to select the desired one.
79
 
80
  -- OPA source selection flag
81
  SELA1 <= IX3_V_i(1) when (
82
    IX3_INSTR_i(1).WRD = '1' and
83
    IX3_INSTR_i(1).RD = INSTR_i.RS1
84
  ) else '0';
85
 
86
  -- Updated OPA operand source mux
87
  UOPA <= IX3_RES1_i when (SELA1 = '1') else IX3_RES0_i;
88
 
89
  -- Updated OPA operand valid flag (flag is set if there's
90
  -- a valid value for it from IX3 stage).
91
 
92
  UOPA_V <=  '1' when (
93
    (
94
      IX3_V_i(0) = '1' and
95
      IX3_INSTR_i(0).WRD = '1' and
96
      IX3_INSTR_i(0).RD = INSTR_i.RS1
97
     ) or (
98
      IX3_V_i(1) = '1' and
99
      IX3_INSTR_i(1).WRD = '1' and
100
      IX3_INSTR_i(1).RD = INSTR_i.RS1
101
     )
102
  ) else '0';
103
 
104
  -- OPB source selection flag
105
  SELB1 <= IX3_V_i(1) when (
106
    IX3_INSTR_i(1).WRD = '1' and
107
    IX3_INSTR_i(1).RD = INSTR_i.RS2
108
  ) else '0';
109
 
110
  -- Updated OPB operand source mux
111
  UOPB <= IX3_RES1_i when (SELB1 = '1') else IX3_RES0_i;
112
 
113
  -- Updated OPB operand valid flag (flag is set if there's
114
  -- a valid value for it from IX3 stage).
115
 
116
  UOPB_V <= '1' when (
117
    (
118
      IX3_V_i(0) = '1' and
119
      IX3_INSTR_i(0).WRD = '1' and
120
      IX3_INSTR_i(0).RD = INSTR_i.RS2
121
     ) or (
122
      IX3_V_i(1) = '1' and
123
      IX3_INSTR_i(1).WRD = '1' and
124
      IX3_INSTR_i(1).RD = INSTR_i.RS2
125
     )
126
  ) else '0';
127
 
128
  OPA_V_o <= OPA_V_i or UOPA_V;
129
 
130
  OPB_V_o <= OPB_V_i or UOPB_V;
131
 
132
  OPA_o <= OPA_i when (OPA_V_i = '1') else UOPA;
133
 
134
  OPB_o <= OPB_i when (OPB_V_i = '1') else UOPB;
135
 
136
end ARC;

powered by: WebSVN 2.1.0

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