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


沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...