RTL Studio Open IDE

Arithmetic & Math

8-Bit Saturating Subtractor — L1 Upgrade — L2 Upgrade

8-bit unsigned saturating subtractor with sticky underflow flag, asynchronous reset, and synchronous clear.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

8-Bit Saturating Subtractor — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Arithmetic & Math catalog. Adders, multipliers, dividers, ALUs, and arithmetic datapaths. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.

This IP core implements an 8-bit unsigned saturating subtractor.

It computes a - b and saturates the result to zero if a < b.

A sticky sat_flag indicates when an underflow event has occurred, persisting until explicitly cleared via clear_sat or rst_n.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Saturating Subtractor — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 8-bit unsigned saturating subtractor with sticky underflow flag, asynchronous reset, and synchronous clear.
  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.

Features

  • 8-bit Unsigned Arithmetic: Operates on two 8-bit operands.
  • Saturating Output: Result is clamped to 0 on underflow (a < b).
  • Sticky Status Flag: sat_flag asserts high on underflow and remains high until cleared.
  • Reset Control:

- Asynchronous active-low reset (rst_n). - Synchronous clear (clear_sat).

  • Combinational Result: The subtraction result is available immediately.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
clear_satInput1Synchronous clear for sticky flag
aInput8Minuend operand
bInput8Subtrahend operand
resultOutput8Saturating subtraction result
sat_flagOutput1Sticky underflow flag

Verification

The provided testbench validates the following scenarios:

Test CaseDescriptionExpected ResultExpected Flag
TC1Normal subtraction (10 - 3)70
TC2Underflow (3 - 10)01
TC3Sticky flag persistence71
TC4Clear flag via clear_satN/A0
TC5Reset clears flagN/A0
TC6Zero result (5 - 5)00

Run the simulation to verify these test cases. The simulation log should report INFO: PASS upon completion.

More in Arithmetic & Math

All Arithmetic & Math blocks