OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [hf-riscv/] [core_rv32i/] [reg_bank.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
 
5
entity reg_bank is
6
        port (  clock:          in std_logic;
7
                read_reg1:      in std_logic_vector(4 downto 0);
8
                read_reg2:      in std_logic_vector(4 downto 0);
9
                write_reg:      in std_logic_vector(4 downto 0);
10
                wreg:           in std_logic;
11
                write_data:     in std_logic_vector(31 downto 0);
12
                read_data1:     out std_logic_vector(31 downto 0);
13
                read_data2:     out std_logic_vector(31 downto 0)
14
        );
15
end reg_bank;
16
 
17
architecture arch_reg_bank of reg_bank is
18
        type bank is array(0 to 31) of std_logic_vector(31 downto 0);
19
        signal registers: bank := (others => (others => '0'));
20
begin
21
        process(clock, write_reg, wreg, write_data, read_reg1, read_reg2, registers)
22
        begin
23
                if clock'event and clock = '1' then
24
                        if write_reg /= "00000" and wreg = '1' then
25
                                registers(conv_integer(write_reg)) <= write_data;
26
                        end if;
27
                end if;
28
        end process;
29
 
30
        read_data1 <= registers(conv_integer(read_reg1)) when read_reg1 /= "00000" else (others => '0');
31
        read_data2 <= registers(conv_integer(read_reg2)) when read_reg2 /= "00000" else (others => '0');
32
end arch_reg_bank;
33
 

powered by: WebSVN 2.1.0

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