-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_pixel_tb.vhd
234 lines (196 loc) · 6.32 KB
/
command_pixel_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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 16:36:09 05/07/2020
-- Design Name:
-- Module Name: /home/parallels/fpga_work/dvid_serdes/command_pixel_tb.vhd
-- Project Name: dvid_serdes
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: command_decoder
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY command_pixel_tb IS
END command_pixel_tb;
ARCHITECTURE behavior OF command_pixel_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT command_decoder
PORT(
clk : IN std_logic;
rx_busy : IN std_logic;
rx_data : IN std_logic_vector(7 downto 0);
cmd : OUT std_logic_vector(1 downto 0);
cmd_data : OUT std_logic_vector(31 downto 0);
cmd_enb : OUT std_logic
);
END COMPONENT;
COMPONENT pixel_writter
PORT(
clk : IN std_logic;
cmd_enb : IN std_logic;
cmd : IN std_logic_vector(1 downto 0);
data : IN std_logic_vector(31 downto 0);
busy : out STD_LOGIC;
write_addr : OUT std_logic_vector(15 downto 0);
write_pixel : OUT std_logic_vector(11 downto 0);
write_enb : OUT std_logic
);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
signal rx_busy : std_logic := '0';
signal rx_data : std_logic_vector(7 downto 0) := (others => '0');
--Outputs
signal cmd : std_logic_vector(1 downto 0);
signal cmd_data : std_logic_vector(31 downto 0);
signal cmd_enb : std_logic;
signal busy : std_logic;
--Write Out
signal write_addr : std_logic_vector(15 downto 0);
signal write_pixel : std_logic_vector(11 downto 0);
signal write_enb : std_logic;
signal command : std_logic_vector(7 downto 0) := (others => '0');
-- Clock period definitions
constant clk_period : time := 20 ns;
constant baud_period : time := 1000 ms / 115200;
procedure send_command(constant baud_period : in time;
signal command : in STD_LOGIC_VECTOR(7 downto 0);
signal rx_data : out STD_LOGIC_VECTOR(7 downto 0);
signal rx_busy : out STD_LOGIC
) is
begin
wait for baud_period;
rx_busy <= '1';
wait for baud_period*9;
rx_data <= command;
wait for baud_period*2;
rx_busy <= '0';
end send_command;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut_command: command_decoder PORT MAP (
clk => clk,
rx_busy => rx_busy,
rx_data => rx_data,
cmd => cmd,
cmd_data => cmd_data,
cmd_enb => cmd_enb
);
-- Instantiate the Unit Under Test (UUT)
uut_pixel: pixel_writter PORT MAP (
clk => clk,
cmd_enb => cmd_enb,
cmd => cmd,
data => cmd_data,
busy => busy,
write_addr => write_addr,
write_pixel => write_pixel,
write_enb => write_enb
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
-- insert stimulus here
command <= X"01";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"00";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"02";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"0F";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"ED";
send_command(baud_period, command, rx_data, rx_busy);
-- insert stimulus here
-- cmd send pixels
command <= X"02";
send_command(baud_period, command, rx_data, rx_busy);
-- send 8 pixels
command <= X"00";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"08";
send_command(baud_period, command, rx_data, rx_busy);
-- pair 1
command <= X"FE";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"DC";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"BA";
send_command(baud_period, command, rx_data, rx_busy);
-- pair 2
command <= X"98";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"76";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"54";
send_command(baud_period, command, rx_data, rx_busy);
-- pair 3
command <= X"32";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"10";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"FE";
send_command(baud_period, command, rx_data, rx_busy);
-- pair 4
command <= X"DC";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"BA";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"98";
send_command(baud_period, command, rx_data, rx_busy);
-- cmd send pixels
command <= X"02";
send_command(baud_period, command, rx_data, rx_busy);
-- send 8 pixels
command <= X"00";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"04";
send_command(baud_period, command, rx_data, rx_busy);
-- pair 1
command <= X"32";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"10";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"FE";
send_command(baud_period, command, rx_data, rx_busy);
-- pair 2
command <= X"DC";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"BA";
send_command(baud_period, command, rx_data, rx_busy);
command <= X"98";
send_command(baud_period, command, rx_data, rx_busy);
wait;
end process;
END;