RTL Studio Open IDE

Arithmetic & Math

1-Bit Full Adder — L1 Upgrade — L2 Upgrade

1-Bit Full Adder with saturation clamping and sticky signed overflow flag.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

1-Bit Full Adder — 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 implements a 1-bit full adder with saturation arithmetic and sticky overflow detection. It is designed for low-bit-width arithmetic units where overflow handling and error tracking are critical.

Signed Interpretation:

  • Input 0 represents value 0.
  • Input 1 represents value -1.
  • The output sum is clamped to the valid 1-bit signed range [-1, 0] (represented as 1 and 0 respectively) when saturation occurs.

Sticky Overflow: A sticky flag (ovf_sticky) latches signed overflow events until explicitly cleared via the clr_sticky signal. This allows for error detection across multiple cycles without losing historical overflow information.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 1-Bit Full Adder — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 1-Bit Full Adder with saturation clamping and sticky signed overflow 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.

Features

  • Combinational Logic: Fast 1-bit sum and carry generation.
  • Saturation: Clamps the sum output to 1 (representing -1, the minimum value) on carry-out or saturation conditions.
  • Sticky Overflow Flag: Registers signed overflow events and holds them until cleared.
  • Control Signals: Synchronous reset (rst_n) and asynchronous clear (clr_sticky) for the sticky flag.
  • Verified: Functionally verified with Icarus Verilog simulation.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low synchronous reset
clr_stickyInput1Active-high clear for sticky overflow flag
aInput1Operand A (0=0, 1=-1)
bInput1Operand B (0=0, 1=-1)
cinInput1Carry-in
sumOutput1Saturated sum result
satOutput1Saturation flag (asserted on saturation)
ovf_stickyOutput1Sticky overflow flag

Architecture

The design consists of a raw adder core and control logic for saturation and overflow tracking.

  1. Raw Adder: Computes the standard XOR sum and AND-OR carry.
  2. Saturation Logic: Forces the sum to 1 if a carry-out occurs, ensuring the result stays within the 1-bit signed range.
  3. Signed Overflow Detection: Detects overflow when two negative inputs (1) produce a positive sum (0) without carry, or two positive inputs (0) produce a negative sum (1) with carry.
  4. Sticky Latch: Registers the overflow event. The flag remains set until clr_sticky is asserted or rst_n is de-asserted.

Verification

The testbench verifies basic addition, saturation clamping, and sticky flag behavior.

### Test Cases

Test CaseInputs (a, b, cin)Expected SumExpected SatExpected Ovf StickyResult
TC10, 0, 0000PASS
TC21, 0, 0100PASS
TC30, 1, 0100PASS
TC41, 1, 0111PASS
TC51, 1, 1111PASS
TC6Clear StickyN/AN/A0PASS
TC7Set StickyN/AN/A1PASS

### Running Simulation

To run the simulation:

More in Arithmetic & Math

All Arithmetic & Math blocks