2014年6月7日 星期六

74HC/HCT85 4-bit magnitude comparator---Verilog

74HC/HCT85  4-bit magnitude comparator
APPLICATIONS
• Process controllers
• Servo-motor control


Verilog HDL源代碼


module compare4(
input       [3:0] a_in, // 第一個4位比較值
input       [3:0] b_in, // 第二個4位比較值
input       [2:0] i_in, // 擴展輸入端

output  reg [2:0] f_out      // 比較結果輸出端
);

//******************************************************************************
//  模組名稱:4位元比較器模組
//  功能描述:完成4位比較器的功能
//******************************************************************************
always@( a_in or b_in or i_in ) begin
    if ( a_in > b_in )
      f_out = 3'b100; // 輸出a大於b
    else if( a_in < b_in )
       f_out = 3'b010; // 輸出a小於b
    else begin
         case( i_in )
         3'b000:
                  f_out = 3'b110;
         3'b010:
         f_out = 3'b010; // 輸出a小於b
         3'b100:
         f_out = 3'b100; // 輸出a大於b
         3'b110:
                  f_out = 3'b000;
         default:
         f_out = 3'b001;     // 輸出a等於b
         endcase
    end
end
endmodule  


沒有留言:

張貼留言

2026 作業3 RFID+ Telegram 練習

 2026 作業3  RFID+ Telegram  練習 (Wokwi 與 Telegram 二者溝通訊息反映比較慢 ) 歡迎 Alex 使用 RFID 控制系統 /on : 開啟 LED /off : 關閉 LED /flash : 閃爍模式 /timer : 開啟 5 秒 ...