RTL Studio Open IDE

Arithmetic & Math

32-Bit Equality Comparator — L1 Upgrade — L2 Upgrade

Registered 32-bit equality comparator with sticky saturation flag for underflow detection.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

32-Bit Equality 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 implements a registered 32-bit equality comparator with a sticky saturation flag.

It compares two 32-bit operands (a and b) and asserts an output when they are equal.

Additionally, it detects underflow conditions (where a < b) and sets a sticky saturation flag that persists until explicitly cleared via the clear_sat signal.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 32-Bit Equality Comparator — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: Registered 32-bit equality comparator with sticky saturation flag for underflow detection.
  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

The module registers input operands a and b on the rising clock edge when valid_in is asserted. Equality is determined by comparing the registered values. A saturation flag is set if a is less than b during the comparison cycle. The saturation flag remains high until the clear_sat signal is asserted, provided valid_in is also high.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low reset
clear_satInput1Clear saturation flag
valid_inInput1Valid input enable
aInput32Operand A
bInput32Operand B
eq_outOutput1Equality output
sat_flagOutput1Sticky saturation flag

Verification

The testbench verifies six key scenarios to ensure functional correctness:

  1. TC1: Basic Equality detection for identical operands.
  2. TC2: Basic Inequality detection for distinct operands.
  3. TC3: Saturation flag setting on underflow (a < b).
  4. TC4: Sticky nature of the saturation flag (persists across cycles).
  5. TC5: Clearing of the saturation flag via clear_sat.
  6. TC6: Reset behavior of all outputs.
Test CaseDescriptionExpected Result
TC1Basic Equalityeq_out = 1, sat_flag = 0
TC2Basic Inequalityeq_out = 0, sat_flag = 0
TC3Underflow Saturationeq_out = 0, sat_flag = 1
TC4Sticky Saturationeq_out = 0, sat_flag = 1
TC5Clear Saturationeq_out = 0, sat_flag = 0
TC6Reset Behavioreq_out = 0, sat_flag = 0

More in Arithmetic & Math

All Arithmetic & Math blocks