A SID tune makes its sound by writing to the 29 registers of the SID chip at
$D400 to $D41C (the chip’s 32 addresses repeat through
$D7FF on a plain C64). The explorer’s
Registers tab lists every write to them, by video frame and raster line, and reads out
what each voice does. This page is the key to those numbers. It follows Bob Yannes’s
description of the MOS 6581 (the chip’s designer) and the measured behaviour that the open
emulators are built on.
The register map
| Offset | Voice 1 | Voice 2 | Voice 3 | Name |
|---|---|---|---|---|
| +0 | $D400 | $D407 | $D40E | Frequency, low byte (write only) |
| +1 | $D401 | $D408 | $D40F | Frequency, high byte |
| +2 | $D402 | $D409 | $D410 | Pulse width, low byte |
| +3 | $D403 | $D40A | $D411 | Pulse width, high nibble (bits 0 to 3) |
| +4 | $D404 | $D40B | $D412 | Control |
| +5 | $D405 | $D40C | $D413 | Attack (high nibble) and decay (low nibble) |
| +6 | $D406 | $D40D | $D414 | Sustain level (high nibble) and release (low nibble) |
| Address | Name | Bits |
|---|---|---|
$D415 | Filter cutoff, low | Bits 0 to 2: the low three bits of the 11-bit cutoff. |
$D416 | Filter cutoff, high | The high eight bits of the cutoff. |
$D417 | Resonance and routing | Bits 4 to 7 resonance (0 to 15); bit 3 the external input; bits 0 to 2 send voice 1, 2, 3 through the filter. |
$D418 | Mode and volume | Bit 7 voice 3 off (unless it is filtered); bit 6 high-pass; bit 5 band-pass; bit 4 low-pass; bits 0 to 3 the master volume. |
$D419 | Paddle X | Read only; the explorer returns $FF. |
$D41A | Paddle Y | Read only; $FF. |
$D41B | Voice 3 oscillator | Read only: the top eight bits of voice 3’s waveform output. Tunes read it for random numbers (with noise) and for slow modulation. |
$D41C | Voice 3 envelope | Read only: voice 3’s envelope level, 0 to 255. |
$D41D–$D41F | Unused | Reads return the last value on the bus. |
The oscillator
Each voice has a 24-bit phase counter that adds the 16-bit frequency value on every clock
cycle of the chip (the processor clock: 985,248 Hz PAL, 1,022,727 Hz NTSC). The pitch is
F × clock / 16,777,216, so one unit of the frequency register is 0.0587 Hz on a
PAL machine and 0.0610 Hz on an NTSC one, and a tune written for one is out of tune on
the other. 440 Hz needs $1D45 (7493) on PAL.
| Control bit | Name | What it does |
|---|---|---|
| 0 | Gate | 0 to 1 starts the envelope (attack, then decay to the sustain level); 1 to 0 starts the release. |
| 1 | Sync | The counter is cleared each time the previous voice’s counter passes its top bit (voice 1 is synchronised by voice 3). Gives the hard-sync tone. |
| 2 | Ring | With the triangle waveform, the triangle’s fold is made by the previous voice’s top bit: ring modulation (the bell sound). |
| 3 | Test | Holds the counter at 0 and the noise generator reset; used to restart a waveform in phase. |
| 4 | Triangle | The counter’s top 12 bits, folded at the half way point. |
| 5 | Sawtooth | The counter’s top 12 bits. |
| 6 | Pulse | Full level while the top 12 bits are at or above the pulse width, else zero. The width is a 12-bit number, so 4096 steps of duty; 2048 is a square wave. |
| 7 | Noise | Eight bits taken from a 23-bit shift register that is clocked when bit 19 of the counter rises: the faster the voice, the faster the noise. |
Choosing more than one waveform makes a combined waveform, which the real chips produce from the analogue outputs pulling each other down. The values differ between the 6581 and the 8580 and from chip to chip. Combining noise with another waveform locks the shift register up, so it stays silent until the test bit resets it.
The envelope
Each voice has an envelope generator that multiplies the waveform by a level from 0 to 255. It starts at a gate on (attack: the level climbs to 255), then decays to the sustain level (a nibble times 17, so 0 to 255) and stays there until the gate goes off, when it falls to 0 (release). The times below are the documented ones for the 16 settings of each nibble.
| Setting | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Attack, 0 to full | 2 ms | 8 ms | 16 ms | 24 ms | 38 ms | 56 ms | 68 ms | 80 ms | 100 ms | 250 ms | 500 ms | 800 ms | 1 s | 3 s | 5 s | 8 s |
| Decay or release, full to 0 | 6 ms | 24 ms | 48 ms | 72 ms | 114 ms | 168 ms | 204 ms | 240 ms | 300 ms | 750 ms | 1.5 s | 2.4 s | 3 s | 9 s | 15 s | 24 s |
| Rate counter period (cycles) | 9 | 32 | 63 | 95 | 149 | 220 | 267 | 313 | 392 | 977 | 1954 | 3126 | 3907 | 11720 | 19532 | 31251 |
The chip makes these with a 15-bit rate counter that counts clock cycles and steps the level when it reaches the period in the last row, and with a second counter that slows the decay and release as the level falls: the level steps every 1, 2, 4, 8, 16 and 30 periods below the levels $FF, $5D, $36, $1A, $0E and $06, which makes the fall exponential. Two quirks matter to tunes: the rate counter is not reset when a rate is changed, so a counter already above the new period runs on to 32768 and wraps before the next step (the “ADSR delay bug”, which makes a note start late), and a level of 0 holds until the next gate on.
The filter and the volume
The chip has one filter, shared by the voices that are switched through it
($D417 bits 0 to 2). It has three outputs, low-pass, band-pass and high-pass,
that can be mixed ($D418 bits 4 to 6), a cutoff set by the 11-bit value in
$D415/$D416 and a resonance of 0 to 15. The voices that bypass the filter go
straight to the volume control. The cutoff and the shape of the response are the largest
difference between the two chips.
| Cutoff register | MOS 6581 (as fitted from a reference) | MOS 8580 (as fitted) |
|---|---|---|
| 0 | about 360 Hz | near 0 Hz |
| $040 (64) | about 390 Hz | about 440 Hz |
| $100 (256) | about 610 Hz | about 1.7 kHz |
| $200 (512) | about 1.9 kHz | about 3.4 kHz |
| $300 (768) | about 4.5 kHz | about 4.7 kHz |
| $400 (1024) | about 6.6 kHz | about 5.8 kHz |
| $7FF (2047) | about 11 kHz | about 11 kHz |
Those are the −3 dB points that give the best match of this site’s filter to the output of libsidplayfp’s reSIDfp engine for a noise tune (playback); real chips vary, and the 6581’s curve differs from chip to chip.
The master volume ($D418 bits 0 to 3) is a multiplier of the whole output. On a 6581 the
voices have a direct-current offset, so a change of the volume register is heard as a step. A tune
that writes the volume register several thousand times a second is playing sampled sound (“digi”) through it, 4 bits at
a time. On an 8580 the offset is a fraction of that, and such tunes sound faint.
The explorer’s Filter and volume table says when the volume register is written so often that it is playing samples.
What the explorer reads out
- Voices: for each voice of each chip, how many writes it got, how many times its gate was switched on, the lowest and highest pitch it was set to (as a note name and in hertz), every waveform it used with the number of control writes that chose it, the range of pulse widths, the attack/decay and sustain/release values used, and how many times sync, ring modulation and test were set.
- Filter and volume: the cutoff range, resonance values, which voices were filtered, which filter modes were used, the range of volumes and how often the volume was written.
- Voice activity: a picture with a lane for each voice of the first chip: the pitch over the run as a line (coloured by waveform, fainter while the gate is off) and the envelope level as a shaded area.
- Every write: the video frame, raster line and processor cycle of each write to a SID register, the register, the value and its meaning (for example “Voice 1 frequency = $1D (frequency $1D45 = 440.0 Hz, A-4)”).