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

Subversion Repositories hd44780_driver

[/] [hd44780_driver/] [trunk/] [tb_example_driver.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jodb
-- Filename:     tb_example_driver.vhd
2
-- Filetype:     VHDL Testbench
3
-- Date:         26 oct 2012
4
-- Update:       -
5
-- Description:  VHDL testbench for example driver
6
-- Author:       J. op den Brouw
7
-- State:        Demo
8
-- Error:        -
9
-- Version:      1.0alpha
10
-- Copyright:    (c)2012, De Haagse Hogeschool
11
 
12
-- This file contains a very simple VHDL testbench for a User Side
13
-- driver for the LCD driver.
14
-- 
15
 
16
-- Libraries et al.
17
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.numeric_std.all;
20
 
21
-- The entity of a testbench for the example driver
22
entity tb_example_driver is
23
end entity tb_example_driver;
24
 
25
-- The architecture!
26
architecture sim of tb_example_driver is
27
-- Component declaration of the example driver
28
component example_driver is
29
        port (CLOCK_50 : in std_logic;
30
                        BUTTON   : in std_logic_vector(2 downto 0);
31
                        SW       : in std_logic_vector(9 downto 0);
32
                        LEDG     : out std_logic_vector(9 downto 0);
33
                        HEX3_D   : out std_logic_vector(6 downto 0);
34
                        HEX2_D   : out std_logic_vector(6 downto 0);
35
                        HEX1_D   : out std_logic_vector(6 downto 0);
36
                        HEX0_D   : out std_logic_vector(6 downto 0);
37
                        HEX0_DP  : out std_logic;
38
                        HEX1_DP  : out std_logic;
39
                        HEX2_DP  : out std_logic;
40
                        HEX3_DP  : out std_logic;
41
                        -- LCD of the DE0 board
42
                        LCD_EN   : out std_logic;
43
                        LCD_RS   : out std_logic;
44
                        LCD_RW   : out std_logic;
45
                        LCD_DATA : inout std_logic_vector(7 downto 0);
46
                        LCD_BLON : out std_logic
47
        );
48
end component example_driver;
49
 
50
signal CLOCK_50 : std_logic;
51
signal BUTTON   : std_logic_vector(2 downto 0);
52
signal SW       : std_logic_vector(9 downto 0);
53
signal LEDG     : std_logic_vector(9 downto 0);
54
signal HEX3_D   : std_logic_vector(6 downto 0);
55
signal HEX2_D   : std_logic_vector(6 downto 0);
56
signal HEX1_D   : std_logic_vector(6 downto 0);
57
signal HEX0_D   : std_logic_vector(6 downto 0);
58
signal HEX0_DP  : std_logic;
59
signal HEX1_DP  : std_logic;
60
signal HEX2_DP  : std_logic;
61
signal HEX3_DP  : std_logic;
62
-- LCD of the DE0 board
63
signal LCD_EN   : std_logic;
64
signal LCD_RS   : std_logic;
65
signal LCD_RW   : std_logic;
66
signal LCD_DATA : std_logic_vector(7 downto 0);
67
signal LCD_BLON : std_logic;
68
 
69
--constant freq_in : integer := 10000; -- 10 kHz
70
constant freq_in : integer := 50000000; -- 50 MHz
71
constant clock_period : time := (1.0/real(freq_in)) * (1 sec);
72
 
73
-- Internal tracer
74
signal trace : integer;
75
 
76
begin
77
 
78
        -- The driver's driver...
79
        de0: example_driver
80
        port map (CLOCK_50 => CLOCK_50, BUTTON => BUTTON, SW => SW, LEDG => LEDG,
81
                  HEX3_D => HEX3_D, HEX2_D => HEX2_D, HEX1_D => HEX1_D, HEX0_D => HEX0_D,
82
                                 HEX0_DP => HEX0_DP, HEX1_DP => HEX1_DP, HEX2_DP => HEX2_DP, HEX3_DP => HEX3_DP,
83
                                 LCD_EN => LCD_EN, LCD_RS => LCD_RS, LCD_RW => LCD_RW, LCD_DATA => LCD_DATA,
84
                                 LCD_BLON => LCD_BLON);
85
 
86
        -- The clock signal generation process
87
        clockgen: process is
88
        begin
89
                -- give time for reset, buttons active low!
90
                CLOCK_50 <= '0';
91
                BUTTON <= "110";
92
                wait for 15 ns;
93
                BUTTON <= "111";
94
                wait for 5 ns;
95
                -- forever: generate clock cycle for 20 ns and 50% d.c.
96
                loop
97
                        CLOCK_50 <= '1';
98
                        wait for clock_period/2;
99
                        CLOCK_50 <= '0';
100
                        wait for clock_period/2;
101
                end loop;
102
        end process;
103
 
104
        -- Simple simulation description of the LCD itself...
105
        -- (probably too simple)
106
        lcd_module_sim: process is
107
        begin
108
                trace <= 0;
109
                LCD_DATA <= (others => 'Z');
110
                -- Wait for reset clear
111
                wait until BUTTON(0) = '0';
112
                trace <= 1;
113
                -- Three writes to the LCD, no busy flag testing possible
114
                wait until LCD_EN = '1';
115
                wait until LCD_EN = '1';
116
                wait until LCD_EN = '1';
117
                trace <= 2;
118
 
119
                loop
120
                        -- command/data written to
121
                        trace <= 3;
122
                        wait until LCD_EN = '1';
123
                        trace <= 4;
124
                        wait until LCD_EN = '0';
125
 
126
                        -- busy flag reading
127
                        trace <= 5;
128
                        wait until LCD_EN = '1';
129
                        trace <= 6;
130
                        if LCD_RW = '1' then
131
                                trace <= 61;
132
                                -- Signal LCD is busy
133
                                LCD_DATA <= "1ZZZZZZZ";
134
                                -- Internal delay of the LCD for some commands
135
                                wait for 40 us;
136
                                -- Signal LCD is ready
137
                                LCD_DATA <= "0ZZZZZZZ";
138
                        end if;
139
                        wait until LCD_EN = '0';
140
                        trace <= 7;
141
                        if LCD_RW = '1' then
142
                                trace <= 1;
143
                                LCD_DATA <= "ZZZZZZZZ";
144
                        end if;
145
 
146
                end loop;
147
                wait;
148
        end process;
149
 
150
end architecture sim;

powered by: WebSVN 2.1.0

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