2020年4月22日 星期三

4-bit Magnitude Comparator in Verilog

4-bit Magnitude Comparator   in  Verilog





//-----------------------------------------
// 4-bit Comparator  
// (if...else if...else)
//-----------------------------------------
module Comparator( a, b , eq, gt, lt);

// Port Declarations
input [3:0] a, b; //4-bit inputs
output reg eq, gt, lt;  //outputs eq:Equal, gt:Great than, lt:Less than

always @ (a or b)
 begin
   if (a==b)
    begin
     eq = 1'b1; gt = 1'b0; lt = 1'b0;
    end
  else if (a > b)
    begin
     eq = 1'b0; gt = 1'b1; lt = 1'b0;
    end
  else
    begin
     eq = 1'b0; gt = 1'b0; lt = 1'b1;
    end
 end
endmodule

沒有留言:

張貼留言

2026 作業2 RFID+Node-Red+Python+SQLite 練習 (修正版 利用wokwi 內部元件)

2026 作業2  RFID+Node-Red+Python+SQLite 練習 (修正版  利用wokwi 內部元件) 使用 wokwi 上 的 元件    (原先尚未有) 硬體線路   不需要 自行建立元件   rfid-rc522.chip.json   rfid-rc52...