Let's build a "perfect" MOS SID (6581)

VST, AU, AAX, CLAP, etc. Plugin Virtual Instruments Discussion
RELATED
PRODUCTS

Post

Here is a more modern thread. I first looked at the technical reversing efforts published in 2008, but it seems this thread from 2016 has much more complete (90%?) information in it.

http://forum.6502.org/viewtopic.php?f=8&t=4150

With this information already researched and published by others it makes it far more practical to design an accurate model working in spice for every component.

I don't personally have much interest in the subject but I will publish my spice netlists / ltspice schematics here so we can begin to look at improving the accuracy of the model. With an accurate model in hand it will be possible to accurately model the filter in software with a valid reference using the usual approximate methods ("zero delay" filters, blah blah ...)

It would make sense to publish the results under GPLv2 so they can be used in reSID and related projects to even further perfect their accuracy.

Here are a few drawings published in the linked thread which will be my primary target to start working toward a functional model.

Filter and surrounding supporting circuits:
Image

"Opamp" subcircuit:
Image

I don't know enough about the technicals of NMOS IC design to say anything for certain now but as far as simulation accuracy, to my knowledge we can get close enough ignoring on-resistance and various other minor properties of the IC itself (tempco, etc.)

I'll be able to say for certain after I publish a working model netlist.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Progress so far:
https://sourceforge.net/p/sidplay-resid ... r/residfp/

You can see some progress in Filter6581.h and Integrator.h has already been made by the author(s), from what I can see they've only covered non-linear charge current using a naive symmetrical approximation. The approximation is rendered into a look-up table and the whole thing is computed in integer/fixed-point using table lookups.

I'm still examining the code to find how they've accounted for the non-linear amp block's "signal path saturation" effect. From what I can see the amp blocks are assumed to be completely linear, but here is the relevant quote:
* Provided a reasonably high input impedance and a reasonably low output
* impedance, the "op-amp" can be modeled as a voltage transfer function
* mapping input voltage to output voltage.
I understand this to mean "we can use a simple approximation/table to go output = f(input)". I agree 100%... mostly, although it's questionable within which frequency range that's typically not an issue until you get up into high MHz.

The voltage follower input is linear but the inverting amp and feedback buffer (also inverting) are not even close to linear. This is what I would call "signal path saturation", that is in other words non-linear distortion applied directly to the signal itself. The amps are class-A with buffered inputs and that NMOS transistors are inherently very non-linear and have a very narrow "linear" (SCARE QUOTES!!) operating region.

Here is such an NMOS inverter/amp circuit simulated in ltspice:
Image
Image

This circuit schematic/netlist use the guesses for resistance values from the schematics posted above. At a glance the results seem accurate with ltspice's naive NMOS model but it would be great if anyone could tell me how much an idiot I am and fix them to be as accurate as possible.

Everything I post in this thread can be considered GPL v2 only (not GPL v3).

ltspice/netlist here:
http://xhip.net/sid/sidamp_r0.asc
http://xhip.net/sid/sidamp_r0.net

So since this occurs in addition to the "variable resistor" circuit's non-linear behavior, this is a crucial element of the timbre of the filter if not the single most important aspect of the entire circuit.

The analog signal path uses these amps several times, so this distortion is applied over and over in multiple places both inside the filter integrators and directly on the dry signal.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

This is far from "perfect" but this is a good first step. Just for fun, here is a look at two of these amps (very poor approximation so far, all based on 2nd hand guesses) running in series applied to a "triangle" (linear) waveform:

Image

So if you were to send a linear ramp/triangle into the EXT input this is approximately what I would expect you should get from the filter itself with cutoff = infinite. I may move on to approximating the whole signal path next including the mixer and output amplifier before implementing the filter core itself.

Note the range of the input waveform is 6v to 12v which is approximately what you'd get from the waveform DAC since the resistor for bit 12 is tied positive (+6v offset.)
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

:party:
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

Output approximately equals vader?

Image

Insert imperial march chiptune.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

+1 for Vader....following...

Post

It seems the opamp non-linearity is applied naively via a table with interpolation.

This table is found in FilterModelConfig.cpp. From my initial glancing examination it appears the table is input/ouput pairs.

Their output does not match the simulation, unsurprisingly, because the actual circuit is influenced by the properties of the transistors as well as the true resistance values at play. The overall shape of the measured values however is near identical. The "zero point" where input == output is in their measurement 4.5v, while in simulation it is 7.5v.

This is likely partly because of the measurement they used applied to the full circuit rather than a complete isolated amp, so the parts attached to the filter capacitors wrapping the amp (LP: amp 3) that they measured likely produced a negative offset somehow. Nonetheless I'm still surprised by the difference of +3v between an isolated amp vs. their measured values from the capacitor attached to a real chip. If they provide documentation somewhere (?) about exactly how they came up with these measured values that would help to identify the source of the difference.

