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

Subversion Repositories potato

[/] [potato/] [trunk/] [src/] [pp_register_file.vhd] - Blame information for rev 45

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

Line No. Rev Author Line
1 2 skordal
-- The Potato Processor - A simple processor for FPGAs
2
-- (c) Kristian Klomsten Skordal 2014 <kristian.skordal@wafflemail.net>
3 3 skordal
-- Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
4 2 skordal
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use ieee.numeric_std.all;
8
 
9
use work.pp_types.all;
10
use work.pp_utilities.all;
11
 
12
--! @brief 32-bit RISC-V register file.
13
entity pp_register_file is
14
        port(
15
                clk    : in std_logic;
16
 
17
                -- Read port 1:
18
                rs1_addr : in  register_address;
19
                rs1_data : out std_logic_vector(31 downto 0);
20
 
21
                -- Read port 2:
22
                rs2_addr : in  register_address;
23
                rs2_data : out std_logic_vector(31 downto 0);
24
 
25
                -- Write port:
26
                rd_addr  : in register_address;
27
                rd_data  : in std_logic_vector(31 downto 0);
28
                rd_write : in std_logic
29
        );
30
end entity pp_register_file;
31
 
32
architecture behaviour of pp_register_file is
33
 
34
        --! Register array type.
35
        type regfile_array is array(0 to 31) of std_logic_vector(31 downto 0);
36
 
37
        --! Register array.
38
        --shared variable registers : regfile_array := (others => (others => '0')); -- Shared variable used to simulate write-first RAM
39
 
40
begin
41
 
42
        regfile: process(clk)
43
                variable registers : regfile_array := (others => (others => '0'));
44
        begin
45
                if rising_edge(clk) then
46
                                if rd_write = '1' and rd_addr /= b"00000" then
47
                                        registers(to_integer(unsigned(rd_addr))) := rd_data;
48
                                end if;
49
 
50
                                rs1_data <= registers(to_integer(unsigned(rs1_addr)));
51
                                rs2_data <= registers(to_integer(unsigned(rs2_addr)));
52
                end if;
53
        end process regfile;
54
 
55
end architecture behaviour;

powered by: WebSVN 2.1.0

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