




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、說明文檔4到8 LED編碼器4位超前進位加法器abcincout8段LED顯示器8段LED顯示器1.結(jié)構(gòu)圖:2.八段LED顯示器的編碼:假設8段LED顯示器是共陰極的,DPGFEDCBA正好組成一個8位的數(shù)8seg,給這個數(shù)賦值,即可以顯示相應的數(shù)字。編碼:3.編碼器子模塊4到8位LED編碼器module coder(in,out);input3:0 in;output7:0 out;wire3:0 in;reg7:0 out;always(in)begincase(in)4'h0: out=8'h3f;4'h1: out=8'h06;4'h2: out
2、=8'h5b;4'h3: out=8'h4f;4'h4: out=8'h66;4'h5: out=8'h6d;4'h6: out=8'h7d;4'h7: out=8'h07;4'h8: out=8'h7f;4'h9: out=8'h6f;4'ha: out=8'h77;4'hb: out=8'h7c;4'hc: out=8'h39;4'hd: out=8'h5e;4'he: out=8'h79;4
3、'hf: out=8'h71;endcaseendendmodule4. 超前進位加法器子模塊對一個4位全加器,第i位的兩加數(shù)分別是Ai和Bi,進位輸入信號是Ci-1,這個位產(chǎn)生的進位輸出是 Ci,則可以有得到:Ci=AiBi(AiBi)Ci-1令Gi= AiBi(進位產(chǎn)生函數(shù)) Pi= AiBi(進位傳遞函數(shù))則:Ci=Gi+ PiCi-1所以有:C0=G0+P0C-1 C1=G1+P1C0 C2=G2+P2C1 C3=G3+P3C2將上式逐次代入則可以得到如下表達式(C-1是最低位的進位輸入)COG0+P0C-1C1=G1+P1C0=G1+P1G0+P1P0C-1C2=G2
4、+P2C1=G2+P2G1+P2P1C0=G2+P2G1+P2P1G0+P2P1P0C-1C3=G3+P3C2 =G3+P3G2+P3P2C1 =G3+P3P2P3P2C1 =G3+P3P2P3P2G1P3P2P1C0 =G3+P3P2P3P2G1P3P2P1G0P3P2P1P0C-1上述表達式說明只要各位數(shù)據(jù)和最低位進位同時輸入,各位之間的進位信號與和就能同時產(chǎn)生。要據(jù)這樣的原理可以實現(xiàn)超前進位加法器,這種加法器運算速度顯著提高,但是復雜度也提高了。module add4_head( a, b, cin, sum,cout);input3:0 a;input3:0 b;input cin;
5、output3:0 sum;output cout;wire3:0 p;wire3:0 g;wire3:0 t;wire2:0 c;assign p0 = a0 | b0;assign p1 = a1 | b1;assign p2 = a2 | b2;assign p3 = a3 | b3;assign t0 = a0 b0;assign t1 = a1 b1;assign t2 = a2 b2;assign t3 = a3 b3;assign g0 = a0 & b0;assign g1 = a1 & b1;assign g2 = a2 & b2;assign g3
6、= a3 & b3;assign c0 = (p0 & cin) | g0;assign c1 = (p1 & c0) | g1;assign c2 = (p2 & c1) | g2;assign cout = g3 | (p3 & (g2 | p2 & (g1 | p1 & (g0|(p0&cin);assign sum0 = t0 cin;assign sum1 = t1 c0;assign sum2 = t2 c1;assign sum3 = t3 c2; endmodule5.例化兩個子模塊把超前進位加法器和4到8位LED
7、編碼器 兩個模塊例化放一起,完成本設計module add_display(a,b,cin,cout,out);input3:0 a;input3:0 b;input cin;output cout;output7:0 out;wire3:0 temp;add4_head add4_head(.a(a), .b(b), .cin(cin), .sum(temp), .cout(cout) );coder coder ( .in(temp), .out(out);endmodule6.對本設計進行測試/timescale 1ns / 1psmodule testbench;/ Inputsreg
8、 3:0 a;reg 3:0 b;reg cin;/ Outputswire 7:0 out;wire cout; add_display add_display(.a(a),.b(b),.cin(cin),.cout(cout),.out(out);integer m,n,l;initial begin a = 4'b0000; b = 4'b0000;cin= 0;/ Add stimulus herefor(m=0;m<2;m=m+1) for(n=0;n<16;n=n+1) for(l=0;l<16;l=l+1) begin a=n; b=l; cin
9、=m; #20; end end endmodule module fanlongfei5test;/ Inputsreg 3:0 a;reg 3:0 b;reg cin;/ Outputswire 7:0 out;wire cout;fanlongfeichao uut(.a(a),.b(b),.cin(cin),.cout(cout),.out(out);initial begin a=4'b0000;b=4'b0000;cin=0;#20a=4'b0000;b=4'b0000;cin=1;#20a=4'b0001;b=4'b0000;cin
10、=1;#20a=4'b0001;b=4'b0001;cin=1;#20a=4'b0100;b=4'b0100;cin=1;#20a=4'b1111;b=4'b0001;cin=1;#20a=4'b0001;b=4'b0000;cin=0;#20a=4'b0001;b=4'b0001;cin=0;#20a=4'b0100;b=4'b0100;cin=0;#20a=4'b1111;b=4'b0001;cin=0;#20;endendmodule4'b0000:out0=1000000;4'b0001:out0=1111001; 4'b0010:out0=0100100; 4'b0011:out0=011
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 出售學校學區(qū)房合同范本
- 一建培訓合同范本
- 年度供貨合同范本
- 供銷總社采購合同范例
- 勞動工人合同范本
- 公司合作簽合同范本
- 中央新風合同范本
- 加盟飯店合同范本
- 中介房租合同范本
- app項目轉(zhuǎn)讓合同范本
- 社會階層與教育選擇行為分析-深度研究
- 社會工作行政(第三版)課件匯 時立榮 第6-11章 項目管理- 社會工作行政的挑戰(zhàn)、變革與數(shù)字化發(fā)展
- 學校小賣部承包合同范文
- 2025年湘潭醫(yī)衛(wèi)職業(yè)技術學院高職單招職業(yè)適應性測試近5年??及鎱⒖碱}庫含答案解析
- 2025年湖南鐵道職業(yè)技術學院高職單招職業(yè)技能測試近5年常考版參考題庫含答案解析
- DB 63- T993-2011 三江源生態(tài)監(jiān)測技術規(guī)范
- 北京市東城區(qū)2025年公開招考539名社區(qū)工作者高頻重點提升(共500題)附帶答案詳解
- 2025福建福州地鐵集團限公司運營分公司校園招聘高頻重點提升(共500題)附帶答案詳解
- 2025至2030年中國電子護眼臺燈數(shù)據(jù)監(jiān)測研究報告
- 兒童睡眠障礙治療
- 2025年浙江省溫州樂清市融媒體中心招聘4人歷年高頻重點提升(共500題)附帶答案詳解
評論
0/150
提交評論