001. 初始文件
创建模拟器的初始源文件。
第 1 / 356 · tests/chapter_01_cpu/test_001_initial_files.py
需要创建的文件
emulator/cpu/cpu.py
emulator/cpu/addressing_modes.py
emulator/cpu/instructions.py
emulator/bus/cpu_bus.py
emulator/memory/ram.py此步骤存在的原因
在实现具体行为之前,先确立最初的源代码边界。CPU 状态、地址计算、指令行为、总线路由和内存存储不应从一开始就混在一个单体文件中。
复现步骤
1. Create emulator/cpu, emulator/bus, and emulator/memory if they do not exist.
2. Create the five empty Python files listed above.
3. Add __init__.py files to package directories when required by the environment.
4. Run this test and confirm that every expected path exists.此步骤尚不需要任何实现。空文件正是本步骤预期的结果。
常见误解
创建多个独立文件并不要求现在就设计好未来所有的类。此步骤只定义物理位置;后续的测试会逐步引入各自的职责。
范围之外
- RAM 行为
- CPU 寄存器
- 总线地址映射
- 指令执行
运行本课
uv run pytest tests/chapter_01_cpu/test_001_initial_files.py -v