




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、分頻module clkgen (clock,reset,clkdiv,clk500;input clock,reset;output clkdiv;output clk500;reg 31:0 counter1;reg clkdiv;reg clk500;reg 31:0 counter0;/*?1HZ?*/always(posedge clockif(resetbeginclkdiv<=0;counter0<=0;endelse if(counter0=24'd4begincounter0<=0;clkdiv=clkdiv;endelsebegincounter0
2、<=counter0+1;clkdiv<=clkdiv;end/*?500HZ?*/always(posedge clock if(resetbeginclk500<=0;counter1<=0;endelse if(counter1=24'd2begincounter1<=0;clk500=clk500;endelsebegincounter1<=counter1+1;clk500<=clk500;endendmodule計數(shù)module jishu24(clkdiv,clear,second,s_carry,minute,m_carry,h
3、our,sL,sH,mL,mH,hL,hH; input clkdiv,clear;output 5:0 second,minute;output 4:0 hour;output s_carry,m_carry;output sL,sH,mL,mH,hL,hH;reg s_carry,m_carry;reg 5:0 second,minute;reg 4:0 hour;reg sL,sH,mL,mH,hL,hH;always(posedge clkdiv or clearif(clearsecond<=0;else if(second!=6'b111011beginsecond&
4、lt;=second+1;s_carry<=0;endelsebeginsecond<=0;s_carry<=1;endalways(posedge s_carry or clearif(clearminute<=0;else if(minute!=6'b111011beginminute<=minute+1;m_carry<=0;endelsebeginminute<=0;m_carry<=1;endalways (posedge m_carry or clearif(clearhour<=0;else if(hour!=5
5、9;b10111beginhour<=hour+1;endelsebeginhour<=0;endalways(posedge secondbeginsL<=second%10;sH<=second/10;endalways(posedge minutebeginmL<=minute%10;mH<=minute/10;endalways(posedge hourbeginhL<=hour%10;hH<=hour/10;endendmodule顯示module decode(clk500,reset,hH,hL,mH,mL,sH,sL,HIGH,L
6、OW,COM;input clk500;input reset;input hH,hL;/?input mH,mL;/?input sH,sL;/?output 6:0 HIGH,LOW;/?output 7:0 COM;/?reg 7:0 show_temp_H,show_temp_L;/?reg 7:0 COM;reg 7:0 Uweixuan;/?COM?reg 2:0 sm;/?reg 6:0 HIGH;/?reg 6:0 LOW;/?always(posedge clk500beginif(sm=3'b111sm<=3'b000;elsesm<=sm+3&
7、#39;b001;Uweixuan<=Uweixuan<<1;/?if(Uweixuan=8'b0000_0000Uweixuan<=8'b0000_0001; /?Uweixuan?COM=Uweixuan;/?Uweixuan?endalways(smbegincase(COM8'b1111_1110:show_temp_H=sL;/?8'b1111_1101:show_temp_H=sH;8'b1111_1011:show_temp_H=4'b1010;8'b1111_0111:show_temp_H=mL;
8、8'b1110_1111:show_temp_L=mH;8'b1101_1111:show_temp_L=4'b1010;8'b1011_1111:show_temp_L=hL;8'b0111_1111:show_temp_L=hH;/?endcaseendalways(show_temp_H/?begincase(show_temp_H4'b0000: HIGH=7'b011_1111;4'b0001: HIGH =7'b000_0110;4'b0010: HIGH =7'b101_1011;4'
9、b0011: HIGH =7'b100_1111;4'b0100: HIGH =7'b110_0110;4'b0101: HIGH =7'b110_1101;4'b0110: HIGH =7'b111_1101;4'b0111: HIGH =7'b000_0111;4'b1000: HIGH =7'b111_1111;4'b1001: HIGH =7'b110_1111;4'b1010: HIGH =7'b100_0000;default HIGH =7'b000_0
10、000;endcaseendalways(show_temp_L/?begincase(show_temp_L4'b0000:LOW=7'b011_1111;4'b0001: LOW =7'b000_0110;4'b0010: LOW =7'b101_1011;4'b0011: LOW =7'b100_1111;4'b0100: LOW =7'b110_0110;4'b0101: LOW =7'b110_1101;4'b0110: LOW =7'b111_1101;4'b01
11、11: LOW =7'b000_0111;4'b1000: LOW =7'b111_1111;4'b1001: LOW =7'b110_1111;4'b1010: LOW =7'b100_0000;default LOW =7'b000_0000;endcaseendendmodule主函數(shù)實現(xiàn)各函數(shù)的調(diào)用module main(clock,reset,HIGH,LOW,COM;input clock;input reset;output 6:0 HIGH,LOW;output 7:0 COM;endmodulemodule cl
12、kgen (clock,reset,clkdiv,clk500; input clock,reset;output clkdiv;output clk500;reg 23:0 counter1;reg clkdiv;reg clk500;reg 23:0 counter0;/*?1HZ?*/ always(posedge clockif(resetbeginclkdiv<=0;counter0<=0;endelse if(counter0=24'd4begincounter0<=0;clkdiv=clkdiv;endelsebegincounter0<=coun
13、ter0+1;clkdiv<=clkdiv;end/*?500HZ?*/ always(posedge clock if(resetbeginclk500<=0;counter1<=0;endelse if(counter1=24'd2begincounter1<=0;clk500=clk500;endelsebegincounter1<=counter1+1;clk500<=clk500;endendmodulemodule jishu24(clkdiv,clear,second,s_carry,minute,m_carry,hour,sL,sH,
14、mL,mH,hL,hH; input clkdiv,clear;output 5:0 second,minute;output 4:0 hour;output s_carry,m_carry;output sL,sH,mL,mH,hL,hH;reg s_carry,m_carry;reg 5:0 second,minute;reg 4:0 hour;reg sL,sH,mL,mH,hL,hH;always(posedge clkdiv or clearif(clearsecond<=0;else if(second!=6'b111011beginsecond<=second
15、+1;s_carry<=0;endelsebeginsecond<=0;s_carry<=1;endalways(posedge s_carry or clearif(clearminute<=0;else if(minute!=6'b111011beginminute<=minute+1;m_carry<=0;endelsebeginminute<=0;m_carry<=1;endalways (posedge m_carry or clearif(clearhour<=0;else if(hour!=5'b10111be
16、ginhour<=hour+1;endelsebeginhour<=0;endalways(posedge secondbeginsL<=second%10;sH<=second/10;endalways(posedge minutebeginmL<=minute%10;mH<=minute/10;endalways(posedge hourbeginhL<=hour%10;hH<=hour/10;endendmodulemodule shumaguan(clk500,reset1,hH,hL,mH,mL,sH,sL,HIGH,LOW,COM;i
17、nput clk500;input reset1;input hH,hL;/?input mH,mL;/?input sH,sL;/?output 6:0 HIGH,LOW;/?output 7:0 COM;/?reg 7:0 show_temp_H,show_temp_L;/?reg 7:0 COM;reg 7:0 Uweixuan;/?COM?reg 2:0 sm;/?reg 6:0 HIGH;/?reg 6:0 LOW;/?always(posedge clk500beginif(sm=3'b111sm<=3'b000;elsesm<=sm+3'b00
18、1;Uweixuan<=Uweixuan<<1;if(Uweixuan=8'b0000_0000Uweixuan<=8'b0000_0001; /?Uweixuan? COM=Uweixuan;/?Uweixuan?endalways(clk500begincase(COM8'b1111_1110:show_temp_H=sL;/?8'b1111_1101:show_temp_H=sH;8'b1111_1011:show_temp_H=4'b1010;8'b1111_0111:show_temp_H=mL;8
19、9;b1110_1111:show_temp_L=mH;8'b1101_1111:show_temp_L=4'b1010;8'b1011_1111:show_temp_L=hL;8'b0111_1111:show_temp_L=hH;/?endcaseendalways(show_temp_H/?begincase(show_temp_H4'b0000: HIGH=7'b011_1111;4'b0001: HIGH =7'b000_0110;4'b0010: HIGH =7'b101_1011;4'b001
20、1: HIGH =7'b100_1111;4'b0100: HIGH =7'b110_0110;4'b0101: HIGH =7'b110_1101;4'b0110: HIGH =7'b111_1101;4'b0111: HIGH =7'b000_0111;4'b1000: HIGH =7'b111_1111;4'b1001: HIGH =7'b110_1111;4'b1010: HIGH =7'b100_0000;default HIGH =7'b000_0000;
21、 endcaseendalways(show_temp_L/?begincase(show_temp_L4'b0000: LOW =7'b011_1111;4'b0001: LOW =7'b000_0110;4'b0010: LOW =7'b101_1011;4'b0011: LOW =7'b100_1111;4'b0100: LOW =7'b110_0110;4'b0101: LOW =7'b110_1101;4'b0110: LOW =7'b111_1101;4'b0111: LOW =7'b000_0111;4'b1000: LOW =7'b111_1111;4'b1
溫馨提示
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 主播上崗考試題及答案
- 靜物寫生素描考試題及答案
- 宣傳接待崗面試題及答案
- 廣東省廣州市番禺育才2022-2023學(xué)年八年級下學(xué)期期中考試物理試題(含答案)
- 抗體檢驗知識培訓(xùn)課件
- 創(chuàng)新型醫(yī)療器械研發(fā)協(xié)議
- 關(guān)于職場軟技能培養(yǎng)的建議與反思
- 小學(xué)生科學(xué)知識讀物征文
- 員工技能培訓(xùn)安排表
- 全球教育資源分布及質(zhì)量評估表
- 信息系統(tǒng)應(yīng)急響應(yīng)計劃制定指南考核試卷
- 酒店消防安全知識培訓(xùn)試題及答案
- 2024解析:第四章光現(xiàn)象-講核心(解析版)
- 2024解析:第十九章生活用電-講核心(解析版)
- BRC+Food+Safety+Standard+2024年培訓(xùn)課件全攻略
- 《公路橋梁掛籃設(shè)計與施工技術(shù)指南》
- 建筑工地安全風險分級管控方案
- 供熱管網(wǎng)維保服務(wù)方案
- 現(xiàn)代家政導(dǎo)論-課件 4.1.1認識家政教育及意義
- 浙江省【高等職業(yè)技術(shù)教育招生考試】-商業(yè)類(電子商務(wù))-職業(yè)技能理論知識(一)(答案版)
- 人教版小學(xué)六年級下冊音樂教案全冊
評論
0/150
提交評論