threshold-absolutevalue4

Absolute value of 4-bit 2's complement signed integer.

Function

abs4(a) = |a| where a is interpreted as 4-bit 2's complement (-8 to +7)

Truth Table

| Input | Signed | |Abs| | Output | |-------|--------|------|--------| | 0000 | +0 | 0 | 0000 | | 0001 | +1 | 1 | 0001 | | 0010 | +2 | 2 | 0010 | | 0011 | +3 | 3 | 0011 | | 0100 | +4 | 4 | 0100 | | 0101 | +5 | 5 | 0101 | | 0110 | +6 | 6 | 0110 | | 0111 | +7 | 7 | 0111 | | 1000 | -8 | 8 | 1000 | | 1001 | -7 | 7 | 0111 | | 1010 | -6 | 6 | 0110 | | 1011 | -5 | 5 | 0101 | | 1100 | -4 | 4 | 0100 | | 1101 | -3 | 3 | 0011 | | 1110 | -2 | 2 | 0010 | | 1111 | -1 | 1 | 0001 |

Architecture

5-layer circuit implementing conditional 2's complement negation:

  • For positive (a3=0): output = input
  • For negative (a3=1): output = ~input + 1

Key formulas for negative path:

  • o0 = a0 (always)
  • o1 = ~a1 XOR ~a0
  • o2 = a2 XOR (a1 AND ~a0)
  • o3 = 1 only for input 1000 (-8)

Parameters

Inputs 4
Outputs 4
Neurons 23
Layers 5
Parameters 145
Magnitude 64

License

MIT

Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/threshold-absolutevalue4