blob: d9f4a0ae435f800334edd35ee7cd1051f40c5fdc (
plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY buff_test IS
END buff_test;
ARCHITECTURE behavior OF buff_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT buff
PORT(
wr_clk : IN std_logic;
wr_en : IN std_logic;
wr_data : IN std_logic_vector(63 downto 0);
wr_done : IN std_logic;
wr_accept : OUT std_logic;
rd_clk : IN std_logic;
rd_en : IN std_logic;
rd_data : OUT std_logic_vector(63 downto 0);
rd_length : OUT std_logic_vector(8 downto 0);
rd_valid : OUT std_logic
);
END COMPONENT;
signal wr_clk : std_logic := '0';
signal wr_en : std_logic := '0';
signal wr_data : std_logic_vector(63 downto 0) := (others => '0');
signal wr_done : std_logic := '0';
signal wr_accept : std_logic;
signal rd_clk : std_logic := '0';
signal rd_en : std_logic := '0';
signal rd_data : std_logic_vector(63 downto 0);
signal rd_length : std_logic_vector(8 downto 0);
signal rd_valid : std_logic;
-- Clock period definitions
constant wr_clk_period : time := 10 ns;
constant rd_clk_period : time := 7 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: buff PORT MAP (
wr_clk => wr_clk,
wr_en => wr_en,
wr_data => wr_data,
wr_done => wr_done,
wr_accept => wr_accept,
rd_clk => rd_clk,
rd_en => rd_en,
rd_data => rd_data,
rd_length => rd_length,
rd_valid => rd_valid
);
-- Clock process definitions
wr_clk_process :process
begin
wr_clk <= '0';
wait for wr_clk_period/2;
wr_clk <= '1';
wait for wr_clk_period/2;
end process;
rd_clk_process :process
begin
rd_clk <= '0';
wait for rd_clk_period/2;
rd_clk <= '1';
wait for rd_clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for wr_clk_period;
wr_en <= '1';
wr_data <= x"0123456789ABCDEF";
wait for wr_clk_period;
wr_en <= '1';
wr_data <= x"FEDCBA9876543210";
wait for wr_clk_period;
wr_en <= '0';
wr_data <= x"0000000000000000";
wr_done <= '1';
wait for wr_clk_period;
wr_done <= '0';
wait until wr_accept = '1';
wait for wr_clk_period / 2;
wr_en <= '1';
wr_data <= x"AAAAAAAAAAAAAAAA";
wait for wr_clk_period;
wr_data <= x"BBBBBBBBBBBBBBBB";
wait for wr_clk_period;
wr_data <= x"CCCCCCCCCCCCCCCC";
wait for wr_clk_period;
wr_data <= x"DDDDDDDDDDDDDDDD";
wait for wr_clk_period;
wr_en <= '0';
wr_data <= x"0000000000000000";
wr_done <= '1';
wait for wr_clk_period;
wr_done <= '0';
wait until wr_accept = '1';
wait for wr_clk_period / 2;
wait for wr_clk_period;
wr_en <= '1';
wr_data <= x"0123456789ABCDEF";
wait for wr_clk_period;
wr_data <= x"FEDCBA9876543210";
wait for wr_clk_period;
wr_data <= x"0123456789ABCDEF";
wait for wr_clk_period;
wr_data <= x"FEDCBA9876543210";
wait for wr_clk_period;
wr_en <= '0';
wr_data <= x"0000000000000000";
wr_done <= '1';
wait for wr_clk_period;
wr_done <= '0';
wait;
end process;
process
begin
rd_en <= '0';
wait for rd_clk_period;
rd_en <= '1';
wait for rd_clk_period * 2;
end process;
END;
|