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

Subversion Repositories graphicallcd

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 maihde
-------------------------------------------------------------------------------
2
-- WISHBONE DATASHEET
3
-- WISHBONE SoC Architecture Specification, Revision B.3
4
--
5
-- General Description        : graphical LCD interface for KS0108b controllers
6
--
7
-- Supported Cycles           : SLAVE, READ/WRITE
8
--
9
-- Data Port Size             : 8-bit
10
-- Data Port Granularity      : 8-bit
11
-- Data Port Max Operand Size : 8-bit
12
-- Data Transfer Ordering     : Big endian and/or little endian
13
-- Data Transfer Sequence     : Undefined
14
--
15
-- Supported Signal List
16
-- Signal Name                WISHBONE Equiv
17
--  ACK_O                       ACK_O
18
--  CLK_I                       CLK_I
19
--  DAT_I(7 downto 0)           DAT_I()
20
--  DAT_O(7 downto 0)           DAT_O()
21
--  RST_I                       RST_I
22
--  STB_I                       STB_I
23
--  WE_I                        WE_I
24
--  D/I_F                       TGD(0)
25
--  CS1                         TGD(1)
26
--  CS2                         TGD(2)
27
-------------------------------------------------------------------------------
28
library IEEE;
29
use IEEE.std_logic_1164.all;
30
use IEEE.std_logic_arith.all;
31
use IEEE.std_logic_unsigned.all;
32
 
33
entity graphical_lcd is
34
  port (
35
    -- LCD interface
36
    E     : out   std_logic;                     -- enable signal
37
    R_W   : out   std_logic;                     -- Read High / Write Low
38
    CS1   : out   std_logic;                     -- CS1
39
    CS2   : out   std_logic;                     -- CS2
40
    D_I   : out   std_logic;                     -- data high / instruction low
41
    DB    : inout std_logic_vector(7 downto 0);  -- data byte
42
    -- Wishbone interface
43
    CLK_I : in    std_logic;                     -- The Sytem Clock
44
    RST_I : in    std_logic;                     -- Async. Reset
45
    DAT_I : in    std_logic_vector(7 downto 0);
46
    DAT_O : out   std_logic_vector(7 downto 0);
47
    ACK_O : out   std_logic;
48
    STB_I : in    std_logic;
49
    WE_I  : in    std_logic;
50
    TGD_I : in    std_logic_vector(2 downto 0));
51
end graphical_lcd;
52
 
53
-------------------------------------------------------------------------------
54
-- ARCHITECTURE
55
-------------------------------------------------------------------------------
56
architecture ks0108b of graphical_lcd is
57
  type state is (IDLE, WR_SETUP, WR_HOLD, RD_SETUP, RD_HOLD, ACK);
58
 
59
  signal DB_en : std_logic := '0';        -- enable the DB lines
60
  signal cur_state : state := idle;       -- current state
61
 
62
  signal data_in : std_logic_vector(7 downto 0) := "XXXXXXXX";
63
  signal data_out : std_logic_vector(7 downto 0) := "XXXXXXXX";
64
 
65
  signal e_cnt : std_logic_vector(7 downto 0);
66
  signal e_int : std_logic;
67
  signal e_en : std_logic;
68
begin  -- behavioral
69
 
70
  -----------------------------------------------------------------------------
71
  -- WISHBONE STUFF
72
  -----------------------------------------------------------------------------
73
  DAT_O <= data_out;
74
 
75
  ACK_O <= '1' when (cur_state = ACK) else
76
           '0';
77
 
78
  wishbone_dat_in: process (CLK_I, RST_I)
79
  begin  -- process wishbone_dat_in
80
    if RST_I = '1' then                 -- asynchronous reset
81
      data_in <= "00000000";
82
    elsif CLK_I'event and CLK_I = '1' then  -- rising clock edge
83
      if (STB_I = '1') and (WE_I = '1') then
84
        data_in <= DAT_I;
85
      end if;
86
    else
87
      data_in <= data_in;
88
    end if;
89
  end process wishbone_dat_in;
90
 
91
  -----------------------------------------------------------------------------
92
  -- LCD STUFF
93
  -----------------------------------------------------------------------------
94
 
95
  E <= e_int;
96
 
97
  D_I <= TGD_I(0);
98
 
99
  CS1 <= TGD_I(1);
100
 
101
  CS2 <= TGD_I(2);
102
 
103
  R_W <= '0' when (cur_state = WR_SETUP) or (cur_state = WR_HOLD) else
104
         '1' when (cur_state = RD_SETUP) or (cur_state = RD_HOLD) else
105
         '1';
106
 
107
  e_en <= '1' when (cur_state = WR_SETUP) or (cur_state = WR_HOLD) else
108
          '1' when (cur_state = RD_SETUP) or (cur_state = RD_HOLD) else
109
          '0';
110
 
111
  DB <= data_in when (cur_state = WR_SETUP) or (cur_state = WR_HOLD) else
112
        "ZZZZZZZZ";
113
 
114
  data_out <= DB when (e_int'event) and (e_int = '0') else
115
              data_out;
116
 
117
  -- purpose: creates the enable signal which is at least a 500ns period clock
118
  e_gen: process (CLK_I, RST_I, e_en)
119
  begin  -- process e_gen
120
    if (RST_I = '1') or (e_en = '0') then
121
      e_cnt <= "00000000";
122
      e_int <= '0';
123
    elsif CLK_I'event and CLK_I = '1' then
124
      e_cnt <= e_cnt + 1;
125
      if (e_cnt = X"19") then
126
        e_cnt <= "00000000";
127
        e_int <= not e_int;
128
      end if;
129
    end if;
130
  end process e_gen;
131
 
132
  state_machine: process (CLK_I, RST_I)
133
  begin  -- process state_machine
134
    if RST_I = '1' then
135
      cur_state <= idle;
136
    elsif CLK_I'event and CLK_I = '1' then
137
      case cur_state is
138
        when IDLE =>
139
          if (STB_I = '1') then
140
            if (WE_I = '1') then
141
              cur_state <= WR_SETUP;
142
            else
143
              cur_state <= RD_SETUP;
144
            end if;
145
          else
146
            cur_state <= IDLE;
147
          end if;
148
 
149
        when WR_SETUP =>
150
          if (e_int = '1') then
151
            cur_state <= WR_HOLD;
152
          else
153
            cur_state <= WR_SETUP;
154
          end if;
155
 
156
        when WR_HOLD =>
157
          if (e_int = '0') and (e_cnt = X"03") then
158
            cur_state <= ACK;
159
          else
160
            cur_state <= WR_HOLD;
161
          end if;
162
 
163
        when RD_SETUP =>
164
          if (e_int = '1') then
165
            cur_state <= RD_HOLD;
166
          else
167
            cur_state <= RD_SETUP;
168
          end if;
169
 
170
        when RD_HOLD =>
171
          if (e_int = '0') and (e_cnt = X"03") then
172
            cur_state <= ACK;
173
          else
174
            cur_state <= RD_HOLD;
175
          end if;
176
 
177
        when ACK =>
178
          if (STB_I = '0') then
179
            cur_state <= IDLE;
180
          end if;
181
 
182
        when others => null;
183
 
184
      end case;
185
    end if;
186
  end process state_machine;
187
 
188
end ks0108b;
189
 
190
 
191
 

powered by: WebSVN 2.1.0

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