-
Notifications
You must be signed in to change notification settings - Fork 0
/
register_file_tb.vhd
executable file
·108 lines (85 loc) · 2.31 KB
/
register_file_tb.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
library ieee;
use ieee.std_logic_1164.all;
entity REGISTER_FILE_TB is
end entity;
architecture REGISTER_FILE_TB_ARCH of REGISTER_FILE_TB is
component REGISTER_FILE is
generic(
REGESTER_SIZE : integer; -- Size of each register in the register file
REGISTER_COUNT : integer -- Number of registers in the register file
);
port(
IDATA : in std_logic_vector(REGESTER_SIZE - 1 downto 0); -- STD logic vector for input data
CLK : in std_logic; -- Clock input
SEL : in std_logic_vector(4 - 1 downto 0); -- Select signal for addressing to registers
RES : in std_logic; -- Reset signal
WRITE_EN : in std_logic; -- Wrinting enable signal
READ_EN : in std_logic; -- Reading enable signal
ODATA : out std_logic_vector(REGESTER_SIZE - 1 downto 0) -- Output of data
);
end component;
constant REG_SIZE : integer := 8;
constant REG_COUNT : integer := 16;
signal clock : std_logic := '1';
signal indata : std_logic_vector(REG_SIZE - 1 downto 0);
signal odata : std_logic_vector(REG_SIZE - 1 downto 0);
signal selec : std_logic_vector(3 downto 0);
signal reset : std_logic;
signal writeE : std_logic;
signal readE : std_logic;
begin
R_FILE : REGISTER_FILE
generic map(REG_SIZE, REG_COUNT)
port map(indata, clock, selec, reset, writeE, readE, odata);
process
begin
loop
clock <= not clock;
wait for 5 ns;
clock <= not clock;
wait for 5 ns;
-- clock period = 10 ns
end loop;
end process;
process
begin
indata <= "00000000";
selec <= "0000";
writeE <= '0';
readE <= '0';
reset <= '0';
wait for 10 ns;
indata <= "00000000";
selec <= "0000";
writeE <= '1';
readE <= '0';
reset <= '0';
wait for 10 ns;
indata <= "00000000";
selec <= "0000";
writeE <= '0';
readE <= '0';
reset <= '0';
wait for 10 ns;
indata <= "00000000";
selec <= "0001";
writeE <= '1';
readE <= '0';
reset <= '0';
wait for 10 ns;
indata <= "00000000";
selec <= "0000";
writeE <= '0';
readE <= '0';
reset <= '0';
wait for 10 ns;
indata <= "00000000";
selec <= "0000";
writeE <= '0';
readE <= '1';
reset <= '0';
wait for 1 ns;
assert false report "Reached end of test";
wait;
end process;
end architecture;