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] - Rev 4
Compare with Previous | Blame | View Log
----------------------------------------------------------------- -- -- ----------------------------------------------------------------- -- -- -- Copyright (C) 2017 Stefano Tonello -- -- -- -- This source file may be used and distributed without -- -- restriction provided that this copyright statement is not -- -- removed from the file and that any derivative work contains -- -- the original copyright notice and the associated disclaimer.-- -- -- -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY -- -- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -- -- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -- -- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR -- -- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -- -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -- -- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -- -- BUSINESS REQERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -- -- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- -- POSSIBILITY OF SUCH DAMAGE. -- -- -- ----------------------------------------------------------------- --------------------------------------------------------------- -- A-pipeline result mux (IX2 stage) --------------------------------------------------------------- library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; library WORK; use WORK.RV01_CONSTS_PKG.all; use WORK.RV01_TYPES_PKG.all; use WORK.RV01_FUNCS_PKG.all; use work.RV01_IDEC_PKG.all; entity RV01_PIPE_A_RMX_X2 is generic( NW : natural := 2 ); port( OPA_V_i : in std_logic; OPB_V_i : in std_logic; OPA_i : in SDWORD_T; OPB_i : in SDWORD_T; INSTR_i : in DEC_INSTR_T; IX3_V_i : in std_logic_vector(NW-1 downto 0); IX3_INSTR_i : in DEC_INSTR_VEC_T(NW-1 downto 0); IX3_RES0_i : in SDWORD_T; IX3_RES1_i : in SDWORD_T; OPA_V_o : out std_logic; OPB_V_o : out std_logic; OPA_o : out SDWORD_T; OPB_o : out SDWORD_T ); end RV01_PIPE_A_RMX_X2; architecture ARC of RV01_PIPE_A_RMX_X2 is signal SELA1,SELB1 : std_logic; signal UOPA,UOPB : SDWORD_T; signal UOPA_V,UOPB_V : std_logic; begin ------------------------------------ -- Notes ------------------------------------ -- Stage IX3 provides (up to) two results per cycle, -- requiring a mux to select the desired one. -- OPA source selection flag SELA1 <= IX3_V_i(1) when ( IX3_INSTR_i(1).WRD = '1' and IX3_INSTR_i(1).RD = INSTR_i.RS1 ) else '0'; -- Updated OPA operand source mux UOPA <= IX3_RES1_i when (SELA1 = '1') else IX3_RES0_i; -- Updated OPA operand valid flag (flag is set if there's -- a valid value for it from IX3 stage). UOPA_V <= '1' when ( ( IX3_V_i(0) = '1' and IX3_INSTR_i(0).WRD = '1' and IX3_INSTR_i(0).RD = INSTR_i.RS1 ) or ( IX3_V_i(1) = '1' and IX3_INSTR_i(1).WRD = '1' and IX3_INSTR_i(1).RD = INSTR_i.RS1 ) ) else '0'; -- OPB source selection flag SELB1 <= IX3_V_i(1) when ( IX3_INSTR_i(1).WRD = '1' and IX3_INSTR_i(1).RD = INSTR_i.RS2 ) else '0'; -- Updated OPB operand source mux UOPB <= IX3_RES1_i when (SELB1 = '1') else IX3_RES0_i; -- Updated OPB operand valid flag (flag is set if there's -- a valid value for it from IX3 stage). UOPB_V <= '1' when ( ( IX3_V_i(0) = '1' and IX3_INSTR_i(0).WRD = '1' and IX3_INSTR_i(0).RD = INSTR_i.RS2 ) or ( IX3_V_i(1) = '1' and IX3_INSTR_i(1).WRD = '1' and IX3_INSTR_i(1).RD = INSTR_i.RS2 ) ) else '0'; OPA_V_o <= OPA_V_i or UOPA_V; OPB_V_o <= OPB_V_i or UOPB_V; OPA_o <= OPA_i when (OPA_V_i = '1') else UOPA; OPB_o <= OPB_i when (OPB_V_i = '1') else UOPB; end ARC;