二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)

二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)

ID:37751338

大?。?6.50 KB

頁數(shù):5頁

時間:2019-05-30

二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)_第1頁
二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)_第2頁
二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)_第3頁
二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)_第4頁
二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)_第5頁
資源描述:

《二進(jìn)制轉(zhuǎn)十進(jìn)制Verilog實現(xiàn)》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫

1、/*八位二進(jìn)制輸入三位十進(jìn)制BCD碼輸出*/modulebcd(input[7:0]bin_in,//輸入二進(jìn)制//3位bcd碼輸出outputreg[3:0]dec_out0=4'h0,outputreg[3:0]dec_out1=4'h0,outputreg[3:0]dec_out2=4'h0,inputclk);wire[2:0]c_in;wire[2:0]c_out;reg[3:0]dec_sreg0=4'h0;reg[3:0]dec_sreg1=4'h0;reg[3:0]dec_sreg2=4'h0;wire[

2、3:0]next_sreg0,next_sreg1,next_sreg2;reg[3:0]bit_cnt=4'h0;reg[7:0]bin_sreg;wireload=~

3、bit_cnt;//讀入二進(jìn)制數(shù)據(jù),準(zhǔn)備轉(zhuǎn)換wireconvert_ready=(bit_cnt==4'h9);//轉(zhuǎn)換成功wireconvert_end=(bit_cnt==4'ha);//完畢,重新開始/*************************************************************************

4、***************************************/always@(posedgeclk)beginif(convert_end)bit_cnt<=4'h0;elsebit_cnt<=bit_cnt+4'h1;end/**************************************************************************************************************/always@(posedgeclk)beginif(lo

5、ad)bin_sreg<=bin_in;elsebin_sreg<={bin_sreg[6:0],1'b0};endassignc_in[0]=bin_sreg[7];assignc_in[1]=(dec_sreg0>=5);assignc_in[2]=(dec_sreg1>=5);assignc_out[0]=c_in[1];assignc_out[1]=c_in[2];assignc_out[2]=(dec_sreg2>=5);//確定移位輸出assignnext_sreg0=c_out[0]?({dec_sreg0

6、[2:0],c_in[0]}+4'h6):({dec_sreg0[2:0],c_in[0]});assignnext_sreg1=c_out[1]?({dec_sreg1[2:0],c_in[1]}+4'h6):({dec_sreg1[2:0],c_in[1]});assignnext_sreg2=c_out[2]?({dec_sreg2[2:0],c_in[2]}+4'h6):({dec_sreg2[2:0],c_in[2]});//裝入數(shù)據(jù)/**************************************

7、**************************************************************************************************/always@(posedgeclk)beginif(load)begindec_sreg0<=4'h0;dec_sreg1<=4'h0;dec_sreg2<=4'h0;endelsebegindec_sreg0<=next_sreg0;dec_sreg1<=next_sreg1;dec_sreg2<=next_sreg2;e

8、ndend//輸出/**************************************************************************************************************************************/always@(posedgeclk)beginif(convert_ready)begindec_out0<=dec_sreg0;dec_out1<=dec_sreg1;dec_out2<=dec_sreg2;endendendmod

9、ule/*16為二進(jìn)制輸入,5位十進(jìn)制BCD碼輸出*/modulebcd1(input[15:0]bin_in,//輸入二進(jìn)制//3位bcd碼輸出outputreg[3:0]dec_out0=4'h0,outputreg[3:0]dec_out1=4'h0,outputreg[3:0]dec_out2=4'h0,ou

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動畫的文件,查看預(yù)覽時可能會顯示錯亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負(fù)責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時聯(lián)系客服。
3. 下載前請仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時可能由于網(wǎng)絡(luò)波動等原因無法下載或下載錯誤,付費(fèi)完成后未能成功下載的用戶請聯(lián)系客服處理。