aboutsummaryrefslogtreecommitdiff
path: root/src/dispdrv_tb.vhd
blob: 2c8d6f51855ae22f2a704d40a8ab8382e3474764 (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
library IEEE;
library UNISIM;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
use UNISIM.VCOMPONENTS.ALL;

entity dispdrv_tb is
end dispdrv_tb;

architecture Behavioral of dispdrv_tb is
component dispdrv port (
	CLK: in std_logic;
	D0: in std_logic_vector(7 downto 0);
	D1: in std_logic_vector(7 downto 0);
	D2: in std_logic_vector(7 downto 0);
	D3: in std_logic_vector(7 downto 0);
	D: out std_logic_vector(7 downto 0);
	S: out std_logic_vector(1 downto 0));
end component;
signal CLK: std_logic;
signal D0: std_logic_vector(7 downto 0);
signal D1: std_logic_vector(7 downto 0);
signal D2: std_logic_vector(7 downto 0);
signal D3: std_logic_vector(7 downto 0);
signal D: std_logic_vector(7 downto 0);
signal S: std_logic_vector(1 downto 0);

signal test_case: std_logic_vector(1 downto 0);
signal OK: boolean := true;
begin
	test: dispdrv port map(
		CLK => CLK,
		D0 => D0,
		D1 => D1,
		D2 => D2,
		D3 => D3,
		D => D,
		S => S);

	tb: process
		variable D0_t: std_logic_vector(7 downto 0) := b"00001111";
		variable D1_t: std_logic_vector(7 downto 0) := b"11110000";
		variable D2_t: std_logic_vector(7 downto 0) := b"01010101";
		variable D3_t: std_logic_vector(7 downto 0) := b"10101010";
	begin

	D0 <= D0_t;
	D1 <= D1_t;
	D2 <= D2_t;
	D3 <= D3_t;

	for test_i in 0 to 3 loop
		test_case <= std_logic_vector(to_unsigned(test_i, 2));
		CLK <= '0';
		wait for 5 ns;
		CLK <= '1';
		wait for 5 ns;

		if test_case = 0 and D /= D0_t then
			OK <= false;
		end if;
		if test_case = 1 and D /= D1_t then
			OK <= false;
		end if;
		if test_case = 2 and D /= D2_t then
			OK <= false;
		end if;
		if test_case = 3 and D /= D3_t then
			OK <= false;
		end if;
	end loop;
	wait;
	end process;
end Behavioral;