OpenCores
URL https://opencores.org/ocsvn/16x2_lcd_controller/16x2_lcd_controller/trunk

Subversion Repositories 16x2_lcd_controller

[/] [16x2_lcd_controller/] [trunk/] [demo/] [lcd16x2_ctrl_demo.vhd] - Blame information for rev 4

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

Line No. Rev Author Line
1 4 stachelsau
-------------------------------------------------------------------------------
2
-- Title      : Synthesizable demo for design "lcd16x2_ctrl"
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : lcd16x2_ctrl_tb.vhd
6
-- Author     :   <stachelsau@T420>
7
-- Company    : 
8
-- Created    : 2012-07-28
9
-- Last update: 2012-07-29
10
-- Platform   : 
11
-- Standard   : VHDL'93/02
12
-------------------------------------------------------------------------------
13
-- Description: This demo writes writes a "hello world" to the display and
14
-- interchanges both lines periodically.
15
-------------------------------------------------------------------------------
16
-- Copyright (c) 2012 
17
-------------------------------------------------------------------------------
18
-- Revisions  :
19
-- Date        Version  Author  Description
20
-- 2012-07-28  1.0      stachelsau      Created
21
-------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
 
26
-------------------------------------------------------------------------------
27
 
28
entity lcd16x2_ctrl_demo is
29
  port (
30
    clk    : in  std_logic;
31
    lcd_e  : out std_logic;
32
    lcd_rs : out std_logic;
33
    lcd_rw : out std_logic;
34
    lcd_db : out std_logic_vector(7 downto 4));
35
 
36
end entity lcd16x2_ctrl_demo;
37
 
38
-------------------------------------------------------------------------------
39
 
40
architecture behavior of lcd16x2_ctrl_demo is
41
 
42
  -- 
43
  signal timer : natural range 0 to 100000000 := 0;
44
  signal switch_lines : std_logic := '0';
45
  signal line1 : std_logic_vector(127 downto 0);
46
  signal line2 : std_logic_vector(127 downto 0);
47
 
48
 
49
  -- component generics
50
  constant CLK_PERIOD_NS : positive := 10;  -- 100 Mhz
51
 
52
  -- component ports
53
  signal rst          : std_logic;
54
  signal line1_buffer : std_logic_vector(127 downto 0);
55
  signal line2_buffer : std_logic_vector(127 downto 0);
56
 
57
begin  -- architecture behavior
58
 
59
  -- component instantiation
60
  DUT : entity work.lcd16x2_ctrl
61
    generic map (
62
      CLK_PERIOD_NS => CLK_PERIOD_NS)
63
    port map (
64
      clk          => clk,
65
      rst          => rst,
66
      lcd_e        => lcd_e,
67
      lcd_rs       => lcd_rs,
68
      lcd_rw       => lcd_rw,
69
      lcd_db       => lcd_db,
70
      line1_buffer => line1_buffer,
71
      line2_buffer => line2_buffer);
72
 
73
  rst <= '0';
74
 
75
  line1(127 downto 120) <= X"20";
76
  line1(119 downto 112) <= X"20";
77
  line1(111 downto 104) <= X"48";  -- H
78
  line1(103 downto 96)  <= X"65";  -- e
79
  line1(95 downto 88)   <= X"6c";  -- l
80
  line1(87 downto 80)   <= X"6c";  -- l
81
  line1(79 downto 72)   <= X"6f";  -- o
82
  line1(71 downto 64)   <= X"20";
83
  line1(63 downto 56)   <= X"57";  -- W
84
  line1(55 downto 48)   <= X"6f";  -- o
85
  line1(47 downto 40)   <= X"72";  -- r
86
  line1(39 downto 32)   <= X"6c";  -- l
87
  line1(31 downto 24)   <= X"64";  -- d
88
  line1(23 downto 16)   <= X"21";  -- !
89
  line1(15 downto 8)    <= X"20";
90
  line1(7 downto 0)     <= X"20";
91
 
92
  line2(127 downto 120) <= X"30";
93
  line2(119 downto 112) <= X"31";
94
  line2(111 downto 104) <= X"32";
95
  line2(103 downto 96)  <= X"33";
96
  line2(95 downto 88)   <= X"34";
97
  line2(87 downto 80)   <= X"35";
98
  line2(79 downto 72)   <= X"36";
99
  line2(71 downto 64)   <= X"37";
100
  line2(63 downto 56)   <= X"38";
101
  line2(55 downto 48)   <= X"39";
102
  line2(47 downto 40)   <= X"3a";
103
  line2(39 downto 32)   <= X"3b";
104
  line2(31 downto 24)   <= X"3c";
105
  line2(23 downto 16)   <= X"3d";
106
  line2(15 downto 8)    <= X"3e";
107
  line2(7 downto 0)     <= X"3f";
108
 
109
  line1_buffer <= line2 when switch_lines = '1' else line1;
110
  line2_buffer <= line1 when switch_lines = '1' else line2;
111
 
112
  -- switch lines every second
113
  process(clk)
114
  begin
115
    if rising_edge(clk) then
116
      if timer = 0 then
117
        timer <= 100000000;
118
        switch_lines <= not switch_lines;
119
      else
120
        timer <= timer - 1;
121
      end if;
122
    end if;
123
 
124
  end process;
125
end architecture behavior;
126
 
127
 

powered by: WebSVN 2.1.0

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