2012年10月12日 星期五

P5-22 Low active 3-8 decoder usign bitwise operators


//P5-22 Low active 3-8 decoder usign bitwise operators

//For DE2-70 Boards


module Decoder3x8 (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 [2:0]d;
wire [7:0]y;
   
    //mapping to hardware 
    assign LEDR = SW;
    assign d=SW[2:0];
    

//compute the outputs with b
assign y[0] = ~((~d[2]) & (~d[1]) & (~d[0])),
            y[1] = ~((~d[2]) & (~d[1]) & (d[0])),
            y[2] = ~((~d[2]) & (d[1]) & (~d[0])),
            y[3] = ~((~d[2]) & (d[1]) & (d[0])),
            y[4] = ~((d[2]) & (~d[1]) & (~d[0])),
            y[5] = ~((d[2]) & (~d[1]) & (d[0])),
            y[6] = ~((d[2]) & (d[1]) & (~d[0])),
            y[7] = ~((d[2]) & (d[1]) & (d[0]));

//assign output hardware
assign LEDG=y;


endmodule

/*
//Filename : decod3_8.v
//----------------------------------------------
module decod3_8(y, d);
output [7:0] y;
input [2:0] d;

 //compute the outputs with b
 assign y[0] = ~((~d[2]) & (~d[1]) & (~d[0])),
            y[1] = ~((~d[2]) & (~d[1]) & (d[0])),
            y[2] = ~((~d[2]) & (d[1]) & (~d[0])),
            y[3] = ~((~d[2]) & (d[1]) & (d[0])),
            y[4] = ~((d[2]) & (~d[1]) & (~d[0])),
            y[5] = ~((d[2]) & (~d[1]) & (d[0])),
            y[6] = ~((d[2]) & (d[1]) & (~d[0])),
            y[7] = ~((d[2]) & (d[1]) & (d[0]));
endmodule
*/


沒有留言:

張貼留言

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

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