EDA技術與Verilog設計第六章課后習題部分答案PPT課件_第1頁
EDA技術與Verilog設計第六章課后習題部分答案PPT課件_第2頁
EDA技術與Verilog設計第六章課后習題部分答案PPT課件_第3頁
EDA技術與Verilog設計第六章課后習題部分答案PPT課件_第4頁
EDA技術與Verilog設計第六章課后習題部分答案PPT課件_第5頁
已閱讀5頁,還剩26頁未讀, 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1 6 11 6 11試編寫求補碼的Verilog程序 輸入是帶符號的8位二進制數modulewytest data in data out 習題6 11input 7 0 data in output 7 0 data out reg 7 0 data out always data in beginif data in 7 正數負數判斷 從最高是否為1來判斷data out data in 1 8 h80 elsedata out data in endendmodule 2 6 11仿真波形 8A 原碼表示的十進制數 100A 十進制數10B6 原碼表示的十進制數 5436 十進制數5380 原碼表示的十進制數128 3 6 12 6 12編寫兩個四位二進制數相減的verilog程序modulewytest opr1 opr2 out data 完成Opr1 opr2的運算input 3 0 opr1 opr2 output 4 0 out data reg 3 0 out regcout function 3 0 abs input 3 0 data case data 3 1 b0 abs data 1 b1 abs data 1 對負數求絕對值 按位取反再加1endcaseendfunction 4 6 12 always opr1oropr2 case opr1 3 opr2 3 2 b00 cout out opr1 opr2 兩個正數相減2 b01 cout out opr1 abs opr2 正數減負數 化為加法運算2 b10 cout out abs opr1 opr2 負數減正數 化為加法再取反2 b11 cout out abs opr2 abs opr1 負數相減 化為絕對值相減 順序調換 endcaseassignout data cout out endmodule 5 6 12 6 12仿真波形 6 6 13 6 13有一個比較電路 當輸入的一位BCD碼大于4時 輸出1 否則輸出0 modulewytest bcd in out input 3 0 bcd in outputout assignout bcd in 4 1 0 endmodule 7 6 13 仿真波形 8 6 13 modulewytest bcd in out 習題6 13input 3 0 bcd in outputout assignout bcd in 4 1 0 regout always bcd in if bcd in 4 0 out 1 elseout 0 endmodule 9 6 13 10 6 14 試編寫一個實現3輸入與非門的verilog程序 modulewytest a o input 2 0 a outputo nandnand3 o a 0 a 1 a 2 endmodule 11 6 14 12 6 15 6 15設計74138譯碼器電路 13 6 15 modulewytest s1 s2 in out inputs1 input 1 0 s2 input 2 0 in output 7 0 out reg 8 0 out always s1ors2orin beginif s1 0 out 8 hff elseif s2 0 s2 1 out 8 hff elsecase in 3 d0 out 8 b11111110 3 d1 out 8 b11111101 3 d2 out 8 b11111011 3 d3 out 8 b11110111 3 d4 out 8 b11101111 3 d5 out 8 b11011111 3 d6 out 8 b10111111 3 d7 out 8 b01111111 endcaseendendmodule 14 6 15 15 6 16 CO Q3Q2Q1Q0CTT 注意 異步清零 同步置位 6 16設計一個74161的電路 16 6 16 modulewytest reset load ctt ctp clk data in out co 習題6 16inputreset load ctt ctp clk input 3 0 data in output 3 0 out outputco reg 3 0 out regco always posedgeclkornegedgereset if reset beginout 4 b0 co 1 b0 endelseif load out data in elseif ctt out out elseif ctp out out elsebeginout out 1 if out 14 co 1 elseco 0 endendmodule 17 6 16 18 四級流水線實現的32位加法器 modulewytest clk a b sum cout input 31 0 a b inputclk output 31 0 sum outputcout 最后輸出的結果reg 31 0 sum regcout 第一級流水線的輸出reg 7 0 fist sum regfirst cout 第一級流水線要緩存的數據 未用的數據緩存reg 7 0 first a 31 24 first a 23 16 first a 15 8 reg 7 0 first b 31 24 first b 23 16 first b 15 8 19 四級流水線實現的32位加法器 第二級流水線的輸出reg 7 0 second sum regsecond cout 第二級流水線要緩存的數據 未用的數據緩存reg 7 0 second a 31 24 second a 23 16 reg 7 0 second b 31 24 second b 23 16 第一級流水線計算結果緩存reg 7 0 first sum 1 第一級流水線計算結果第一次緩存 第三級流水線輸出reg 7 0 third sum regthird cout 第三級流水線要緩存的數據 未用的數據緩存reg 7 0 third a 31 24 reg 7 0 third b 31 24 第一級 第二級流水線計算結果緩存reg 7 0 first sum 2 第一級流水線計算結果第二次緩存 reg 7 0 second sum 1 第二級流水線計算結果第一次緩存 20 四級流水線實現的32位加法器 第一級流水線always posedgeclk begin first cout fist sum a 7 0 b 7 0 cout first a 31 24 a 31 24 first b 31 24 b 31 24 first a 23 16 a 23 16 first b 23 16 b 23 16 first a 15 8 a 15 8 first b 15 8 b 15 8 end 第二級流水線always posedgeclk begin second cout second sum first a 15 8 first b 15 8 first cout second a 31 24 first a 31 24 second b 31 24 first b 31 24 second a 23 16 first a 23 16 second b 23 16 first b 23 16 first sum 1 fist sum end 21 四級流水線實現的32位加法器 第三級流水線always posedgeclk begin third cout third sum second a 23 16 second b 23 16 second cout third a 31 24 second a 31 24 third b 31 24 second b 31 24 first sum 2 first sum 1 second sum 1 second sum end 第四級流水線always posedgeclk begin cout sum 31 24 third a 31 24 third b 31 24 third cout sum 23 0 third sum second sum 1 first sum 2 endendmodule 22 四級流水線實現的32位加法器 23 8x8乘法器實現 modulewytest out a b clk input 7 0 a b inputclk output 15 0 out reg 15 0 out reg 3 0 firsta firstb reg 3 0 seconda secondb wire 7 0 outa outb outc outd always posedgeclk beginfirsta 3 0 a 7 4 seconda 3 0 a 3 0 firstb 3 0 b 7 4 secondb 3 0 b 3 0 end mul4x4m1 outa firsta firstb clk m2 outb seconda firstb clk m3 outc firsta secondb clk m4 outd seconda secondb clk always posedgeclk out outa 8 outb 4 outc 4 outd endmodule 24 8x8乘法器實現 用另一種方法實現 將8位數字分成4段 每段兩位 那么操作數可表示如下 A A1X26 A2X24 A3X22 A4B B1X26 B2X24 B3X22 B4AXB A1X26 A2X24 A3X22 A4 X B1X26 B2X24 B3X22 B4 上式展開后 要做16次2X2的乘法 調用16次lookup函數然后再做移位相加的處理 25 7 5編寫4位并 串轉換電路 modulewytest clk rst in out inputclk rst input 3 0 in outputout regout reg 1 0 i always posedgeclk beginif rst begini 2 d0 out 1 d0 endelseif i 3 beginout in i i i 1 endend 26 模為9的占空比50 的奇數分頻 modulewytest RESET CLK COUT inputCLK RESET outputCOUT reg 3 0 m n wireCOUT regCOUT1 COUT2 assignCOUT COUT1 COUT2 always posedgeCLK beginif RESET beginCOUT1 0 輸出信號初態為0m 0 計數初值為0end elseif RESET beginif m 8 n 1beginm 0 endelsem m 1 if m 3 N 2 1 5COUT1 COUT1 elseif m 7 N 2COUT1 COUT1 endend 27 always negedgeCLK beginif RESET beginCOUT2 0 n 0 end elseif RESET beginif n 8 beginn 0 endelsen n 1 if n 3 COUT2 COUT2 elseif n 7 COUT2 COUT2 endendEndmodule 模為9的占空比50 的奇數分頻 28 模為9 3的小數分頻 分頻方法 9分頻7次 10分頻3次 modulefdiv8 1 clk in rst clk out inputclk in rst outputclk out regclk out reg 3 0 cnt1 cnt1計8分頻的次數reg 3 0 cnt2 cnt2為兩個分頻器的計數值always posedgeclk inorposedgerst beginif rst begincnt1 0 cnt2 0 clk out 0 endelseif cnt1 7 9分頻7次beginif cnt2 8 9分頻的前8個脈沖的處理begincnt2 cnt2 1 clk out 0 endelse 處理最后一個輸入脈沖begincnt2 0 clk out 1 cnt1 cnt1 1 endend 29 模為9 3的小數分頻 elseif cnt1 10 beginif cnt2 9 10分頻的前9個脈沖處理begincnt2 cnt2 1 clk out 0 endelsebegincnt2 0 clk out 1 if cnt1 9 cnt1 0 elsecnt1 cnt1 1 endendendendmodule 30 習題10 3 1001 二進制序列檢測器 S0 S1 S2 S3 1 0 0 0 0 0 0 0 1 1 1 0 1 0 0

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論