OpenCores
URL https://opencores.org/ocsvn/graphicallcd/graphicallcd/trunk

Subversion Repositories graphicallcd

[/] [graphicallcd/] [trunk/] [graphical_lcd_tb.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 maihde
library IEEE;
2
use IEEE.std_logic_1164.all;
3
use IEEE.std_logic_arith.all;
4
use IEEE.std_logic_unsigned.all;
5
 
6
-------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
 
11
-------------------------------------------------------------------------------
12
 
13
entity graphical_lcd_tb is
14
 
15
end graphical_lcd_tb;
16
 
17
-------------------------------------------------------------------------------
18
architecture testbench of graphical_lcd_tb is
19
  component graphical_lcd
20
    port (
21
      E     : out   std_logic;
22
      R_W   : out   std_logic;
23
      CS1   : out   std_logic;
24
      CS2   : out   std_logic;
25
      D_I   : out   std_logic;
26
      DB    : inout std_logic_vector(7 downto 0);
27
      CLK_I : in    std_logic;
28
      RST_I : in    std_logic;
29
      DAT_I : in    std_logic_vector(7 downto 0);
30
      DAT_O : out   std_logic_vector;
31
      ACK_O : out   std_logic;
32
      STB_I : in    std_logic;
33
      WE_I  : in    std_logic;
34
      TGD_I : in    std_logic_vector(2 downto 0));
35
  end component;
36
 
37
  signal E_i     : std_logic;
38
  signal R_W_i   : std_logic;
39
  signal CS1_i   : std_logic;
40
  signal CS2_i   : std_logic;
41
  signal D_I_i   : std_logic;
42
  signal DB_i    : std_logic_vector(7 downto 0);
43
  signal CLK_I_i : std_logic;
44
  signal RST_I_i : std_logic;
45
  signal DAT_I_i : std_logic_vector(7 downto 0);
46
  signal DAT_O_i : std_logic_vector(7 downto 0);
47
  signal ACK_O_i : std_logic;
48
  signal STB_I_i : std_logic;
49
  signal WE_I_i  : std_logic;
50
  signal TGD_I_i : std_logic_vector(2 downto 0);
51
 
52
  constant clock_period : delay_length := 20 ns;
53
 
54
begin  -- testbench
55
 
56
  -- Unit under test
57
  UUT: graphical_lcd
58
    port map (
59
        E     => E_i,
60
        R_W   => R_W_i,
61
        CS1   => CS1_i,
62
        CS2   => CS2_i,
63
        D_I   => D_I_i,
64
        DB    => DB_i,
65
        CLK_I => CLK_I_i,
66
        RST_I => RST_I_i,
67
        DAT_I => DAT_I_i,
68
        DAT_O => DAT_O_i,
69
        ACK_O => ACK_O_i,
70
        STB_I => STB_I_i,
71
        WE_I  => WE_I_i,
72
        TGD_I => TGD_I_i);
73
 
74
  -- Simulate fake data reads
75
  DB_i <= "ZZZZZZZZ" when R_W_i = '0' else
76
          "00001111";
77
 
78
  -- Reset driver
79
  RST_I_i <= '1', '0' after 2.5 * clock_period;
80
 
81
  -- Generate the testbench clock
82
  clk_gen: process
83
  begin  -- process clk_gen
84
    CLK_I_i <= '0';
85
    wait for clock_period/2;
86
    loop
87
      CLK_I_i <= '1';
88
      wait for clock_period/2;
89
      CLK_I_i <= '0';
90
      wait for clock_period/2;
91
    end loop;  -- clock_period/2;
92
  end process clk_gen;
93
 
94
  stimulus: process
95
  begin  -- process stimulus
96
    wait until RST_I_i = '0';
97
 
98
    wait until CLK_I_i = '1';
99
    -- Turn the display on
100
    DAT_I_i <= "00111111";
101
    TGD_I_i <= "000";
102
    WE_I_i <= '1';
103
    wait until CLK_I_i = '1';
104
    STB_I_i <= '1';
105
    wait until ACK_O_i = '1';
106
    wait until CLK_I_i = '1';
107
    STB_I_i <= '0';
108
 
109
    -- Read until the busy is gone
110
    wait until CLK_I_i = '1';
111
    TGD_I_i <= "100";
112
    WE_I_i <= '0';
113
    wait until CLK_I_i = '1';
114
    STB_I_i <= '1';
115
    wait until ACK_O_i = '1';
116
    wait until CLK_I_i = '1';
117
    STB_I_i <= '0';
118
    -- Send some data
119
    wait until CLK_I_i = '1';
120
    DAT_I_i <= "10101100";
121
    TGD_I_i <= "011";
122
    WE_I_i <= '1';
123
    wait until CLK_I_i = '1';
124
    STB_I_i <= '1';
125
    wait until ACK_O_i = '1';
126
    wait until CLK_I_i = '1';
127
    STB_I_i <= '0';
128
    wait;
129
 
130
  end process stimulus;
131
 
132
end testbench;
133
 
134
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.