Skip to content

Triangle Waveform

Leandro Nini edited this page Oct 13, 2022 · 3 revisions

The upper 12 bits of the oscillator run from 0 to $fff, at a speed dependent on the frequency, producing a sawtooth waveform. A triangle waveform is obtained by XORing the bits with the oscillator's MSB, in this way during the second half of the wave, when the MSB is 1, the bits are inverted forming the descending ramp of the triangle. As the result is only 11 bits the value is shifted to the left and the LSB is set to 0, thus halving the resolution but retaining full amplitude. It is possible to apply a ring modulation effect, controlled by Bit 2 of the Control Register, so the MSB is XORed with the (inverted) MSB of the preceeding voice producing non-harmonic overtones. This is the XOR logic applied to the first eleven bits of the oscillator's output:

The output results from the following expression:

  • Tri_bitX = ¬((TriXOR ∧ bitX) ∨ ¬(TriXOR ∨ bitX)) = TriXOR ⊕ bitX

The xor selector is generated by the following circuit:

The output results from the following expression:

  • TriXOR = ¬(a ∨ Saw ∨ (b ∧ bit23)) = ¬Saw ∧ ¬a ∧ ¬(b ∧ bit23)

where:

  • a = ¬(b ∨ bit23)
  • b = ¬(V23 ∨ ¬Ring) = ¬V23 ∧ Ring

(V23 is the 23rd bit of the ring modulating voice's oscillator)

resulting in:

  • TriXOR = ¬Saw ∧ (b ∨ bit23) ∧ ¬(b ∧ bit23) = ¬Saw ∧ (b ⊕ bit23) = ¬Saw ∧ ((¬V23 ∧ Ring) ⊕ bit23)

So TriXOR is high for the following combination:

S b23 V23 R
0 1 0 0
0 1 1 0
0 0 0 1
0 1 1 1

In other words if the sawtooth waveform is not selected the oscillator bits are inverted when ring modulation is disabled and the MSB is 1 or when ring modulation is enabled and the two MSBs, from the current and the modulating voices, are equal. When the sawtooth is selected the XORing is disabled as the same output is used for both waveforms.

On the 8580 the triangle bits are quite different, taking up more space with a couple more transistors:

There is only one logical port surrounded by a few inverters. The result is the same but the intermediate (inverted) value is latched at sid_clk2.

  • /Tri_bitX = ¬((¬bitX ∧ TriXOR) ∨ (bitX ∧ ¬TriXOR)) = ¬(TriXOR ⊕ bitX)

There is also a difference in how the sawtooth's MSB is obtained:

In the 6581 the MSB of the oscillator, used as input for the triangle xor logic and the pulse adder last bit, is connected directly to the waveform selector, while in the 8580 it is instead latched at sid_clk2 before being forwarded to the selector.

This has an implication on combined waveforms: in the 6581 if the sawtooth MSB is pulled down it might affect the oscillator's adder driving the top bit low.