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] - 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) 2015 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 32x32 Register File
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
 
40
entity RV01_REGFILE_32X32_2W is
41
  port(
42
    CLK_i : in std_logic;
43
    RA0_i : in RID_T;
44
    RA1_i : in RID_T;
45
    RA2_i : in RID_T;
46
    RA3_i : in RID_T;
47
    WA0_i : in RID_T;
48
    WA1_i : in RID_T;
49
    WE0_i : in std_logic;
50
    WE1_i : in std_logic;
51
    D0_i : in std_logic_vector(SDLEN-1 downto 0);
52
    D1_i : in std_logic_vector(SDLEN-1 downto 0);
53
 
54
    Q0_o : out std_logic_vector(SDLEN-1 downto 0);
55
    Q1_o : out std_logic_vector(SDLEN-1 downto 0);
56
    Q2_o : out std_logic_vector(SDLEN-1 downto 0);
57
    Q3_o : out std_logic_vector(SDLEN-1 downto 0)
58
  );
59
end RV01_REGFILE_32X32_2W;
60
 
61
architecture ARC of RV01_REGFILE_32X32_2W is
62
 
63
  subtype WORD_T is std_logic_vector(SDLEN-1 downto 0);
64
  type MEM_T is array (REGNUM-1 downto 0) of WORD_T;
65
 
66
  signal REG_q : MEM_T;
67
 
68
begin
69
 
70
  -- sync. write
71
  process(CLK_i)
72
  begin
73
    if(CLK_i = '1' and CLK_i'event) then
74
      if(WE0_i = '1') then
75
        REG_q(WA0_i) <= D0_i;
76
      end if;
77
      if(WE1_i = '1') then
78
        REG_q(WA1_i) <= D1_i;
79
      end if;
80
    end if;
81
 
82
  end process;
83
 
84
  -- async. read
85
  Q0_o <= REG_q(RA0_i) when not(RA0_i = 0) else (others => '0');
86
  Q1_o <= REG_q(RA1_i) when not(RA1_i = 0) else (others => '0');
87
  Q2_o <= REG_q(RA2_i) when not(RA2_i = 0) else (others => '0');
88
  Q3_o <= REG_q(RA3_i) when not(RA3_i = 0) else (others => '0');
89
 
90
end ARC;

powered by: WebSVN 2.1.0

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