2012年10月27日 星期六

P6-18 8bit latch 適用於DE2-70

P6-18 8bit latch 適用於DE2-70




//------------------------------------
//8-bit latch using if... statement
//Filename : latch8_if
//------------------------------------

module latch_8bit (SW, LEDR, LEDG , CLOCK_27 ,KEY );
input  [17:0] SW; // toggle switches
input  [7:0] KEY;     // Push bottom
input  CLOCK_27; //Clock 27MHz , 50Mhz

output [17:0] LEDR; // red  LEDS   
  output [7:0] LEDG; // green LEDs
  
  
//set original program input , output 

    // output [7:0] y;
   // input load;     //latch signal
    // input [7:0] din;
    
    //wire [7:0] y;
wire load;
wire [7:0] din;

reg [7:0] y=8'b0;
    
    
    //mapping to hardware 
    assign LEDR = SW;
    
    assign load=SW[17];
    assign din=SW[7:0];   
      
   
always @ (y or load)
begin
if (load)
y = din;
end

    assign LEDG[7:0]=y;

endmodule

沒有留言:

張貼留言

習題解答 (5/6)

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