2012年10月11日 星期四

P5-16 移位 Shift << , >> 範例:除8 適合於DE2-70實驗板



// p5-16 Divided by 8 shift right operator ">>  
// for DE2=70 experiment board"

module Divided8 (SW, LEDR, LEDG);
input [17:0] SW; // toggle switches
output [17:0] LEDR; // red  LEDS   
  output [7:0] LEDG; // green LEDs
  
//set original program input , output 
wire [7:0]div;  //Dividend
wire [7:0]quot; //Quotient , Remainder

assign div=SW[7:0];

parameter sh_bit=3;
assign quot = div >> sh_bit;

assign LEDG[7:0]=quot;
     
endmodule     


/*original program 
module div_8(div,quot);
input [7:0]div;
output[7:0]quot;
parameter sh_bit=3;
assign quot = din >> sh_bit;
endmodule
*/

沒有留言:

張貼留言

習題解答 (5/6)

  第五章 習題解答 一、 錯誤偵測技術 1. 何謂循環冗餘檢查法 (CRC)? 是一種根據傳輸資料產生簡短固定位數校驗碼的演算法。發送端將資料除以一個特定的多項式,得到的「餘數」即為 CRC 碼並隨資料發送;接收端以同樣多項式除之,若餘數為 0 則代表資料傳輸正確。 2. 何...