77范文网 - 专业文章范例文档资料分享平台

基于FPGA的数字系统设计实验3控制液晶显示屏显示字符OK

来源:网络收集 时间:2019-03-27 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

Jian程序

library IEEE;

use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. --library UNISIM;

--use UNISIM.VComponents.all; entity lcd is port(

clk, reset : in bit;

SF_D : out bit_vector(3 downto 0);

LCD_E, LCD_RS, LCD_RW, SF_CE0 : out bit; LED : out bit_vector(7 downto 0) ); end lcd;

architecture behavior of lcd is

type tx_sequence is (high_setup, high_hold, oneus, low_setup, low_hold, fortyus, done); signal tx_state : tx_sequence := done; signal tx_byte : bit_vector(7 downto 0); signal tx_init : bit := '0';

type init_sequence is (idle, fifteenms, one, two, three, four, five, six, seven, eight, done); signal init_state : init_sequence := idle; signal init_init, init_done : bit := '0'; signal i : integer range 0 to 750000 := 0; signal i2 : integer range 0 to 2000 := 0; signal i3 : integer range 0 to 82000 := 0;

signal SF_D0, SF_D1 : bit_vector(3 downto 0); signal LCD_E0, LCD_E1 : bit; signal mux : bit;

type display_state is (init, function_set, entry_set, set_display, clr_display, pause, set_addr, char_f, char_p, char_g, char_a, done);

signal cur_state : display_state := init; begin

LED <= tx_byte; --for diagnostic purposes SF_CE0 <= '1'; --disable intel strataflash LCD_RW <= '0'; --write only

--The following \--when to transmit a command/data and when not to with cur_state select

tx_init <= '0' when init | pause | done, '1' when others;

--control the bus with cur_state select mux <= '1' when init, '0' when others;

--control the initialization sequence with cur_state select init_init <= '1' when init,

'0' when others;--register select with cur_state select

LCD_RS <= '0' when function_set|entry_set|set_display|clr_display|set_addr, '1' when others;

--what byte to transmit to lcd

--refer to datasheet for an explanation of these values with cur_state select

tx_byte <= \\\\\\\\\\--main state machine

display: process(clk, reset) begin

if(reset='1') then

cur_state <= function_set;

elsif(clk='1' and clk'event) then case cur_state is

--refer to intialize state machine below when init =>

if(init_done = '1') then cur_state <= function_set; else

cur_state <= init; end if;

--every other state but pause uses the transmit state machine when function_set => if(i2 = 2000) then

cur_state <= entry_set; else

cur_state <= function_set;

end if;

when entry_set => if(i2 = 2000) then

cur_state <= set_display; else

cur_state <= entry_set; end if;

when set_display => if(i2 = 2000) then

cur_state <= clr_display; else

cur_state <= set_display; end if;

when clr_display => i3 <= 0;

if(i2 = 2000) then cur_state <= pause; else

cur_state <= clr_display; end if;

when pause => if(i3 = 82000) then cur_state <= set_addr; i3 <= 0;else

cur_state <= pause; i3 <= i3 + 1; end if;

when set_addr => if(i2 = 2000) then cur_state <= char_J; else

cur_state <= set_addr; end if;

when char_J => if(i2 = 2000) then cur_state <= char_I; else

cur_state <= char_J; end if;

when char_I => if(i2 = 2000) then cur_state <= char_A; else

cur_state <= char_I;

end if;

when char_A=> if(i2 = 2000) then cur_state <= char_N; else

cur_state <= char_A; end if;

when char_N => if(i2 = 2000) then cur_state <= done; else

cur_state <= char_N; end if;

when done => cur_state <= done; end case; end if;

end process display; with mux select

SF_D <= SF_D0 when '0', --transmit SF_D1 when others; --initialize with mux select

LCD_E <= LCD_E0 when '0', --transmit LCD_E1 when others; --initialize --specified by datasheet

transmit : process(clk, reset, tx_init) begin

if(reset='1') then tx_state <= done;

elsif(clk='1' and clk'event) then case tx_state is

when high_setup => --40ns LCD_E0 <= '0';

SF_D0 <= tx_byte(7 downto 4); if(i2 = 2) then

tx_state <= high_hold; i2 <= 0; else

tx_state <= high_setup;i2 <= i2 + 1; end if;

when high_hold => --230ns LCD_E0 <= '1';

SF_D0 <= tx_byte(7 downto 4); if(i2 = 12) then

tx_state <= oneus; i2 <= 0; else

tx_state <= high_hold; i2 <= i2 + 1; end if;

when oneus => LCD_E0 <= '0'; if(i2 = 50) then

tx_state <= low_setup; i2 <= 0; else

tx_state <= oneus; i2 <= i2 + 1; end if;

when low_setup => LCD_E0 <= '0';

SF_D0 <= tx_byte(3 downto 0); if(i2 = 2) then

tx_state <= low_hold; i2 <= 0; else

tx_state <= low_setup; i2 <= i2 + 1; end if;

when low_hold => LCD_E0 <= '1';

SF_D0 <= tx_byte(3 downto 0); if(i2 = 12) then tx_state <= fortyus; i2 <= 0; else

tx_state <= low_hold; i2 <= i2 + 1; end if;

when fortyus => LCD_E0 <= '0'; if(i2 = 2000) then tx_state <= done; i2 <= 0; else

tx_state <= fortyus; i2 <= i2 + 1; end if;

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库基于FPGA的数字系统设计实验3控制液晶显示屏显示字符OK在线全文阅读。

基于FPGA的数字系统设计实验3控制液晶显示屏显示字符OK.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/546242.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: