-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregs.vhd
36 lines (29 loc) · 878 Bytes
/
regs.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity regs is
port (
clk, reset, we : in std_logic;
rd, rs : in std_logic_vector(3 downto 0);
din : in std_logic_vector(7 downto 0);
dout : out std_logic_vector(7 downto 0)
);
end regs;
architecture regs_beh of regs is
constant REG_TAM : integer := 16;
type mem is array(REG_TAM-1 downto 0) of std_logic_vector(7 downto 0);
signal registers : mem;
begin
process (clk, reset)
begin
if reset = '1' then
for i in 0 to REG_TAM - 1 loop
registers(i) <= (others => '0');
end loop;
elsif (rising_edge(clk) and we = '1') then
-- report to_string(rd) & ':' & to_string(conv_integer(rd));
registers(conv_integer(rd)) <= din;
end if;
end process;
dout <= registers(conv_integer(rs));
end regs_beh;