2012年10月12日 星期五

P5-24 4-2 編碼器 for DE2-70 Boards



//P5-24 4-2 encoder using bitwise operators




module Encoder4x2 (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 [1:0] y;
wire [3:0] I;

   
    //mapping to hardware 
    assign LEDR = SW;
    assign I=SW[3:0];


//Assign y[1:0] with truth table states
assign y[1] = ((((~I[3]) & (I[2])) | ((I[3]) & (~I[2]))) & (~I[1]) & (~I[0])),
           y[0] = ((~I[2]) & (~I[0]) & (((~I[3]) & (I[1])) | ((I[3]) & (~I[1]))));

    assign LEDG[1:0]=y;

endmodule
    
    
    
/*  original program   
//-----------------------------------------------
//Filename : encod4_2.v
//-----------------------------------------------
module encod4_2(y, I3, I2, I1, I0);

output [1:0] y; 
input I3, I2, I1,I0;

//Assign y[1:0] with truth table states
assign y[1] = ((((~I3) & (I2)) | ((I3) & (~I2))) & (~I1) & (~I0)),
           y[0] = ((~I2) & (~I0) & (((~I3) & (I1)) | ((I3) & (~I1))));

endmodule
*/

沒有留言:

張貼留言

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

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