-
Notifications
You must be signed in to change notification settings - Fork 1
/
memory_tb.vhd
65 lines (57 loc) · 1.73 KB
/
memory_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
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity t_memory is
end t_memory;
architecture behavior of t_memory is
component Memory is
port (
ADDR: in STD_LOGIC_VECTOR(9 downto 0);
DIN: in STD_LOGIC_VECTOR(15 downto 0);
cMemWrite: in STD_LOGIC;
cMemRead: in STD_LOGIC;
outMemory: out STD_LOGIC_VECTOR(15 downto 0);
reset: in STD_LOGIC := '0'
);
end component Memory;
signal ADDR_t: STD_LOGIC_VECTOR(9 downto 0);
signal DIN_t: STD_LOGIC_VECTOR(15 downto 0);
signal cMemWrite_t: STD_LOGIC;
signal cMemRead_t: STD_LOGIC;
signal outMemory_t: STD_LOGIC_VECTOR(15 downto 0);
signal reset_t: STD_LOGIC;
begin
mem: Memory
port map(
ADDR => ADDR_t,
DIN => DIN_t,
cMemWrite => cMemWrite_t,
cMemRead => cMemRead_t,
outMemory => outMemory_t,
reset => reset_t
);
process
begin
-- Test reset
reset_t <= '1';
wait for 1 ms;
reset_t <= '0';
wait for 1 ms;
-- Test mem read/write
cMemWrite_t <= '1';
cMemRead_t <= '0';
ADDR_t <= "1010101010"; -- Address 682
DIN_t <= "1000000000000000"; -- 32768
wait for 1 ms;
cMemWrite_t <= '0';
cMemRead_t <= '1';
ADDR_t <= "1010101010";
wait for 1 ms;
assert outMemory_t = DIN_t;
-- Test passthrough
cMemRead_t <= '0';
cMemWrite_t <= '0';
wait for 1 ms;
assert outMemory_t = DIN_t;
end process;
end behavior;