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  


沒有留言:

張貼留言

Node-Red & ModeBus FC=1

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