版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、Good is good, but better carries it.精益求精,善益求善。LCD計數(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 腦卒中并發(fā)吞咽障礙個案護理
- IPD(漢捷培訓(xùn))資料課件
- 《認清形勢》課件
- 《政府規(guī)制政策》課件
- 生鮮行業(yè)的報告范文
- 《政府政策與經(jīng)濟學(xué)》課件
- 2025年河南貨運從業(yè)資格證500道題目和答案大全
- 右一跖骨骨折個案護理
- 2025年安徽貨運資格證題目答案解析
- 《認知主義》課件
- 糠醛工藝操作規(guī)程
- 房建項目工程質(zhì)量標準化圖冊(179頁)
- 天津人社局解除勞動合同證明書
- 化工廠車間、班組日常安全檢查表
- 小學(xué)低年級體育游戲化教學(xué)研究課題研究報告
- 復(fù)式交分道岔的檢查方法資料講解
- 檢測和校準實驗室能力認可準則(ISOIEC 170252017)
- S775(八) 重力式無閥濾池
- T∕GEIA 14-2021 華式箱式變電站試驗導(dǎo)則
- 道路橋梁施工工藝流程圖
- m3352系列光盤epc9200i l512liv128li用戶手冊
評論
0/150
提交評論