-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestBenchRams.vhdtst
91 lines (73 loc) · 2.32 KB
/
TestBenchRams.vhdtst
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
-- Tester of RAM Module
Library IEEE;
Use IEEE.std_logic_1164.all;
Use IEEE.std_logic_textio.all;
Use STD.textio.all;
USE ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
USE ieee.numeric_std.ALL;
entity TestBenchRams is
end TestBenchRams;
architecture stimulus of TestBenchRams is
component rams
GENERIC(
WIDTH : integer := 16;
SIZE : integer := 16;
BITS_ADDRESS : integer := 4
);
Port (
WR : in std_logic;
CLK : in std_logic;
Datain : in std_logic_vector(WIDTH-1 downto 0);
Dataout : out std_logic_vector(WIDTH-1 downto 0);
Addr : in std_logic_vector(3 downto 0)
);
end component;
constant period_clk : time := 10 ns;
signal Datain : std_logic_vector(15 downto 0);
signal Dataout : std_logic_vector(15 downto 0);
signal Addr : std_logic_vector(3 downto 0);
signal WR : std_logic;
signal CLK : std_logic;
begin
-- DUT is Device Under Test
DUT:rams generic map(WIDTH => 16, SIZE => 16, BITS_ADDRESS => 4) port map(
WR => WR,
CLK => CLK,
Datain => Datain,
Dataout => Dataout,
Addr => Addr
);
CLK_process :process
begin
CLK <= '0';
wait for period_clk / 2;
CLK <= '1';
wait for period_clk / 2;
end process;
STIMULUS0:process
begin
-- insert stimulus here
WR <= '1';
Addr <= conv_std_logic_vector(0, 4);
Datain <= conv_std_logic_vector(1, 16);
wait for period_clk;
WR <= '1';
Addr <= conv_std_logic_vector(1, 4);
Datain <= conv_std_logic_vector(2, 16);
wait for period_clk;
WR <= '1';
Addr <= conv_std_logic_vector(2, 4);
Datain <= conv_std_logic_vector(3, 16);
wait for period_clk;
WR <= '0';
Addr <= conv_std_logic_vector(0, 4);
wait for period_clk;
WR <= '0';
Addr <= conv_std_logic_vector(1, 4);
wait for period_clk;
WR <= '0';
Addr <= conv_std_logic_vector(2, 4);
wait for period_clk;
end process;
end architecture;