版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Good is good, but better carries it.精益求精,善益求善。LCD計(jì)數(shù)顯示程序-libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;-Uncommentthefollowinglibrarydeclarationifinstantiating-anyXilinxprimitivesinthiscode.-libraryUNISIM;-useUNISIM.VComponents.all;entitycounterisPor
2、t(clk:instd_logic;resetn:instd_logic;dout:outstd_logic_vector(7downto0);lcd_en:outstd_logic;lcd_rs:outstd_logic;lcd_rw:outstd_logic);endcounter;architectureBehavioralofcounteriscomponentcounter60isPort(clk:instd_logic;resetn:instd_logic;dout:outstd_logic_vector(7downto0);endcomponent;componentdecode
3、risPort(din:instd_logic_vector(3downto0);dout:outstd_logic_vector(8downto0);endcomponent;componentlcd_interfaceisport(clk:instd_logic;resetn:instd_logic;dout_s10:instd_logic_vector(8downto0);dout_s1:instd_logic_vector(8downto0);lcd_data:outstd_logic_vector(7downto0);lcd_en:outstd_logic;lcd_rs:outstd
4、_logic;lcd_rw:outstd_logic);endcomponent;signalddout_s10:std_logic_vector(8downto0);signalddout_s1:std_logic_vector(8downto0);signalddout:std_logic_vector(7downto0);beginu1:counter60portmap(clk,resetn,ddout);u2:decoderportmap(ddout(7downto4),ddout_s10);u3:decoderportmap(ddout(3downto0),ddout_s1);u4:
5、lcd_interfaceportmap(clk,resetn,ddout_s10,ddout_s1,dout,lcd_en,lcd_rs,lcd_rw);endBehavioral;-Company:-Engineer:-CreateDate:13:36:1003/30/06-DesignName:-ModuleName:count60-Behavioral-ProjectName:-TargetDevice:-Toolversions:-Description:-Dependencies:-Revision:-Revision0.01-FileCreated-AdditionalComme
6、nts:-libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;entitycounter60isPort(clk:instd_logic;resetn:instd_logic;dout:outstd_logic_vector(7downto0);endcounter60;architectureBehavioralofcounter60issignalcount:std_logic_vector(7downto0);signalcount_div:st
7、d_logic_vector(25downto0);begindout=count;process(clk)beginif(clkeventandclk=1)thenif(resetn=0)thencount_div0);elseif(count_div(25)=1)thencount_div0);elsecount_div=count_div+1;endif;endif;endif;endprocess;process(clk,resetn)beginifresetn=0thencount0);elsifrising_edge(clk)thenif(count_div(25)=1)theni
8、fcount(3downto0)=1001thencount(3downto0)=0000;count(7downto4)=count(7downto4)+1;elsecount(3downto0)=count(3downto0)+1;endif;ifcount=01011001thencountdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=100100000;endcase;endprocess;endBehavioral;libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.
9、all;useieee.std_logic_unsigned.all;entitylcd_interfaceisport(clk:instd_logic;resetn:instd_logic;dout_s10:instd_logic_vector(8downto0);dout_s1:instd_logic_vector(8downto0);lcd_data:outstd_logic_vector(7downto0);lcd_en:outstd_logic;lcd_rs:outstd_logic;lcd_rw:outstd_logic);endlcd_interface;architecture
10、lcd_interface_archoflcd_interfaceissignallcd_we_n:std_logic;signallcd_en_int:std_logic;signalw_comp_n:std_logic;signalseq_count:std_logic_vector(5downto0);signallcd_rs_data:std_logic_vector(8downto0);signaldelay_count:std_logic_vector(15downto0);signallcd_addr:std_logic_vector(5downto0);typestate_lc
11、d_write_typeis(lcd_write_idle,lcd_write_1,lcd_write_2,lcd_write_3,lcd_write_4);signalstate_lcd_write:state_lcd_write_type;typestate_typeis(idle,wait_1,wait_2,state_1,state_2,state_3,done);signalstate:state_type;begin-ThefollowingstatemachineinitializestheLCDandwritesthefollowingmessage-totheLCDpanel
12、-MemecDesign-MB1000Board-TheLCDinitializationsequenceconsistofwritingthe0 x38,0 x38,0 x06,0 x0e,-0 x01,0 x80,0 xc0sequenceofhexnumberstotheLCDcontrolregisters(please-refertotheLCDdatasheetforanexplanationoftheinitializationsequence).-AttheendoftheLCDinitializationsequence,theLCDisreadytobewritten-to
13、startingwithline1.Itshouldbenotedthatdelaysareinsertedbetween-2writestotheLCDpaneltomeettheLCDinitializationrequirements.Although,-theLCDpanelrequiresdifferentdelaysbetween2writes,afixdelayof20msis-insertedbetween2writestosimplytheinitializationdesign(the20msisthe-longestdelaythatisrequiredbytheLCDp
14、anel).A22-bitcounterisusedto-generatethisfixdelay.sequencer_state_register:process(clk,resetn)beginif(resetn=0)thenstateif(delay_count(15)=1)thenstate=wait_1;elsestateif(delay_count(15)=1)thenstate=state_1;elsestatestateif(w_comp_n=0)and(lcd_addr=000110)thenstate=wait_2;elsif(w_comp_n=0)thenstate=wa
15、it_1;elsestateif(delay_count(15)=1)thenstate=state_3;elsestateif(w_comp_n=0)and(lcd_addr=100111)thenstate=done;elsif(w_comp_n=0)thenstate=wait_2;elsestatestatelcd_we_nlcd_we_nlcd_we_nlcd_we_nlcd_we_nlcd_we_nlcd_we_n=1;endcase;endprocesssequencer_state_logic;-Thefollowingsectionsusesthelcd_we_nsignal
16、togeneratethelcd_ensignaland-awritecompletesignal(w_comp_n).Thew_comp_nsignalisusedtoresetvarious-countersthatareusedtogenerateLCDcontrolsignals.state_lcd_write_register:process(clk,resetn)beginif(resetn=0)thenstate_lcd_writeif(lcd_we_n=0)thenstate_lcd_write=lcd_write_1;elsestate_lcd_writeif(seq_cou
17、nt=000101)thenstate_lcd_write=lcd_write_2;elsestate_lcd_writeif(seq_count=011110)thenstate_lcd_write=lcd_write_3;elsestate_lcd_writeif(seq_count=110010)thenstate_lcd_write=lcd_write_4;elsestate_lcd_writestate_lcd_writelcd_en_int=0;w_comp_nlcd_en_int=0;w_comp_nlcd_en_int=1;w_comp_nlcd_en_int=0;w_comp
18、_nlcd_en_int=0;w_comp_nlcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_data=100100000;endcase;endprocess;-Thefollowingisa
19、22-bitfreerunningcounterthatisclearedwhenthereset-signalisassertedortheMSBofthecountergoesto1.Thiscounterisused-togeneratedelaysbetweenback-to-backwritestotheLCDcess(clk)beginif(clkeventandclk=1)thenif(resetn=0)thendelay_count0);elseif(delay_c
20、ount(15)=1)thendelay_count0);elsedelay_count=delay_count+1;endif;endif;endif;endprocess;-Thefollowingcounterisusedbythesequencertogeneratethelcd_ensignal.-ThecounterisresetattheendofeachwritetotheLCDwhenthew_comp_cess(clk)beginif(clkeventandclk=1)thenif(resetn=0)or(w_comp_n=0)thense
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024商品房買賣合同法律特征與無(wú)效情形
- 第四單元課題2 水的凈化教學(xué)設(shè)計(jì)-2023-2024學(xué)年九年級(jí)化學(xué)人教版上冊(cè)
- 統(tǒng)編版二年級(jí)下冊(cè)語(yǔ)文 閱讀課 快樂(lè)讀書(shū)吧課外閱讀《神筆馬良》 教案
- 關(guān)于建筑藝術(shù)的課程設(shè)計(jì)
- 第2章 第2節(jié) 綜合訓(xùn)練2023-2024學(xué)年新教材高中化學(xué)選擇性必修第三冊(cè)同步教學(xué)設(shè)計(jì)(魯科版2019)
- 10 再塑生命的人 教學(xué)設(shè)計(jì)
- 四川省綿陽(yáng)富樂(lè)國(guó)際2024年中考聯(lián)考數(shù)學(xué)試卷含解析
- 信息安全服務(wù)在信息技術(shù)服務(wù)行業(yè)中的應(yīng)用
- 2024年灌溉機(jī)械項(xiàng)目立項(xiàng)申請(qǐng)報(bào)告模稿
- 2024年糖果、巧克力、蜜餞及類似食品項(xiàng)目申請(qǐng)報(bào)告范稿
- 醫(yī)院人才梯隊(duì)建設(shè)與培養(yǎng)方案(2篇)
- 壓軸題05數(shù)列壓軸題15題型 (教師版)
- 易制毒化學(xué)品安全管理崗位責(zé)任分工制度
- 《SketchUp三維輔助設(shè)計(jì)》課件-04 SketchUp基本繪圖工具
- 21J621-1天窗技術(shù)圖集
- (完整版)四宮格數(shù)獨(dú)題目204道(可直接打印)及空表(一年級(jí)數(shù)獨(dú)題練習(xí))
- 《商業(yè)銀行經(jīng)營(yíng)管理》-教學(xué)教案
- 《歌劇魅影》音樂(lè)賞析
- 論科學(xué)、技術(shù)與工程之間的關(guān)系
- 中學(xué)數(shù)學(xué)中的課程思政及案例設(shè)計(jì)
- 第十五章原發(fā)性肝癌課件
評(píng)論
0/150
提交評(píng)論