2012年10月28日 星期日

P6-33 4x1 MUX 適用於DE2-70

P6-33 4x1 MUX 適用於DE2-70 

//--------------------------------------------------
//4 to 1 multiplexer using case....endcase statement
//Filename : mul4_1_case.v
//--------------------------------------------------
module mux_4x1(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 

    // Port Declarations
    //(y, s, i);
//output y;
//input [1:0] s;   //Select line
//input [3:0] i;    //Input data
    
    wire [3:0] i;
    wire [1:0] s;
    reg y;
    
    
    //mapping to hardware 
    assign LEDR = SW;
    
    assign i=SW[3:0]; 
    assign s=SW[17:16];


always @(s or i)
begin
case (s)
      2'b00 : y = i[0];
      2'b01 : y = i[1];
      2'b10 : y = i[2];
      2'b11 : y = i[3];
      default : y = 1'b0;
endcase
end


   assign LEDG[0]=y;

endmodule

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...