2014年6月15日 星期日

SN74LS139 Dual 1-of-4 Decoder/Demultiplexer---適用於DE2-70

SN74LS139  Dual 1-of-4 Decoder/Demultiplexer

module Decoder_2x4_Ls139(En, A, D);
   input En;
   input [1:0] A;
   output reg [3:0] D;
 
   always @ (A or En)
   begin
      if (En==1'b1)
          D<=4'b1111;
      else  
       case (A)
       2'b00 :   D<=4'b1110;
       2'b01 :   D<=4'b1101;
       2'b10 :   D<=4'b1011;
       2'b11 :   D<=4'b0111;
      endcase
   
  end
   
 endmodule





module Decoder_2x4(
  input CLOCK_50,     //    50 MHz clock
  input [3:0] KEY,      //    Pushbutton[3:0]
  input [17:0] SW,     //    Toggle Switch[17:0]
  output [6:0]    HEX0,HEX1,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7,  // Seven Segment Digits
  output [8:0] LEDG,   //    LED Green
  output [17:0] LEDR,   //    LED Red
  inout [35:0] GPIO_0,GPIO_1,    //    GPIO Connections
//    LCD Module 16X2
  output LCD_ON,     // LCD Power ON/OFF
  output LCD_BLON,     // LCD Back Light ON/OFF
  output LCD_RW,     // LCD Read/Write Select, 0 = Write, 1 = Read
  output LCD_EN,     // LCD Enable
  output LCD_RS,     // LCD Command/Data Select, 0 = Command, 1 = Data
  inout [7:0] LCD_DATA, // LCD Data bus 8 bits
  input  UART_RXD, //RS232 RXD
  output UART_TXD //RS232 TXD
);

//    All inout port turn to tri-state
assign    GPIO_0        =    36'hzzzzzzzzz;
assign    GPIO_1        =    36'hzzzzzzzzz;

assign HEX0=7'b111_1111;  //off 7-segment Display
assign HEX1=7'b111_1111;
assign HEX2=7'b111_1111;
assign HEX3=7'b111_1111;
assign HEX4=7'b111_1111;
assign HEX5=7'b111_1111;
assign HEX6=7'b111_1111;
assign HEX7=7'b111_1111;

//Decoder_2x4_Ls139(En, A, B, D);
Decoder_2x4_Ls139(SW[17],SW[1:0],LEDR[3:0]);


endmodule





 module Decoder_2x4_Ls139(En, A, D);
   input En;
   input [1:0] A;
   output reg [3:0] D;
 
   always @ (A or En)
   begin
      if (En==1'b1)
          D<=4'b1111;
      else  
       case (A)
       2'b00 :   D<=4'b1110;
       2'b01 :   D<=4'b1101;
       2'b10 :   D<=4'b1011;
       2'b11 :   D<=4'b0111;
      endcase
   
  end
   
 endmodule

沒有留言:

張貼留言

Node-Red & ModeBus FC=1

Node-Red & ModeBus FC=1 write address=0..7   8bits read address=16..23 8bits  [{"id":"cf7c1253d4d997dd","type&q...