So for now this doesn't lead anywhere productive on its own, although it does confirm the operation of the amp under simulation and provides some extra info about a +/-3v offset introduced at some point.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

After a bit more experimentation I suspect the amp design is extremely finicky. It looks like I'm able to hand-tweak nearly any selection of simulation FET models to work in the circuit by adjusting the resistances, but in most cases it requires adding parts that aren't in the existing schematics. So I'm a bit caught here between "hmm, I think I might have no idea what I'm doing" and "maybe there are very important parts of the circuit missing or incorrect in the schematics?".

A major bit of evidence to support that the issue is a combination of those two factors is the fact that the self-biasing feedback transistor in the amp circuit affects gain combined with the fact the amp must have >1 gain in order to operate correctly in the feedback-based circuits it's used in. So while the naive NMOS model produces a sort-of expected result I don't think there is any way it's accurate enough to actually work in the filter.

Some things I'm 90% certain about at this point:
  • The "vader" saturation characteristic is roughly accurate with any class-A amplifier: rounded top, expo/pointy or clipped bottom. So while currently accuracy is absolutely awful the results are very roughly as expected. That's a good thing, I guess.
  • There are missing or incorrect values in the amp circuit which are essential to its proper operation under simulation. It may be that fine-tuning the properties of each individual NMOS transistor is absolutely crucial to get the circuit to work accurately.
  • If I'm correct in my guess that these circuits are extremely finicky, it may be easier to roughly approximate them using alternative circuits.
So it seems the 90% of the information is missing that crucial remaining 90%. Not surprising.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

More progress (if you'd call it that):
Image

http://xhip.net/sid/badsid.mp3
( http://xhip.net/sid/badsid.flac )

Now the problem is that in order to get the amps all neatly biased and functional, I ended up making them too damn linear :) You can see they're not "linear" obviously, but this is not the radical sort of distortion I'd expect. Also the high-pass amp is oscillating like crazy making the simulation run at the speed of a plastic bag flying against the wind.

It made a sound though. That's a good sign I'm not wasting my time. Although honestly speaking creating such a filter is not exactly any more complicated than drawing random lines with a crayon.

Nothing special yet, but I can set the filter (as inaccurate as it may be at this point) to self-oscillate since I can set the feedback resistor to whatever I like. The input signal can also be ten billion volts if so desired.

Now with bypass capacitor in the amp it doesn't oscillate and the simulation runs at about 30% real-time.

http://xhip.net/sid/badsid2.mp3
( http://xhip.net/sid/badsid2.flac )
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote: Fri Jun 07, 2019 4:42 am Output approximately equals vader?

Image

Insert imperial march chiptune.
:lol:
:ud:

Post

Vaderoid function!

Post

Did you know Vader’s helmet was designed from an inverted flower pot George Lucas found in an Oakland flea market one weekend?

True story.

Post

realtrance wrote: Fri Jun 07, 2019 5:05 pm Did you know Vader’s helmet was designed from an inverted flower pot George Lucas found in an Oakland flea market one weekend?

True story.
that wouldn't be my first guess

Post

i've never really thought about it, but i'm curious as to how one would accurately model the SID chip when pretty much every one of them sounds different from one another (6581/8580 aside, even 6581 of the same rev with same/close production dates). never bothered comparing them too closely, but i've tested/sold almost a hundred SIDs over the years and found a very wide range of variance among them. maybe all due to the filters, not sure how close they sound without that in play.

would have been a great idea if i had recorded each one of them playing back the same SID tune off the same C64, but of course i never think to do stuff like that when i have the opportunity.

Post

That's a fallacy though, although I admit it's easy to get distracted or hung up on it. It was often brought up "how can you accurately emulate an analog synthesizer when every one sounds different?"

The differences are due to random variations. While any two grapes may taste different you can certainly create a synthetic "grape flavor" and have people judge its accuracy. You can also look at the chemistry of the origin of the flavor and variation between real grape varieties and how they interact with the "taste buds" to create the sensation of distinct flavors.

In understanding that you can accurately model the flavor using a synthetic chemical. The chemical flavor may itself be distinct just like any two varieties of grape (or even the same variety during different seasons or from two vines in the same field!) Despite that the accuracy of the flavor is determined not by whether it matches any particular instance but rather whether it falls completely within the bounds of variation among members of the group. At such a point you have to question: what is the difference between "grape extract" and "synthetic grape flavor" when you ignore whether it came from a grape? If they're chemically identical the answer is: "none."

So in short: the way we accurately model such a thing is to identify the range of variations and create a model that sits within them. Since these variations are impossible to control in nature (a physical SID chip with real transistors) and they are possible to control in our model, we can go even a step further and adjust the parameters of the model to approximate or even match any particular instance.

An accurate complete spice model of all modules in my opinion would be far beyond anything else anyone has created to date. Creating such a thing is not my goal: taking the first steps is.

Check out my boot-prints in the mud back there.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post Reply

Return to “Instruments”