You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The x76489 is a fully synchronous Verilog implementation of the Texas Instruments SN76489AN Digital Complex Sound Generator. This implementation provides a functional equivalent of the SN76489AN for FPGA-based applications.
Features
Fully Synchronous Design: All state changes occur on the positive edge of clk when cen is active. No latches or asynchronous logic.
Three Tone Channels: 10-bit period down counters with toggle flip-flop output.
White and Periodic Noise: 15-bit LFSR with configurable feedback taps (bits 0,1).
Four Independent Attenuators: 2dB steps per TI datasheet, 0dB to 28dB plus OFF.
Register Compatible: 8 internal registers with latch/data byte protocol.
The testbench (tb_x76489.v) provides comprehensive verification across 6 sections covering the latch / data register bus, tone and noise generators, attenuators, master mix, and write-while-active behaviour:
Register Protocol: Latch byte, data byte, all 8 register addresses, reset defaults
Tone Generation: Period configuration, toggle verification, rate comparison
Noise Generation: White and periodic modes, LFSR shift, tone 3 driven, LFSR reset
Attenuation: 2dB steps, OFF state, silence verification
Master Output: Channel summing and isolation (3 tone + noise)
Write-While-Active: Attenuation and frequency changes during playback
An agnostic VGM playback testbench is included for validating the PSG against real game audio. VGM files contain timestamped SN76489 register writes captured from arcade and console hardware. The testbench replays these writes through the x76489 and captures the audio output as WAV files.
WAV files are written to sim/output/wav/ with names derived from the source VGM filenames. The testbench automatically detects the SN76489 clock rate from each VGM file and adjusts timing accordingly.
Pipeline
Step
Input
Output
vgm2hex.py
VGZ/VGM files
playlist.hex + tracklist.txt
tb_x76489_vgm.v
playlist.hex
track_NN.raw (8-bit PCM at 44100 Hz)
wav_batch.py
track_NN.raw + tracklist.txt
Named WAV files
SN76489 Family Roadmap
The x76489 core targets the SN76489AN. LFSR taps and prescaler are parameterized for future variant support.
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0). You may use, share, and modify this code for non-commercial purposes, provided that proper credit is given. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.