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

Subversion Repositories arm4u

[/] [arm4u/] [trunk/] [hdl/] [register_file.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Bregalad
-- This file is part of ARM4U CPU
2
-- 
3
-- This is a creation of the Laboratory of Processor Architecture
4
-- of Ecole Polytechnique Fédérale de Lausanne ( http://lap.epfl.ch )
5
--
6
-- register_file.vhd  --  Describes the register file of the processor
7
--                        Normally the synthesis tool should automatically infer
8
--                        a 32x32 SRAM unit to store the registers
9
--
10
-- Written By -  Jonathan Masur and Xavier Jimenez (2013)
11
--
12
-- This program is free software; you can redistribute it and/or modify it
13
-- under the terms of the GNU General Public License as published by the
14
-- Free Software Foundation; either version 2, or (at your option) any
15
-- later version.
16
--
17
-- This program is distributed in the hope that it will be useful,
18
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-- GNU General Public License for more details.
21
--
22
-- In other words, you are welcome to use, share and improve this program.
23
-- You are forbidden to forbid anyone else to use, share and improve
24
-- what you give them.   Help stamp out software-hoarding!
25
 
26
library ieee;
27
use ieee.std_logic_1164.all;
28
use ieee.std_logic_unsigned.all;
29
 
30
entity register_file is
31
    port(
32
        clk    : in std_logic;
33
        aa     : in  std_logic_vector( 4 downto 0);
34
        ab     : in  std_logic_vector( 4 downto 0);
35
                ac     : in  std_logic_vector( 4 downto 0);
36
        aw     : in  std_logic_vector( 4 downto 0);
37
        wren   : in  std_logic;
38
                rd_clken : in std_logic := '1';
39
        wrdata : in  std_logic_vector(31 downto 0);
40
        a      : out std_logic_vector(31 downto 0);
41
        b      : out std_logic_vector(31 downto 0);
42
                c      : out std_logic_vector(31 downto 0)
43
    );
44
end register_file;
45
 
46
architecture synth of register_file is
47
    type reg_type is array (0 to 31) of std_logic_vector(31 downto 0);
48
    signal reg_array : reg_type := (others=>(others=>'0'));
49
        signal aal, abl, acl : std_logic_vector(4 downto 0);
50
begin
51
 
52
process(clk) is
53
        variable aav, abv, acv : std_logic_vector(4 downto 0);
54
begin
55
    if(rising_edge(clk))then
56
                if rd_clken = '1'
57
                then
58
                        aav := aa;
59
                        abv := ab;
60
                        acv := ac;
61
                else
62
                        aav := aal;
63
                        abv := abl;
64
                        acv := acl;
65
                end if;
66
 
67
                a <= reg_array(conv_integer(aav));
68
                b <= reg_array(conv_integer(abv));
69
                c <= reg_array(conv_integer(acv));
70
 
71
                aal <= aav;
72
                abl <= abv;
73
                acl <= acv;
74
 
75
        if(wren='1')then
76
            reg_array(conv_integer(aw)) <= wrdata;
77
        end if;
78
    end if;
79
end process;
80
 
81
end synth;

powered by: WebSVN 2.1.0

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