Arithmetic & Math
4-Input 8-Bit Adder Tree — L2 Upgrade
4-input 8-bit adder tree with saturating arithmetic and sticky overflow flag.
About this block
Simulate it in the Verilog IDE
4-Input 8-Bit Adder Tree — 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 a 4-input 8-bit unsigned adder tree with saturating arithmetic and a sticky saturation flag. It is designed for fixed-point accumulation applications where overflow detection is critical.
The module computes the sum of four 8-bit inputs, saturating the result to 255 (8'hFF) if the true sum exceeds the 8-bit range. A sticky sat flag remains asserted until explicitly cleared via the clr_sat signal.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 4-Input 8-Bit Adder Tree — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: 4-input 8-bit adder tree with saturating arithmetic and sticky overflow flag.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- 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
- 4-Input Addition: Supports four parallel 8-bit operands.
- Saturating Arithmetic: Output clamps to 255 (
8'hFF) on overflow. - Sticky Saturation Flag:
satoutput remains high after any overflow event until cleared. - Reset Control: Asynchronous active-low reset (
rst_n) clears all state. Synchronous clear (clr_sat) resets only the saturation flag. - Registered Outputs: Registered
sumandsatoutputs ensure stable timing for downstream logic.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Asynchronous active-low reset |
clr_sat | Input | 1 | Synchronous saturation flag clear |
a | Input | 8 | First 8-bit operand |
b | Input | 8 | Second 8-bit operand |
c | Input | 8 | Third 8-bit operand |
d | Input | 8 | Fourth 8-bit operand |
sum | Output | 8 | Saturated sum result |
sat | Output | 1 | Sticky saturation flag |
Integration
### Instantiation
Include the RTL file rtl/adder_tree_4x8_sticky_sat_flag.v in your project. Instantiate the module as follows:
### Usage Example
- Assert
rst_nlow to initialize the module. - Deassert
rst_nto begin operation. - Provide 8-bit values to inputs
a,b,c, andd. - Monitor
sumfor the result. Ifsumis 255 andsatis 1, an overflow occurred. - To clear the sticky flag, assert
clr_sathigh for one clock cycle.
Verification
The provided testbench (tb/tb_adder_tree_4x8_sticky_sat_flag.v) validates:
- Normal addition without overflow.
- Saturation behavior when sum > 255.
- Sticky flag persistence across cycles.
- Synchronous clear of the saturation flag.
- Asynchronous reset functionality.
### Running Simulation
- Ensure your simulator supports SystemVerilog/Verilog.
- Run the simulation script provided in the
sim/directory (e.g.,run_sim.shor equivalent). - Check the log output for
INFO: PASSmessages.
### Expected Results
The simulation log should contain:
TC1 PASS sum=40 sat=0TC2 PASS sum=255 sat=1TC3 PASS sum=4 sat=1TC4 PASS sat=0TC5 PASS sum=0 sat=0TC6 PASS sum=255 sat=1TC7 PASS sum=1 sat=1INFO: PASS
More in Arithmetic & Math
- 1-Bit Full Adder
- 1-Bit Full Adder — L1 Upgrade — L2 Upgrade
- 1-Bit Half Adder
- 16-Bit Carry-Select Adder
- 16-Bit Signed Adder with Overflow
- 2-Bit Saturating Up/Down Counter — L2 Upgrade
- 32-Bit Count Leading Zeros
- 32-Bit Equality Comparator — L1 Upgrade — L2 Upgrade
- 32-Bit Population Count — L1 Upgrade — L2 Upgrade
- 4-bit Adder-Subtractor with Overflow
- 4-Digit BCD Adder with Carry Propagation — L2 Upgrade
- 8-Bit Absolute Value — L1 Upgrade
- 8-Bit ALU Slice with Add/Sub and Logic Ops — L2 Upgrade
- 8-Bit Carry-Save Adder (3:2) — L2 Upgrade
- 8-Bit Count Trailing Zeros — L1 Upgrade — L2 Upgrade
- 8-Bit EQ/GT/LT Comparator — L1 Upgrade — L2 Upgrade