| ---
|
| license: mit
|
| tags:
|
| - pytorch
|
| - safetensors
|
| - threshold-logic
|
| - neuromorphic
|
| ---
|
|
|
| # threshold-7segment
|
|
|
| BCD to 7-segment display decoder.
|
|
|
| ## Function
|
|
|
| segment_decode(B3, B2, B1, B0) -> {a, b, c, d, e, f, g}
|
|
|
| Converts 4-bit BCD input (0-9) to 7 segment control signals.
|
|
|
| ## Segment Layout
|
|
|
| ```
|
| aaa
|
| f b
|
| ggg
|
| e c
|
| ddd
|
| ```
|
|
|
| ## Digit Patterns
|
|
|
| | Digit | a | b | c | d | e | f | g | Display |
|
| |-------|---|---|---|---|---|---|---|---------|
|
| | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | `0` |
|
| | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | `1` |
|
| | 2 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | `2` |
|
| | 3 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | `3` |
|
| | 4 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | `4` |
|
| | 5 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | `5` |
|
| | 6 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | `6` |
|
| | 7 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | `7` |
|
| | 8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | `8` |
|
| | 9 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | `9` |
|
|
|
| ## Architecture
|
|
|
| Two-layer design:
|
|
|
| ```
|
| B3,B2,B1,B0 ββΊ [d0] ββ
|
| [d1] ββ€
|
| [d2] ββ€ [OR] ββΊ a
|
| [d3] ββΌββββββΊ [OR] ββΊ b
|
| [d4] ββ€ [OR] ββΊ c
|
| [d5] ββ€ [OR] ββΊ d
|
| [d6] ββ€ [OR] ββΊ e
|
| [d7] ββ€ [OR] ββΊ f
|
| [d8] ββ€ [OR] ββΊ g
|
| [d9] ββ
|
| ```
|
|
|
| Layer 1: 10 digit detectors (pattern matchers)
|
| Layer 2: 7 OR gates combining relevant digits for each segment
|
|
|
| ## Parameters
|
|
|
| | | |
|
| |---|---|
|
| | Inputs | 4 |
|
| | Outputs | 7 |
|
| | Neurons | 17 |
|
| | Layers | 2 |
|
| | Parameters | 127 |
|
| | Magnitude | 111 |
|
|
|
| ## Usage
|
|
|
| ```python
|
| from safetensors.torch import load_file
|
| # Full implementation in model.py
|
|
|
| # Example: Display digit 5
|
| # result = segment_decode(0, 1, 0, 1, weights)
|
| # -> {'a':1, 'b':0, 'c':1, 'd':1, 'e':0, 'f':1, 'g':1}
|
| ```
|
|
|
| ## License
|
|
|
| MIT
|
| |