# SPDX-License-Identifier: MIT """The two chips as one frozen description (handoff-brief decision 1). The uPD96050 is a uPD77C25 with wider counters, more memory, a deeper stack and three extra jump codes (start-here.md "Registers"). Everything the core does differently for it reads one of these fields; there is no second class. """ from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True, slots=True) class Model: """Widths and sizes of one chip. The core masks every register to these widths (C9).""" name: str pc_bits: int # DS (2): 11; fullsnes: 14 on the uPD96050 rp_bits: int # DS (7): 10; fullsnes: 11 dp_bits: int # DS (5): 8; fullsnes: 11 stack_depth: int # DS (3): 4 levels; fullsnes: 8 (C5) program_words: int # 2,048 x 24 bits; 16,384 on the uPD96050 data_rom_words: int # 1,024 x 16 bits; 2,048 ram_words: int # 256 x 16 bits; 2,048 (battery-backed on the ST010/ST011) #: JP bits 1-0 are NA bits 12-11 and conditional jumps keep PC bit 13 (U11). On the #: uPD7725 those bits are "Reserved" and the 11-bit PC drops them anyway. bank_bits: bool def __post_init__(self) -> None: if self.stack_depth & (self.stack_depth - 1): raise ValueError("stack_depth must be a power of two (the pointer wraps: U10)") for name in ("program_words", "data_rom_words", "ram_words"): if getattr(self, name) <= 0: raise ValueError(f"{name} must be positive") @property def pc_mask(self) -> int: return (1 << self.pc_bits) - 1 @property def rp_mask(self) -> int: return (1 << self.rp_bits) - 1 @property def dp_mask(self) -> int: return (1 << self.dp_bits) - 1 #: NEC uPD77C25 (the SNES DSP-1, -1A, -1B, -2, -3, -4): DS section 2, "Comparison" table. UPD7725_MODEL = Model( name="upd7725", pc_bits=11, rp_bits=10, dp_bits=8, stack_depth=4, program_words=2048, data_rom_words=1024, ram_words=256, bank_bits=False, ) #: NEC uPD96050 (Seta ST010, ST011): no NEC document exists; fullsnes "Registers" and byuu #: (research tier), confirmed by the ST011 program's own jumps (program tier). UPD96050_MODEL = Model( name="upd96050", pc_bits=14, rp_bits=11, dp_bits=11, stack_depth=8, program_words=16384, data_rom_words=2048, ram_words=2048, bank_bits=True, ) MODELS = {model.name: model for model in (UPD7725_MODEL, UPD96050_MODEL)} __all__ = ["MODELS", "UPD7725_MODEL", "UPD96050_MODEL", "Model"]