threshold-computers / src /host_netlist.py
phanerozoic's picture
threshold-computers: a family of machines built from ternary threshold gates, with the paper on universal construction and exact self-reproduction
4a3e194
Raw History Blame Contribute Delete
1.03 kB
"""The clocked netlist of the SUBLEQ host, unit by unit.
The state is the eight counter bits, a halt bit, and the 2048 bits of the
256-byte memory, in that order; the same order indexes the state layout carried
in the serialization. The netlist is the member H_8 of the constant-depth
family of host_family.py: one application is one SUBLEQ step of depth 13. The
device cells are ordinary memory cells that the runtime overwrites between
steps.
"""
from __future__ import annotations
import os
import sys
from typing import List, Tuple
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from matrix8 import Net
HALT_PC = 0xFF
def subleq_state_names() -> List[str]:
names = [f"pc{i}" for i in range(8)] + ["halt"]
for j in range(256):
names += [f"m{j}b{i}" for i in range(8)]
return names
def build_subleq_step_net() -> Tuple[Net, List[str], List[str]]:
"""The step netlist of the host: the member H_8 of the constant-depth family."""
from host_family import build
return build(8)