phanerozoic / threshold-brent-kung

huggingface.co
Total runs: 11
24-hour runs: 0
7-day runs: 2
30-day runs: 7
Model's Last Updated: January 24 2026

Introduction of threshold-brent-kung

Model Details of threshold-brent-kung

threshold-brent-kung

4-bit Brent-Kung parallel prefix adder. Area-efficient variant that computes odd-position prefixes first, then back-propagates.

Circuit
Inputs: A[3:0], B[3:0], Cin (9 inputs)
Outputs: S[3:0], Cout (5 outputs)

Brent-Kung uses fewer prefix operators than Kogge-Stone
by only computing odd positions in the upward sweep.
Brent-Kung Structure (4-bit)
       G3,P3    G2,P2    G1,P1    G0,P0
         │        │        │        │
Level 1  ●────────┘        ●────────┘     (odd positions)
         │                 │
Level 2  ●─────────────────┘              (top)
         │
Level 3  └────────●                       (back-propagate)
                  │
       G3:0     G2:0     G1:0     G0
Comparison with Kogge-Stone
Property Kogge-Stone Brent-Kung
Prefix cells 2n - 2 - log n 2n - 2
Depth log n 2 log n - 2
Wiring High Low
Area Larger Smaller

Brent-Kung trades some speed for reduced area and wiring complexity.

Truth Table (Examples)
A B Cin S Cout
0000 0000 0 0000 0
0101 0011 0 1000 0
1111 0001 0 0000 1
1111 1111 1 1111 1
Parameters
Inputs 9
Outputs 5
Neurons 32
Layers 5
Parameters 132
Magnitude 56
Threshold Implementation
Layer 0: Generate/Propagate
G_i = A_i AND B_i
    weights: [A_i: 1.0, B_i: 1.0]
    bias: -2.0
    fires when: 1·A_i + 1·B_i - 2 >= 0 → A_i + B_i >= 2

P_i = A_i XOR B_i (via OR-NAND-AND decomposition)
    OR:   [1.0, 1.0], bias=-1.0   → A_i + B_i >= 1
    NAND: [-1.0, -1.0], bias=1.0  → -(A_i + B_i) + 1 >= 0 → A_i + B_i <= 1
    AND:  [1.0, 1.0], bias=-2.0   → OR + NAND >= 2
Layers 1-3: Prefix Computation

Brent-Kung's upward sweep computes only odd-position prefixes, then back-propagates to even positions. This minimizes wiring at the cost of depth.

Usage
from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def brent_kung_add(a3, a2, a1, a0, b3, b2, b1, b0, cin):
    a = [a0, a1, a2, a3]
    b = [b0, b1, b2, b3]

    # Generate and Propagate
    g = [a[i] & b[i] for i in range(4)]
    p = [a[i] ^ b[i] for i in range(4)]

    # Upward sweep (odd positions only)
    g10 = g[1] | (p[1] & g[0])
    p10 = p[1] & p[0]
    g32 = g[3] | (p[3] & g[2])
    p32 = p[3] & p[2]

    # Top level
    g30 = g32 | (p32 & g10)

    # Downward sweep (fill even positions)
    g20 = g[2] | (p[2] & g10)

    # Carries
    c0 = g[0] | (p[0] & cin)
    c1 = g10 | (p10 & cin)
    c2 = g20 | (p[2] & p10 & cin)
    c3 = g30 | (p32 & p10 & cin)

    # Sums
    s0 = p[0] ^ cin
    s1 = p[1] ^ c0
    s2 = p[2] ^ c1
    s3 = p[3] ^ c2

    return s3, s2, s1, s0, c3

# Example: 13 + 5 = 18 (overflow)
s3, s2, s1, s0, cout = brent_kung_add(1,1,0,1, 0,1,0,1, 0)
print(f"13 + 5 = {cout*16 + s3*8 + s2*4 + s1*2 + s0}")  # 18
Verification

All 512 input combinations (16 × 16 × 2) exhaustively verified correct.

Files
threshold-brent-kung/
├── model.safetensors    # Threshold network weights
├── create_safetensors.py # Weight generation + exhaustive verification
├── config.json          # Circuit metadata
└── README.md
References
  • Brent, R. P., & Kung, H. T. (1982). "A Regular Layout for Parallel Adders"
  • IEEE Transactions on Computers, C-31(3), pp. 260-264
License

MIT

Runs of phanerozoic threshold-brent-kung on huggingface.co

11
Total runs
0
24-hour runs
0
3-day runs
2
7-day runs
7
30-day runs

More Information About threshold-brent-kung huggingface.co Model

More threshold-brent-kung license Visit here:

https://choosealicense.com/licenses/mit

threshold-brent-kung huggingface.co

threshold-brent-kung huggingface.co is an AI model on huggingface.co that provides threshold-brent-kung's model effect (), which can be used instantly with this phanerozoic threshold-brent-kung model. huggingface.co supports a free trial of the threshold-brent-kung model, and also provides paid use of the threshold-brent-kung. Support call threshold-brent-kung model through api, including Node.js, Python, http.

threshold-brent-kung huggingface.co Url

https://huggingface.co/phanerozoic/threshold-brent-kung

phanerozoic threshold-brent-kung online free

threshold-brent-kung huggingface.co is an online trial and call api platform, which integrates threshold-brent-kung's modeling effects, including api services, and provides a free online trial of threshold-brent-kung, you can try threshold-brent-kung online for free by clicking the link below.

phanerozoic threshold-brent-kung online free url in huggingface.co:

https://huggingface.co/phanerozoic/threshold-brent-kung

threshold-brent-kung install

threshold-brent-kung is an open source model from GitHub that offers a free installation service, and any user can find threshold-brent-kung on GitHub to install. At the same time, huggingface.co provides the effect of threshold-brent-kung install, users can directly use threshold-brent-kung installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

threshold-brent-kung install url in huggingface.co:

https://huggingface.co/phanerozoic/threshold-brent-kung

Url of threshold-brent-kung

threshold-brent-kung huggingface.co Url

Provider of threshold-brent-kung huggingface.co

phanerozoic
ORGANIZATIONS

Other API from phanerozoic

huggingface.co

Total runs: 94
Run Growth: 42
Growth Rate: 45.65%
Updated:September 26 2026