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
*/


沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...