




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、說明文檔4到8 LED編碼器4位超前進位加法器abcincout8段LED顯示器8段LED顯示器1.結(jié)構(gòu)圖:2.八段LED顯示器的編碼:假設(shè)8段LED顯示器是共陰極的,DPGFEDCBA正好組成一個8位的數(shù)8seg,給這個數(shù)賦值,即可以顯示相應(yīng)的數(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)超前進位加法器,這種加法器運算速度顯著提高,但是復(fù)雜度也提高了。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、編碼器 兩個模塊例化放一起,完成本設(shè)計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.對本設(shè)計進行測試/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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度光伏互補型充電樁安裝合同
- 工傷私了賠償協(xié)議范本2025年度:賠償協(xié)議的爭議解決途徑
- 2025年度智能化鋪面出租服務(wù)合同
- 二零二五年度施工安全教育培訓(xùn)與咨詢服務(wù)協(xié)議
- 二零二五年度酒廠文化遺產(chǎn)保護與傳承合作協(xié)議
- 2025年度校企產(chǎn)學(xué)研合作知識產(chǎn)權(quán)共享合同
- 2025年度海鮮餐廳承包經(jīng)營與食材供應(yīng)合同
- 二零二五年度汽車不過戶責(zé)任免除及后續(xù)保養(yǎng)及理賠協(xié)議
- 2025年度社區(qū)食堂運營承包與管理合同
- 舉辦活動保證金協(xié)議
- 2023年全國高考體育單招考試英語試卷試題真題(精校打印版)
- 2023年四川省綿陽市中考化學(xué)試卷真題(含答案與解析)
- 財務(wù)管理中的財務(wù)指標(biāo)
- 2016-2023年青島酒店管理職業(yè)技術(shù)學(xué)院高職單招(英語/數(shù)學(xué)/語文)筆試歷年參考題庫含答案解析
- 第二章-環(huán)境數(shù)據(jù)統(tǒng)計與分析
- 電力各種材料重量表總
- 腸道健康講座活動策劃
- 醫(yī)療器械(耗材)項目投標(biāo)服務(wù)投標(biāo)方案(技術(shù)方案)
- 小學(xué)三年級下冊數(shù)學(xué)教案3篇
- pci術(shù)后術(shù)肢腫脹處理流程
- 遼寧省營口市2023-2024學(xué)年七年級上學(xué)期期末英語試題
評論
0/150
提交評論