# ReSID

reSID is a reverse engineered software emulation of the MOS6581 SID (Sound Interface Device) chip programmed by Dag Lem. This chip was used in the Commodore 64 computer. reSID is free software, published under the GNU General Public License.
reSID is a C++ library containing a complete emulation of the SID chip. This library can be linked into programs emulating the MOS6510 MPU to play music made for the Commodore 64 computer. reSID has been linked into VICE (a Commodore 64 emulator), SIDPLAY (a SID tune player), and into the trackers GoatTracker and cheesecutter.
The emulator engine is cycle-based, emulating the internal operations of the SID chip. SID's audio filter is modeled as an actual two-integrator-loop biquadratic filter. The engine has been developed based on available information on SID, sampling of the OSC3 and ENV3 registers, filter theory, and testing.
There are two main varieties of the SID chip, 6581 and 8580. They implement the same programming API, but their analogue parts behave differently. The differences are mostly: quality of DACs, combined waveforms, voltage offsets inside the chip and the filter.
Due to the engineering decisions, the filter of the 6581 family of chips was significantly nonlinear. Simulations of the effect indicate that the distortion is strongly linked to sound amplitude at the highpass and bandpass outputs of the filter, and occurs only on the other half-wave of the output waveform. The effective center frequency of the filter can be seen to drift higher in spectrum as the input waveform's amplitude increases, and the effect is believed to be side effect of the exponential response of the NMOS inverters that double as op-amps on the 6581 chip. Additionally, the distortion is stabilized by the inverted phase of the bandpass output, which allows some distortion to occur during both half-waves of the input waveform. In contrast, the 8580 chip's filter was re-engineered and appears to behave ideally.
The linear filters of reSID do not even attempt to emulate the nonlinear character of 6581 emulation, and some features such as the OptimiseLevel setting further degrades filter quality by limiting the filter upper frequency to mere 4 kHz (genuine chips can specify center frequencies up to at least 20 kHz on the 6581 and 12 kHz on 8580). Work has been done to add 6581 distortion simulation to the engine, it started in 2007 as a patch maintained by Antti S. Lankila and ended up with the reSIDfp fork, included as the main emulation engine in libsidplayfp.
The latest official version is 0.16, which was released 11 June 2004, while a prerelease for reSID 1.0 was included in VICE in 2010 - 2011, and has been patched by others since then. The prerelease provides accurate models of non-monotonic D/A converters and filter for the 6581 model, where a DAQ has been used to sample the SID capacitor pins in order to work out an op-amp transfer function. It also includes an assortment of improvements to the cycle level emulation of digital components, in particular the waveform and envelope generators, based on revectorized die photographs. A first attempt was made later on to correctly model the 8580 filter too and emulate the slight level of distortion which appears in some extreme conditions. In 2022 Dag Lem returned to development on a new repository hosted on GitHub which is intended to become the official source for the reSID MOS6581 / MOS8580 SID emulator.