1 |
5 |
tantos |
library ieee,exemplar;
|
2 |
|
|
use ieee.std_logic_1164.all;
|
3 |
|
|
use exemplar.exemplar_1164.all;
|
4 |
|
|
|
5 |
|
|
library wb_tk;
|
6 |
|
|
use wb_tk.wb_test.all;
|
7 |
|
|
|
8 |
|
|
library wb_vga;
|
9 |
|
|
use wb_vga.all;
|
10 |
|
|
use wb_vga.constants.all;
|
11 |
|
|
|
12 |
|
|
entity vga_chip_tb is
|
13 |
|
|
end vga_chip_tb;
|
14 |
|
|
|
15 |
|
|
architecture TB of vga_chip_tb is
|
16 |
|
|
-- Component declaration of the tested unit
|
17 |
|
|
component vga_chip is
|
18 |
|
|
port (
|
19 |
|
|
clk_i: in std_logic;
|
20 |
|
|
clk_en: in std_logic := '1';
|
21 |
|
|
rst_i: in std_logic := '0';
|
22 |
|
|
|
23 |
|
|
-- CPU bus interface
|
24 |
|
|
dat_i: in std_logic_vector (cpu_dat_width-1 downto 0);
|
25 |
|
|
dat_oi: in std_logic_vector (cpu_dat_width-1 downto 0);
|
26 |
|
|
dat_o: out std_logic_vector (cpu_dat_width-1 downto 0);
|
27 |
|
|
cyc_i: in std_logic;
|
28 |
|
|
ack_o: out std_logic;
|
29 |
|
|
ack_oi: in std_logic;
|
30 |
|
|
we_i: in std_logic;
|
31 |
|
|
vmem_stb_i: in std_logic;
|
32 |
|
|
reg_stb_i: in std_logic;
|
33 |
|
|
adr_i: in std_logic_vector (cpu_adr_width-1 downto 0);
|
34 |
|
|
sel_i: in std_logic_vector ((cpu_dat_width/8)-1 downto 0) := (others => '1');
|
35 |
|
|
|
36 |
|
|
-- video memory SRAM interface
|
37 |
|
|
s_data : inout std_logic_vector(v_dat_width-1 downto 0);
|
38 |
|
|
s_addr : out std_logic_vector(v_adr_width-1 downto 0);
|
39 |
|
|
s_oen : out std_logic;
|
40 |
|
|
s_wrhn : out std_logic;
|
41 |
|
|
s_wrln : out std_logic;
|
42 |
|
|
s_cen : out std_logic;
|
43 |
|
|
|
44 |
|
|
-- sync blank and video signal outputs
|
45 |
|
|
h_sync: out std_logic;
|
46 |
|
|
h_blank: out std_logic;
|
47 |
|
|
v_sync: out std_logic;
|
48 |
|
|
v_blank: out std_logic;
|
49 |
|
|
h_tc: out std_logic;
|
50 |
|
|
v_tc: out std_logic;
|
51 |
|
|
blank: out std_logic;
|
52 |
|
|
video_out: out std_logic_vector (7 downto 0) -- video output binary signal (unused bits are forced to 0)
|
53 |
|
|
);
|
54 |
|
|
end component;
|
55 |
|
|
|
56 |
|
|
-- Stimulus signals - signals mapped to the input and inout ports of tested entity
|
57 |
|
|
signal clk_i : std_logic;
|
58 |
|
|
signal clk_en : std_logic;
|
59 |
|
|
signal rst_i : std_logic;
|
60 |
|
|
signal dat_i : std_logic_vector(cpu_dat_width-1 downto 0);
|
61 |
|
|
signal dat_oi : std_logic_vector(cpu_dat_width-1 downto 0);
|
62 |
|
|
signal cyc_i : std_logic;
|
63 |
|
|
signal ack_oi : std_logic;
|
64 |
|
|
signal we_i : std_logic;
|
65 |
|
|
signal vmem_stb_i : std_logic;
|
66 |
|
|
signal reg_stb_i : std_logic;
|
67 |
|
|
signal adr_i : std_logic_vector(cpu_adr_width-1 downto 0);
|
68 |
|
|
signal sel_i: std_logic_vector ((cpu_dat_width/8)-1 downto 0) := (others => '1');
|
69 |
|
|
signal s_data : std_logic_vector(v_dat_width-1 downto 0);
|
70 |
|
|
-- Observed signals - signals mapped to the output ports of tested entity
|
71 |
|
|
signal dat_o : std_logic_vector(cpu_dat_width-1 downto 0);
|
72 |
|
|
signal ack_o : std_logic;
|
73 |
|
|
signal s_addr : std_logic_vector(v_adr_width-1 downto 0);
|
74 |
|
|
signal s_oen : std_logic;
|
75 |
|
|
signal s_wrhn : std_logic;
|
76 |
|
|
signal s_wrln : std_logic;
|
77 |
|
|
signal s_cen : std_logic;
|
78 |
|
|
signal h_sync : std_logic;
|
79 |
|
|
signal h_blank : std_logic;
|
80 |
|
|
signal v_sync : std_logic;
|
81 |
|
|
signal v_blank : std_logic;
|
82 |
|
|
signal h_tc : std_logic;
|
83 |
|
|
signal v_tc : std_logic;
|
84 |
|
|
signal blank : std_logic;
|
85 |
|
|
signal video_out : std_logic_vector(7 downto 0);
|
86 |
|
|
|
87 |
6 |
tantos |
constant reg_total0 : integer := 0;
|
88 |
|
|
constant reg_total1 : integer := 1;
|
89 |
|
|
constant reg_total2 : integer := 2;
|
90 |
|
|
constant reg_total3 : integer := 3;
|
91 |
|
|
constant reg_ofs0 : integer := 4;
|
92 |
|
|
constant reg_ofs1 : integer := 5;
|
93 |
|
|
constant reg_ofs2 : integer := 6;
|
94 |
|
|
constant reg_ofs3 : integer := 7;
|
95 |
5 |
tantos |
|
96 |
6 |
tantos |
constant reg_fifo_treshold : integer := 16;
|
97 |
|
|
constant reg_bpp : integer := 17;
|
98 |
|
|
constant reg_hbs : integer := 18;
|
99 |
|
|
constant reg_hss : integer := 19;
|
100 |
|
|
constant reg_hse : integer := 20;
|
101 |
|
|
constant reg_htotal : integer := 21;
|
102 |
|
|
constant reg_vbs : integer := 22;
|
103 |
|
|
constant reg_vss : integer := 23;
|
104 |
|
|
constant reg_vse : integer := 24;
|
105 |
|
|
constant reg_vtotal : integer := 25;
|
106 |
|
|
constant reg_pps : integer := 26;
|
107 |
|
|
constant reg_sync_pol : integer := 27;
|
108 |
|
|
|
109 |
|
|
constant reg_ws : integer := 32;
|
110 |
5 |
tantos |
|
111 |
|
|
constant val_total0 : std_logic_vector(7 downto 0) := "00001111";
|
112 |
|
|
constant val_total1 : std_logic_vector(7 downto 0) := "00000000";
|
113 |
|
|
constant val_total2 : std_logic_vector(7 downto 0) := "00000000";
|
114 |
|
|
constant val_total3 : std_logic_vector(7 downto 0) := "00000000";
|
115 |
|
|
constant val_ofs0 : std_logic_vector(7 downto 0) := "00000000";
|
116 |
|
|
constant val_ofs1 : std_logic_vector(7 downto 0) := "00000000";
|
117 |
|
|
constant val_ofs2 : std_logic_vector(7 downto 0) := "00000000";
|
118 |
|
|
constant val_ofs3 : std_logic_vector(7 downto 0) := "00000000";
|
119 |
|
|
constant val_fifo_treshold : std_logic_vector(7 downto 0) := "00000011";
|
120 |
|
|
constant val_bpp : std_logic_vector(7 downto 0) := "00000011";
|
121 |
|
|
constant val_hbs : std_logic_vector(7 downto 0) := "00000111";
|
122 |
|
|
constant val_hss : std_logic_vector(7 downto 0) := "00001000";
|
123 |
|
|
constant val_hse : std_logic_vector(7 downto 0) := "00001001";
|
124 |
|
|
constant val_htotal : std_logic_vector(7 downto 0) := "00001010";
|
125 |
|
|
constant val_vbs : std_logic_vector(7 downto 0) := "00000001";
|
126 |
|
|
constant val_vss : std_logic_vector(7 downto 0) := "00000010";
|
127 |
|
|
constant val_vse : std_logic_vector(7 downto 0) := "00000011";
|
128 |
|
|
constant val_vtotal : std_logic_vector(7 downto 0) := "00000100";
|
129 |
|
|
constant val_pps : std_logic_vector(7 downto 0) := "00000001";
|
130 |
|
|
constant val_sync_pol : std_logic_vector(7 downto 0) := "10000000";
|
131 |
6 |
tantos |
constant val_ws : std_logic_vector(7 downto 0) := "00000010";
|
132 |
5 |
tantos |
|
133 |
|
|
begin
|
134 |
|
|
|
135 |
|
|
-- Unit Under Test port map
|
136 |
|
|
UUT : vga_chip
|
137 |
|
|
port map (
|
138 |
|
|
clk_i => clk_i,
|
139 |
|
|
clk_en => clk_en,
|
140 |
|
|
rst_i => rst_i,
|
141 |
|
|
dat_i => dat_i,
|
142 |
|
|
dat_oi => dat_oi,
|
143 |
|
|
dat_o => dat_o,
|
144 |
|
|
cyc_i => cyc_i,
|
145 |
|
|
ack_o => ack_o,
|
146 |
|
|
ack_oi => ack_oi,
|
147 |
|
|
we_i => we_i,
|
148 |
|
|
vmem_stb_i => vmem_stb_i,
|
149 |
|
|
reg_stb_i => reg_stb_i,
|
150 |
|
|
adr_i => adr_i,
|
151 |
|
|
s_data => s_data,
|
152 |
|
|
s_addr => s_addr,
|
153 |
|
|
s_oen => s_oen,
|
154 |
|
|
s_wrhn => s_wrhn,
|
155 |
|
|
s_wrln => s_wrln,
|
156 |
|
|
s_cen => s_cen,
|
157 |
|
|
h_sync => h_sync,
|
158 |
|
|
h_blank => h_blank,
|
159 |
|
|
v_sync => v_sync,
|
160 |
|
|
v_blank => v_blank,
|
161 |
|
|
h_tc => h_tc,
|
162 |
|
|
v_tc => v_tc,
|
163 |
|
|
blank => blank,
|
164 |
|
|
video_out => video_out
|
165 |
|
|
);
|
166 |
|
|
|
167 |
|
|
-- Add your stimulus here ...
|
168 |
|
|
|
169 |
|
|
clk_en <= '1';
|
170 |
|
|
-- Add your stimulus here ...
|
171 |
|
|
clock: process is
|
172 |
|
|
begin
|
173 |
|
|
wait for 25 ns;
|
174 |
|
|
clk_i <= '1';
|
175 |
|
|
wait for 25 ns;
|
176 |
|
|
clk_i <= '0';
|
177 |
|
|
end process;
|
178 |
|
|
|
179 |
|
|
ack_oi <= '0';
|
180 |
|
|
dat_oi <= (others => '0');
|
181 |
|
|
|
182 |
|
|
setup: process is
|
183 |
|
|
begin
|
184 |
|
|
sel_i <= (others => '1');
|
185 |
|
|
we_i <= '0';
|
186 |
|
|
reg_stb_i <= '0';
|
187 |
|
|
vmem_stb_i <= '0';
|
188 |
|
|
cyc_i <= '0';
|
189 |
|
|
rst_i <= '1';
|
190 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
191 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
192 |
|
|
rst_i <= '0';
|
193 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
194 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
195 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
196 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
197 |
|
|
|
198 |
6 |
tantos |
if (cpu_dat_width = 8) then
|
199 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total0 ,val_total0);
|
200 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total1 ,val_total1);
|
201 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total2 ,val_total2);
|
202 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total3 ,val_total3);
|
203 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs0 ,val_ofs0);
|
204 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs1 ,val_ofs1);
|
205 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs2 ,val_ofs2);
|
206 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs3 ,val_ofs3);
|
207 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ws ,val_ws);
|
208 |
|
|
|
209 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
210 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
211 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
212 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
213 |
|
|
|
214 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_fifo_treshold ,val_fifo_treshold);
|
215 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_bpp ,val_bpp);
|
216 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_hbs ,val_hbs);
|
217 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_hss ,val_hss);
|
218 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_hse ,val_hse);
|
219 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_htotal ,val_htotal);
|
220 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vbs ,val_vbs);
|
221 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vss ,val_vss);
|
222 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vse ,val_vse);
|
223 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vtotal ,val_vtotal);
|
224 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_pps ,val_pps);
|
225 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_sync_pol ,val_sync_pol);
|
226 |
|
|
end if;
|
227 |
|
|
if (cpu_dat_width = 16) then
|
228 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total0/2 ,val_total1 & val_total0);
|
229 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total2/2 ,val_total3 & val_total2);
|
230 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs0/2 ,val_ofs1 & val_ofs0);
|
231 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs2/2 ,val_ofs3 & val_ofs2);
|
232 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ws/2 ,"00000000" & val_ws );
|
233 |
|
|
|
234 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
235 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
236 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
237 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
238 |
|
|
|
239 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_fifo_treshold/2 ,val_bpp & val_fifo_treshold);
|
240 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_hbs/2 ,val_hss & val_hbs);
|
241 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_hse/2 ,val_htotal & val_hse);
|
242 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vbs/2 ,val_vss & val_vbs);
|
243 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vse/2 ,val_vtotal & val_vse);
|
244 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_pps/2 ,val_sync_pol & val_pps);
|
245 |
|
|
end if;
|
246 |
|
|
if (cpu_dat_width = 32) then
|
247 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_total0/4 ,val_total3 & val_total2 & val_total1 & val_total0);
|
248 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ofs0/4 ,val_ofs3 & val_ofs2 & val_ofs1 & val_ofs0);
|
249 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_ws/4 ,"000000000000000000000000" & val_ws );
|
250 |
|
|
|
251 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
252 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
253 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
254 |
|
|
wait until clk_i'EVENT and clk_i = '1';
|
255 |
|
|
|
256 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_fifo_treshold/4 ,val_hss & val_hbs & val_bpp & val_fifo_treshold);
|
257 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_hse/4 ,val_vss & val_vbs & val_htotal & val_hse);
|
258 |
|
|
wr_chk_val(clk_i, adr_i,dat_o,dat_i,we_i,cyc_i,reg_stb_i,ack_o,reg_vse/4 ,val_sync_pol & val_pps & val_vtotal & val_vse);
|
259 |
|
|
end if;
|
260 |
5 |
tantos |
|
261 |
|
|
wait;
|
262 |
|
|
end process;
|
263 |
|
|
|
264 |
|
|
s_ram: process is
|
265 |
|
|
begin
|
266 |
|
|
wait on s_data,s_addr,s_oen,s_wrhn,s_wrln,s_cen;
|
267 |
|
|
if (s_cen = '0') then
|
268 |
|
|
if (s_oen = '0') then
|
269 |
6 |
tantos |
s_data <= s_addr(v_dat_width-1 downto 0);
|
270 |
5 |
tantos |
elsif (s_wrhn = '0' or s_wrln = '0') then
|
271 |
|
|
if (s_wrhn = '0') then
|
272 |
|
|
else
|
273 |
|
|
end if;
|
274 |
|
|
else
|
275 |
|
|
s_data <= (others => 'Z');
|
276 |
|
|
end if;
|
277 |
|
|
end if;
|
278 |
|
|
end process;
|
279 |
|
|
|
280 |
|
|
end TB;
|
281 |
|
|
|
282 |
|
|
configuration TB_vga_chip of vga_chip_tb is
|
283 |
|
|
for TB
|
284 |
|
|
for UUT : vga_chip
|
285 |
|
|
use entity wb_vga.vga_chip(vga_chip);
|
286 |
|
|
end for;
|
287 |
|
|
end for;
|
288 |
|
|
end TB_vga_chip;
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
--configuration SYNTH_vga_chip of vga_chip_tb is
|
292 |
|
|
-- for TB
|
293 |
|
|
-- for UUT : vga_chip
|
294 |
|
|
-- use entity work.vga_chip(ep1k30fc256_a1);
|
295 |
|
|
-- end for;
|
296 |
|
|
-- end for;
|
297 |
|
|
--end SYNTH_vga_chip;
|
298 |
|
|
--
|
299 |
|
|
--
|