--- 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