RTL Studio Open IDE

Arithmetic & Math

8-Bit EQ/GT/LT Comparator — L1 Upgrade — L2 Upgrade

8-bit registered comparator with equality, greater-than, less-than outputs and a sticky saturation flag.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

8-Bit EQ/GT/LT Comparator — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Arithmetic & Math catalog. Adders, multipliers, dividers, ALUs, and arithmetic datapaths. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP core implements an 8-bit registered comparator capable of determining equality, greater-than, and less-than relationships between two unsigned operands (a and b).

It features registered outputs for stable timing and a sticky saturation flag that indicates when the absolute difference between inputs exceeds 127 (0x7F).

The saturation flag persists until explicitly cleared via the clear_sat signal.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit EQ/GT/LT Comparator — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 8-bit registered comparator with equality, greater-than, less-than outputs and a sticky saturation flag.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Architecture

  • Clock Domain: Single clock domain (clk).
  • Reset: Active-low asynchronous reset (rst_n).
  • Inputs: Two 8-bit unsigned operands (a, b).
  • Logic:

- Combinational comparison logic calculates relationships. - Sequential logic registers outputs on posedge clk. - Saturation logic checks if the difference exceeds the threshold of 127.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
clear_satInput1Active-high clear for saturation flag
aInput8Input operand A
bInput8Input operand B
eqOutput1Asserted when a equals b
gtOutput1Asserted when a is greater than b
ltOutput1Asserted when a is less than b
sat_flagOutput1Sticky saturation flag

Verification

The design has been verified using a testbench that covers:

  • Reset behavior
  • Equality, Greater-Than, and Less-Than comparisons
  • Saturation detection for large differences (both a > b and b > a)
  • Sticky behavior of the saturation flag
  • Clear functionality of the saturation flag

### Test Results

All 12 test cases passed successfully:

  • TC1: Reset behavior
  • TC2-TC4: Basic comparisons (EQ, GT, LT)
  • TC5-TC6: Saturation detection (large differences)
  • TC7-TC11: Saturation flag sticky and clear behavior
  • TC12: Zero difference edge case

More in Arithmetic & Math

All Arithmetic & Math blocks