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

Subversion Repositories wb_lcd

[/] [wb_lcd/] [trunk/] [myhdl/] [wb_lcd_workspace_ramless/] [workspace/] [lcd_display/] [src/] [wb_lcd.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jvillar
-- File: wb_lcd.vhd
2
-- Generated by MyHDL 0.6
3
-- Date: Mon Apr 20 03:13:35 2009
4
 
5
 
6
package pck_wb_lcd is
7
 
8
    type t_enum_t_TxState_2 is (
9
    tx_high_setup,
10
    tx_high_hold,
11
    tx_oneus,
12
    tx_low_setup,
13
    tx_low_hold,
14
    tx_fortyus,
15
    tx_done
16
);
17
    type t_enum_t_State_1 is (
18
    display_init,
19
    init_fifteenms,
20
    init_one,
21
    init_two,
22
    init_three,
23
    init_four,
24
    init_five,
25
    init_six,
26
    init_seven,
27
    init_eight,
28
    display_function_set,
29
    display_entry_set,
30
    display_set_display,
31
    display_clr_display,
32
    display_pause_setup,
33
    display_pause,
34
    display_done,
35
    display_set_addr,
36
    display_char_write
37
);
38
 
39
end package pck_wb_lcd;
40
 
41
library IEEE;
42
use IEEE.std_logic_1164.all;
43
use IEEE.numeric_std.all;
44
use std.textio.all;
45
 
46
use work.pck_myhdl_06.all;
47
 
48
use work.pck_wb_lcd.all;
49
 
50
entity wb_lcd is
51
    port (
52
        wb_clk_i: in std_logic;
53
        wb_rst_i: in std_logic;
54
        wb_dat_i: in unsigned(31 downto 0);
55
        wb_dat_o: out unsigned(31 downto 0);
56
        wb_adr_i: in unsigned(31 downto 0);
57
        wb_sel_i: in unsigned(3 downto 0);
58
        wb_we_i: in std_logic;
59
        wb_cyc_i: in std_logic;
60
        wb_stb_i: in std_logic;
61
        wb_ack_o: out std_logic;
62
        SF_D: out unsigned(3 downto 0);
63
        LCD_E: out std_logic;
64
        LCD_RS: out std_logic;
65
        LCD_RW: out std_logic
66
    );
67
end entity wb_lcd;
68
 
69
architecture MyHDL of wb_lcd is
70
 
71
signal busy: std_logic;
72
signal lcd_we: std_logic;
73
signal mylcd_tx_init: std_logic;
74
signal mylcd_delay_load: std_logic;
75
signal mylcd_tx_done: std_logic;
76
signal mylcd_SF_D1: unsigned(3 downto 0);
77
signal mylcd_SF_D0: unsigned(3 downto 0);
78
signal mylcd_LCD_E1: std_logic;
79
signal mylcd_LCD_E0: std_logic;
80
signal mylcd_delay_done: std_logic;
81
signal mylcd_tx_byte: unsigned(7 downto 0);
82
signal mylcd_wr_addr: unsigned(6 downto 0);
83
signal mylcd_output_selector: std_logic;
84
signal mylcd_state: t_enum_t_State_1;
85
signal mylcd_tx_delay_value: unsigned(19 downto 0);
86
signal mylcd_main_delay_value: unsigned(19 downto 0);
87
signal mylcd_tx_delay_load: std_logic;
88
signal mylcd_delay_value: unsigned(19 downto 0);
89
signal mylcd_wr_dat: unsigned(6 downto 0);
90
signal mylcd_main_delay_load: std_logic;
91
signal mylcd_tx_state: t_enum_t_TxState_2;
92
signal mylcd_counter_counter: unsigned(20 downto 0);
93
 
94
begin
95
 
96
 
97
WB_LCD_WISHBONE_LOGIC: process (busy, wb_we_i, wb_stb_i, wb_cyc_i, wb_adr_i) is
98
begin
99
    wb_ack_o <= (wb_cyc_i and wb_stb_i);
100
 
101
    lcd_we <= (wb_cyc_i and wb_stb_i and wb_we_i and to_std_logic(wb_adr_i /= 128));
102
    if to_boolean(busy) then
103
        wb_dat_o <= "00000000000000000000000000000001";
104
    else
105
        wb_dat_o <= "00000000000000000000000000000000";
106
    end if;
107
end process WB_LCD_WISHBONE_LOGIC;
108
 
109
 
110
mylcd_output_selector <= ((mylcd_state = display_init) or (mylcd_state = init_fifteenms) or (mylcd_state = init_one) or (mylcd_state = init_two) or (mylcd_state = init_three) or (mylcd_state = init_four) or (mylcd_state = init_five) or (mylcd_state = init_six) or (mylcd_state = init_seven) or (mylcd_state = init_eight));
111
 
112
WB_LCD_MYLCD_CONUNTER_SHARING_VALUE: process (mylcd_main_delay_value, mylcd_tx_delay_load, mylcd_tx_delay_value) is
113
begin
114
    if to_boolean(mylcd_tx_delay_load) then
115
        mylcd_delay_value <= mylcd_tx_delay_value;
116
    else
117
        mylcd_delay_value <= mylcd_main_delay_value;
118
    end if;
119
end process WB_LCD_MYLCD_CONUNTER_SHARING_VALUE;
120
 
121
WB_LCD_MYLCD_DISPLAYFSM: process (wb_clk_i, wb_rst_i) is
122
begin
123
    if (wb_rst_i = '1') then
124
        mylcd_state <= display_init;
125
        mylcd_main_delay_load <= '0';
126
        mylcd_main_delay_value <= "00000000000000000000";
127
        mylcd_SF_D1 <= "0000";
128
        mylcd_LCD_E1 <= '0';
129
        mylcd_tx_byte <= "00000000";
130
    elsif rising_edge(wb_clk_i) then
131
        mylcd_main_delay_load <= '0';
132
 
133
        mylcd_main_delay_value <= "00000000000000000000";
134
 
135
        case mylcd_state is
136
            when display_init =>
137
                mylcd_tx_byte <= "00000000";
138
                mylcd_state <= init_fifteenms;
139
                mylcd_main_delay_load <= '1';
140
                mylcd_main_delay_value <= "10110111000110110000";
141
            when init_fifteenms =>
142
                mylcd_main_delay_load <= '0';
143
                if to_boolean(mylcd_delay_done) then
144
                    mylcd_state <= init_one;
145
 
146
                    mylcd_main_delay_load <= '1';
147
                    mylcd_main_delay_value <= "00000000000000001011";
148
                end if;
149
            when init_one =>
150
                mylcd_main_delay_load <= '0';
151
                mylcd_SF_D1 <= "0011";
152
                mylcd_LCD_E1 <= '1';
153
                if to_boolean(mylcd_delay_done) then
154
                    mylcd_state <= init_two;
155
 
156
                    mylcd_main_delay_load <= '1';
157
                    mylcd_main_delay_value <= "00110010000011001000";
158
                end if;
159
            when init_two =>
160
                mylcd_main_delay_load <= '0';
161
                mylcd_LCD_E1 <= '0';
162
                if to_boolean(mylcd_delay_done) then
163
                    mylcd_state <= init_three;
164
 
165
                    mylcd_main_delay_load <= '1';
166
                    mylcd_main_delay_value <= "00000000000000001011";
167
                end if;
168
            when init_three =>
169
                mylcd_main_delay_load <= '0';
170
                mylcd_SF_D1 <= "0011";
171
                mylcd_LCD_E1 <= '1';
172
                if to_boolean(mylcd_delay_done) then
173
                    mylcd_state <= init_four;
174
 
175
                    mylcd_main_delay_load <= '1';
176
                    mylcd_main_delay_value <= "00000001001110001000";
177
                end if;
178
            when init_four =>
179
                mylcd_main_delay_load <= '0';
180
                mylcd_LCD_E1 <= '0';
181
                if to_boolean(mylcd_delay_done) then
182
                    mylcd_state <= init_five;
183
 
184
                    mylcd_main_delay_load <= '1';
185
                    mylcd_main_delay_value <= "00000000000000001011";
186
                end if;
187
            when init_five =>
188
                mylcd_main_delay_load <= '0';
189
                mylcd_SF_D1 <= "0011";
190
                mylcd_LCD_E1 <= '1';
191
                if to_boolean(mylcd_delay_done) then
192
                    mylcd_state <= init_six;
193
 
194
                    mylcd_main_delay_load <= '1';
195
                    mylcd_main_delay_value <= "00000000011111010000";
196
                end if;
197
            when init_six =>
198
                mylcd_main_delay_load <= '0';
199
                mylcd_LCD_E1 <= '0';
200
                if to_boolean(mylcd_delay_done) then
201
                    mylcd_state <= init_seven;
202
 
203
                    mylcd_main_delay_load <= '1';
204
                    mylcd_main_delay_value <= "00000000000000001011";
205
                end if;
206
            when init_seven =>
207
                mylcd_main_delay_load <= '0';
208
                mylcd_SF_D1 <= "0010";
209
                mylcd_LCD_E1 <= '1';
210
                if to_boolean(mylcd_delay_done) then
211
                    mylcd_state <= init_eight;
212
 
213
                    mylcd_main_delay_load <= '1';
214
                    mylcd_main_delay_value <= "00000000011111010000";
215
                end if;
216
            when init_eight =>
217
                mylcd_main_delay_load <= '0';
218
                mylcd_LCD_E1 <= '0';
219
                if to_boolean(mylcd_delay_done) then
220
                    mylcd_state <= display_function_set;
221
 
222
                end if;
223
            when display_function_set =>
224
                mylcd_tx_byte <= "00101000";
225
                if to_boolean(mylcd_tx_done) then
226
                    mylcd_state <= display_entry_set;
227
                end if;
228
            when display_entry_set =>
229
                mylcd_tx_byte <= "00000110";
230
                if to_boolean(mylcd_tx_done) then
231
                    mylcd_state <= display_set_display;
232
                end if;
233
            when display_set_display =>
234
                mylcd_tx_byte <= "00001100";
235
                if to_boolean(mylcd_tx_done) then
236
                    mylcd_state <= display_clr_display;
237
                end if;
238
            when display_clr_display =>
239
                mylcd_tx_byte <= "00000001";
240
                if to_boolean(mylcd_tx_done) then
241
                    mylcd_state <= display_pause;
242
                    mylcd_main_delay_load <= '1';
243
                    mylcd_main_delay_value <= "00010100000001010000";
244
                end if;
245
            when display_pause_setup =>
246
                mylcd_state <= display_pause;
247
            when display_pause =>
248
                mylcd_tx_byte <= "00000000";
249
                if to_boolean(mylcd_delay_done) then
250
                    mylcd_state <= display_done;
251
 
252
                end if;
253
            when display_done =>
254
                mylcd_tx_byte <= "00000000";
255
                if to_boolean(lcd_we) then
256
                    mylcd_state <= display_set_addr;
257
                    mylcd_wr_addr <= resize(wb_adr_i, 7);
258
                    mylcd_wr_dat <= resize(wb_dat_i, 7);
259
                else
260
                    mylcd_state <= display_done;
261
                end if;
262
            when display_set_addr =>
263
                mylcd_tx_byte <= ("10000000" or mylcd_wr_addr);
264
                if to_boolean(mylcd_tx_done) then
265
                    mylcd_state <= display_char_write;
266
                end if;
267
            when display_char_write =>
268
                mylcd_tx_byte <= resize(mylcd_wr_dat, 8);
269
                if to_boolean(mylcd_tx_done) then
270
                    mylcd_state <= display_done;
271
 
272
                end if;
273
        end case;
274
    end if;
275
end process WB_LCD_MYLCD_DISPLAYFSM;
276
 
277
WB_LCD_MYLCD_TXFSM: process (wb_clk_i, wb_rst_i) is
278
begin
279
    if (wb_rst_i = '1') then
280
        mylcd_tx_state <= tx_done;
281
        mylcd_SF_D0 <= "0000";
282
        mylcd_LCD_E0 <= '0';
283
    elsif rising_edge(wb_clk_i) then
284
        mylcd_tx_delay_load <= '0';
285
 
286
        mylcd_tx_delay_value <= "00000000000000000000";
287
 
288
        case mylcd_tx_state is
289
            when tx_high_setup =>
290
                mylcd_LCD_E0 <= '0';
291
                mylcd_SF_D0 <= mylcd_tx_byte(8-1 downto 4);
292
                mylcd_tx_delay_load <= '0';
293
                if to_boolean(mylcd_delay_done) then
294
                    mylcd_tx_state <= tx_high_hold;
295
                    mylcd_tx_delay_load <= '1';
296
                    mylcd_tx_delay_value <= "00000000000000001100";
297
                end if;
298
            when tx_high_hold =>
299
                mylcd_LCD_E0 <= '1';
300
                mylcd_SF_D0 <= mylcd_tx_byte(8-1 downto 4);
301
                mylcd_tx_delay_load <= '0';
302
                if to_boolean(mylcd_delay_done) then
303
                    mylcd_tx_state <= tx_oneus;
304
                    mylcd_tx_delay_load <= '1';
305
                    mylcd_tx_delay_value <= "00000000000000110010";
306
                end if;
307
            when tx_oneus =>
308
                mylcd_LCD_E0 <= '0';
309
                mylcd_tx_delay_load <= '0';
310
                if to_boolean(mylcd_delay_done) then
311
                    mylcd_tx_state <= tx_low_setup;
312
                    mylcd_tx_delay_load <= '1';
313
                    mylcd_tx_delay_value <= "00000000000000000010";
314
                end if;
315
            when tx_low_setup =>
316
                mylcd_LCD_E0 <= '0';
317
                mylcd_SF_D0 <= mylcd_tx_byte(4-1 downto 0);
318
                mylcd_tx_delay_load <= '0';
319
                if to_boolean(mylcd_delay_done) then
320
                    mylcd_tx_state <= tx_low_hold;
321
                    mylcd_tx_delay_load <= '1';
322
                    mylcd_tx_delay_value <= "00000000000000001100";
323
                end if;
324
            when tx_low_hold =>
325
                mylcd_LCD_E0 <= '1';
326
                mylcd_SF_D0 <= mylcd_tx_byte(4-1 downto 0);
327
                mylcd_tx_delay_load <= '0';
328
                if to_boolean(mylcd_delay_done) then
329
                    mylcd_tx_state <= tx_fortyus;
330
                    mylcd_tx_delay_load <= '1';
331
                    mylcd_tx_delay_value <= "00000000011111010000";
332
                end if;
333
            when tx_fortyus =>
334
                mylcd_LCD_E0 <= '0';
335
                mylcd_tx_delay_load <= '0';
336
                if to_boolean(mylcd_delay_done) then
337
                    mylcd_tx_state <= tx_done;
338
                    mylcd_tx_done <= '1';
339
                end if;
340
            when tx_done =>
341
                mylcd_LCD_E0 <= '0';
342
                mylcd_tx_done <= '0';
343
                mylcd_tx_delay_load <= '0';
344
                if to_boolean(mylcd_tx_init) then
345
                    mylcd_tx_state <= tx_high_setup;
346
                    mylcd_tx_delay_load <= '1';
347
                    mylcd_tx_delay_value <= "00000000000000000010";
348
                end if;
349
        end case;
350
    end if;
351
end process WB_LCD_MYLCD_TXFSM;
352
 
353
 
354
mylcd_delay_load <= to_std_logic(to_boolean(mylcd_tx_delay_load) or to_boolean(mylcd_main_delay_load));
355
 
356
 
357
busy <= to_std_logic(mylcd_state /= display_done);
358
LCD_RW <= '0';
359
 
360
WB_LCD_MYLCD_OUTPUT_TX_OR_INIT_MUX: process (mylcd_SF_D1, mylcd_SF_D0, mylcd_LCD_E1, mylcd_LCD_E0, mylcd_output_selector) is
361
begin
362
    if to_boolean(mylcd_output_selector) then
363
        SF_D <= mylcd_SF_D1;
364
        LCD_E <= mylcd_LCD_E1;
365
    else
366
        SF_D <= mylcd_SF_D0;
367
        LCD_E <= mylcd_LCD_E0;
368
    end if;
369
end process WB_LCD_MYLCD_OUTPUT_TX_OR_INIT_MUX;
370
 
371
 
372
mylcd_tx_init <= ((not mylcd_tx_done) and ((mylcd_state = display_function_set) or (mylcd_state = display_entry_set) or (mylcd_state = display_set_display) or (mylcd_state = display_clr_display) or (mylcd_state = display_set_addr) or (mylcd_state = display_char_write)));
373
LCD_RS <= (not ((mylcd_state = display_function_set) or (mylcd_state = display_entry_set) or (mylcd_state = display_set_display) or (mylcd_state = display_clr_display) or (mylcd_state = display_set_addr)));
374
 
375
 
376
mylcd_delay_done <= to_std_logic(mylcd_counter_counter = 0);
377
 
378
WB_LCD_MYLCD_COUNTER_COUNTDOWN_LOGIC: process (wb_clk_i) is
379
begin
380
    if rising_edge(wb_clk_i) then
381
        if to_boolean(mylcd_delay_load) then
382
            mylcd_counter_counter <= resize(mylcd_delay_value, 21);
383
        else
384
            mylcd_counter_counter <= (mylcd_counter_counter - 1);
385
        end if;
386
    end if;
387
end process WB_LCD_MYLCD_COUNTER_COUNTDOWN_LOGIC;
388
 
389
end architecture MyHDL;

powered by: WebSVN 2.1.0

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