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

Subversion Repositories rv01_riscv_core

[/] [rv01_riscv_core/] [trunk/] [VHDL/] [RV01_regfile_32x32_2w.vhd] - Rev 2

Compare with Previous | Blame | View Log

-----------------------------------------------------------------
--                                                             --
-----------------------------------------------------------------
--                                                             --
-- Copyright (C) 2015 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 INTERRUPTION) 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.                                 --
--                                                             --
-----------------------------------------------------------------
 
---------------------------------------------------------------
-- RV01 32x32 Register File
---------------------------------------------------------------
 
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;
 
entity RV01_REGFILE_32X32_2W is
  port(
    CLK_i : in std_logic;
    RA0_i : in RID_T;
    RA1_i : in RID_T;
    RA2_i : in RID_T;
    RA3_i : in RID_T;
    WA0_i : in RID_T;
    WA1_i : in RID_T;
    WE0_i : in std_logic;
    WE1_i : in std_logic;
    D0_i : in std_logic_vector(SDLEN-1 downto 0);
    D1_i : in std_logic_vector(SDLEN-1 downto 0);
 
    Q0_o : out std_logic_vector(SDLEN-1 downto 0);
    Q1_o : out std_logic_vector(SDLEN-1 downto 0);
    Q2_o : out std_logic_vector(SDLEN-1 downto 0);
    Q3_o : out std_logic_vector(SDLEN-1 downto 0)
  );
end RV01_REGFILE_32X32_2W;
 
architecture ARC of RV01_REGFILE_32X32_2W is
 
  subtype WORD_T is std_logic_vector(SDLEN-1 downto 0);
  type MEM_T is array (REGNUM-1 downto 0) of WORD_T;
 
  signal REG_q : MEM_T;
 
begin
 
  -- sync. write
  process(CLK_i)
  begin
    if(CLK_i = '1' and CLK_i'event) then
      if(WE0_i = '1') then
        REG_q(WA0_i) <= D0_i;
      end if;
      if(WE1_i = '1') then
        REG_q(WA1_i) <= D1_i;
      end if;
    end if;
 
  end process;
 
  -- async. read
  Q0_o <= REG_q(RA0_i) when not(RA0_i = 0) else (others => '0');
  Q1_o <= REG_q(RA1_i) when not(RA1_i = 0) else (others => '0');
  Q2_o <= REG_q(RA2_i) when not(RA2_i = 0) else (others => '0');
  Q3_o <= REG_q(RA3_i) when not(RA3_i = 0) else (others => '0');
 
end ARC;

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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