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產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...