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


沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...