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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [datapath/] [registers.vhdl] - Blame information for rev 13

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
LIBRARY unisim;
25
USE unisim.vcomponents.ALL;
26
 
27
ENTITY registers IS
28
 
29
  GENERIC (
30
    w_data : NATURAL := 16;
31
    w_regn : NATURAL := 5);
32
 
33
  PORT (
34
    reset    : IN  STD_LOGIC;
35
    clock    : IN  STD_LOGIC;
36
    reg_a    : IN  STD_LOGIC_VECTOR(w_regn - 1 DOWNTO 0);
37
    reg_b    : IN  STD_LOGIC_VECTOR(w_regn - 1 DOWNTO 0);
38
    we       : IN  STD_LOGIC;
39
    reg_data : IN  UNSIGNED(w_data - 1 DOWNTO 0);
40
    a_out    : OUT UNSIGNED(w_data - 1 DOWNTO 0);
41
    b_out    : OUT UNSIGNED(w_data - 1 DOWNTO 0));
42
 
43
END registers;
44
 
45
ARCHITECTURE Behavioral OF registers IS
46
 
47
  TYPE   register_array IS ARRAY(0 TO (2**w_regn) - 1) OF UNSIGNED(w_data - 1 DOWNTO 0);
48
  SIGNAL register_file : register_array;
49
 
50
BEGIN  -- Behavioral
51
 
52
-- purpose: This is the writing to the register file
53
-- type   : sequential
54
-- inputs : clock, reg_c
55
-- outputs: register_file
56
  reg : PROCESS (clock)
57
  BEGIN  -- PROCESS reg
58
    IF rising_edge(clock) THEN          -- rising clock edge
59
 
60
      IF we = '1' THEN
61
        register_file(to_integer(UNSIGNED(reg_a))) <= reg_data;
62
      END IF;
63
 
64
    END IF;
65
  END PROCESS reg;
66
 
67
-- purpose: Get contents of registers onto intermediate buses
68
-- type   : combinational
69
-- inputs : reg_a,reg_b
70
-- outputs: a_out,b_bout
71
  reg_outputs : PROCESS (reg_a, reg_b, register_file)
72
  BEGIN  -- PROCESS reg_outputs
73
    a_out <= register_file(to_integer(UNSIGNED(reg_a)));
74
    b_out <= register_file(to_integer(UNSIGNED(reg_b)));
75
  END PROCESS reg_outputs;
76
 
77
END Behavioral;

powered by: WebSVN 2.1.0

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