Logic Gates
XOR-Reduce Tree 8-bit
An 8-bit XOR-reduce tree that computes the parity of an 8-bit input vector using a hierarchical binary tree structure.
About this block
Simulate it in the Verilog IDE
XOR-Reduce Tree 8-bit is a Verilog reference block in the Logic Gates catalog. AND, OR, XOR, and other combinational gate and boolean logic primitives. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.
This IP core implements a fast, combinational 8-bit XOR-reduce tree to compute the parity of an input vector.
It utilizes a hierarchical three-stage binary tree structure to minimize latency, making it suitable for high-speed parity generation and error detection applications.
The design is fully verified with exhaustive and random testing.
- Stage 1: Pairs adjacent input bits to produce 4 intermediate signals.
- Stage 2: Pairs the Stage 1 outputs to produce 2 signals.
- Stage 3: XORs the Stage 2 outputs to produce the final parity result.
- Choose Open in IDE. RTL Studio loads the packaged workspace for XOR-Reduce Tree 8-bit.
- Read the Verilog module in the editor. The catalog line for this block: An 8-bit XOR-reduce tree that computes the parity of an 8-bit input vector using a hierarchical binary tree structure.
- 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.
Ports
| Port | Direction | Width | Description |
|---|---|---|---|
in | Input | [7:0] | 8-bit input vector |
out | Output | 1 | XOR reduction result (parity) |
Architecture
The data flow follows a strict binary tree reduction:
Verification
The IP includes a comprehensive testbench (tb/tb_xor_reduce_tree_8bit.v) that performs:
- Exhaustive Testing: Checks all $2^8 = 256$ input combinations.
- Random Testing: Verifies random vectors for robustness.
- Edge Cases: Specifically tests all-zeros, all-ones, and single-bit set scenarios.
### Test Case Highlights
| Test Case | Input | Expected Output | Description |
|---|---|---|---|
| TC1 | 8'h00 | 0 | All zeros (Even parity) |
| TC2 | 8'hFF | 0 | All ones (Even parity) |
| TC3 | 8'h01 | 1 | Single bit set (Odd parity) |
| TC4 | 8'h80 | 1 | Single bit set (Odd parity) |
| TC5 | 8'h07 | 1 | Odd parity (3 bits set) |
| TC6 | 8'h03 | 0 | Even parity (2 bits set) |
Integration
To use this IP in your project:
- Include
rtl/xor_reduce_tree_8bit.vin your synthesis simulation sources. - Instantiate the module using the port list defined above.
### Example Instantiation
More in Logic Gates
- 2-Input AND Gate
- 2-Input NAND Gate
- 2-Input NOR Gate
- 2-Input OR Gate
- 2-Input XOR Gate
- 3-Input Bitwise NOR Gate
- 3-Input Majority Voter
- 3-State Buffer with Enable and High-Z
- 5-Input Majority Voter with Fault Tolerance
- 8-Bit Bitwise XNOR Gate
- 8-Bit NAND Reduction
- 8-Input Majority Voter
- Bitwise Mask AND/OR 8-bit
- OR-Reduce 8-Bit
- Priority Mask-Below 8-bit