Nintendo Entertainment System · build log
The APU, and sound over HDMI
The NES has its sound. The APU, the part of the CPU chip that makes it, follows MesenCE cycle for cycle: two pulse channels, a triangle, noise, the delta-modulation channel and the frame counter that paces them. A model of it in C++ matches the hardware design on every output over millions of cycles, and blargg’s APU and timing test ROMs pass, 34 of them, in the simulation and on the Tang Nano 20K and the PYNQ-Z2. A CRC of the five channels’ levels on every CPU cycle comes out the same on both boards as in the simulation.
The channels are mixed as the chip mixes them, resampled to 48 kHz, and sent with the picture over HDMI, which a monitor plays. The NES makes exactly 800 samples a frame, so its sound keeps time with the 60 Hz display it is paced to, and the samples are the same in the simulation and on every board.
The Tang Nano 20K’s chip is nearly full with the sound added, so its build now leaves out save states; the other boards keep them.