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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [src/] [components/] [regf.vhdl] - Blame information for rev 41

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19
 
20
LIBRARY IEEE;
21
USE IEEE.STD_LOGIC_1164.ALL;
22
USE IEEE.numeric_std.ALL;
23
 
24
ENTITY regf IS
25
  GENERIC (
26
    w_data : NATURAL := 16;
27
    w_addr : NATURAL := 5);
28
  PORT (clk : IN  STD_LOGIC;
29
        we  : IN  STD_LOGIC;
30
        a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
31
        a2  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
32
        d   : IN  STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
33
        q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
34
        q2  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));
35
END ENTITY regf;
36
 
37
ARCHITECTURE Behavioral OF regf IS
38
 
39
  CONSTANT RFSIZE : NATURAL := 2**w_addr;
40
 
41
  TYPE reg_array IS ARRAY(0 TO RFSIZE - 1) OF STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
42
 
43
  SIGNAL reg : reg_array;
44
 
45
BEGIN  -- ARCHITECTURE Behavioral
46
 
47
  -- purpose: Single input, dual output register file
48
  -- type   : sequential
49
  -- inputs : clk, we, a1, a2, d
50
  -- outputs: q1, q2
51
  REGF: PROCESS (clk) IS
52
  BEGIN  -- PROCESS REGF
53
    IF rising_edge(clk) THEN  -- rising clock edge
54
      IF we = '1' THEN
55
        reg(to_integer(UNSIGNED('0' & a1))) <= d;
56
      END IF;
57
    END IF;
58
  END PROCESS REGF;
59
 
60
  q1 <= reg(to_integer(UNSIGNED('0' & a1)));
61
  q2 <= reg(to_integer(UNSIGNED('0' & a2)));
62
 
63
END ARCHITECTURE Behavioral;
64
 

powered by: WebSVN 2.1.0

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