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  


沒有留言:

張貼留言

Modbus FC=1 (Coils read) & FC=15 (Coils Write)

Modbus FC=1  (Coils read)  & FC=15 (Coils Write)   「從 Modbus 設備讀取多個線圈(Coils)狀態,並立刻將這些狀態原封不動地轉寫到另一個記憶體位址(起始位址 16)」 。 整個流程使用了知名套件 node-red...