Digital Waveshape Generator

Introduction

The Digital Waveshape Generator (DWG) began in 1980 as my senior project. I was studying electrical engineering at UAH and graduated with a BSE degree in 1981. I had a strong interest in music synthesizers as I was a trained classical pianist and a fan of progressive rock music. I intended this DWG to be the core of a single voice in a synthesizer. Here is a block diagram of the DWG. My design worked in the sense that it could produce arbitrary wave shapes at a programmable frequency; however, limitations of the hardware avalable in 1980 prevented it from matching the musical scale. I would have needed a master clock frequency of 3.9 GHz which even today is unmanageable. Therefore, I did not build a music synthesizer around it. Here is a block diagram of the original design. (click to see full size.)
My interest was rekindled recently after learning about Direct Digital Synthesis (DDS). I realized a DDS could solve my tuning problem. I found a way to merge my design and a DDS by using my waveshape RAM as the lookup table (LUT) of a DDS. Here is a block diagram of the new design. This is a multi-channel DWG that amortizes the additional hardware required to implement a DDS over multiple channels. The number of channels is controlled by the sequencer. Here is a block diagram of the new design. (click to see full size.)
This design is pipelined. Here is a timing diagram. (click to see full size.)
The design is controlled by a programmable microsequencer implemented with two Nx8 Dual-Port RAMs (where N >= 16) and two 8-bit latches (e.g. 74HC374). Four of the latch outputs are fed back to the DPRAM as address 0-3. The remaining address lines are not used. The sequencer controls whether the system generates 4 channels with 256 samples per cycle, 8 channels with 128 samples, or 16 channels with 64 samples. Here is a diagram of the sequencer. (click to see full size.)

Compromises

While the DDS design solves the problem of matching the chromatic scale, it does so by sacrificing resolution at higher frequencies. For example, at C8 (the highest key on an 88-key keyboard) the phase adjustment (addend) is 1797877 yielding only 5.6 samples per cycle, far less than the goal of 256 samples per cycle. I have not determined the impact this will have on the sound.

With a sample rate of 10 Mhz, the highest note with a sample rate greater than or equal to 256 is F2. Each doubling of the clock frequency raises this by an octave; however, the master clock is the sample rate multiplied by the number of channels, so this strategy quickly becomes untennable using 74HC series devices. If 8 74HCT283 devices are used for the 32-bit adder, the design probably could not support a master clock frequency higher than 20 MHz (50 nanosecond cycle time).

The devices used throughout the design are dual-port RAMs (DPRAMs) except the phase accumulator RAM. This is for convenience to allow a microprocessor to modify the memories without a lot of bus control logic.

The phase adjustment (addend) memory and phase accumulator memory could be as small as 16xN but no such devices are currently in production. The 74LS219 was a 16x4 RAM but an HC/HCT version of this device was never produced. The 74HCT670 4x4 register file could be used to support a mimum of 4 channels.

One alternative would be to implement the entire design excluding the DAC in a Field Programmable Gate Array (FPGA). For example, the Lattice iCE40UP5K family prices range from $5 to $8 and have enough internal RAM to support as many as 16 channels. There is probably enough RAM to allow multiple waveshapes in memory and select a different waveshape based on the desired pitch. Here is a design of a single channel DDS. Click on an image to download a full resolution TIFF file.

A summing network would need to be pipelined to account for the delays in a tree of adders. Here is a design of a 16-channel pipelined summing network. Click on an image to download a full resolution TIFF file.

Resources

I created a simple Java program to help evaluate the performance of various combinations of phase accumulator width and master clock frequency. Here is the code.
I settled on a phase accumulator width of 32 bits and a clock frequency of 10 MHz. The actual frequency will be 80 MHz and various timing signals will be derived from that with 125 nanosecond granularity, but the rate the output is updated is 10 MHz. This yields a maximum variance of 0.0039% and an average variance of 0.00036%, neither of which should be detectable by the human ear. Here is the analysis for this combination.

Note Position Ideal
Frequency
Actual
Frequency
Variance Phase
Adjustment
Sample
Rate
A0 0 27.500000 27.499627 0.000014 11811 846.668360
A0# 1 29.135235 29.134098 0.000039 12513 799.168864
B0 2 30.867706 30.868687 0.000032 13258 754.261578
C1 3 32.703196 32.703392 0.000006 14046 711.946462
C1# 4 34.647829 34.647528 0.000009 14881 671.997850
D1 5 36.708096 36.708079 0.000000 15766 634.276291
D1# 6 38.890873 38.892031 0.000030 16704 598.659004
E1 7 41.203445 41.204039 0.000014 17697 565.067526
F1 8 43.653529 43.653417 0.000003 18749 533.361779
F1# 9 46.249303 46.249479 0.000004 19864 503.423278
G1 10 48.999429 48.999209 0.000005 21045 475.172250
G1# 11 51.913087 51.914249 0.000022 22297 448.490828
A1 12 55.000000 54.999255 0.000014 23622 423.334180
A1# 13 58.270470 58.270525 0.000001 25027 399.568466
B1 14 61.735413 61.735045 0.000006 26515 377.145012
C2 15 65.406391 65.406784 0.000006 28092 355.973231
C2# 16 69.295658 69.295056 0.000009 29762 335.998925
D2 17 73.416192 73.416159 0.000000 31532 317.138145
D2# 18 77.781746 77.781733 0.000000 33407 299.338462
E2 19 82.406889 82.405750 0.000014 35393 282.541746
F2 20 87.307058 87.306835 0.000003 37498 266.680890
F2# 21 92.498606 92.498958 0.000004 39728 251.711639
G2 22 97.998859 97.998418 0.000005 42090 237.586125
G2# 23 103.826174 103.826169 0.000000 44593 224.250443
A2 24 110.000000 110.000838 0.000008 47245 211.662610
A2# 25 116.540940 116.541050 0.000001 50054 199.784233
B2 26 123.470825 123.470090 0.000006 53030 188.572506
C3 27 130.812783 130.813569 0.000006 56184 177.986615
C3# 28 138.591315 138.592441 0.000008 59525 167.996640
D3 29 146.832384 146.832317 0.000000 63064 158.569073
D3# 30 155.563492 155.563466 0.000000 66814 149.669231
E3 31 164.813778 164.813828 0.000000 70787 141.268877
F3 32 174.614116 174.613670 0.000003 74996 133.340445
F3# 33 184.997211 184.997916 0.000004 79456 125.855820
G3 34 195.997718 195.996836 0.000005 84180 118.793062
G3# 35 207.652349 207.652338 0.000000 89186 112.125221
A3 36 220.000000 219.999347 0.000003 94489 105.832425
A3# 37 233.081881 233.082101 0.000001 100108 99.892117
B3 38 246.941651 246.942509 0.000003 106061 94.285364
C4 39 261.625565 261.624809 0.000003 112367 88.994100
C4# 40 277.182631 277.182553 0.000000 119049 83.999026
D4 41 293.664768 293.664634 0.000000 126128 79.284536
D4# 42 311.126984 311.126933 0.000000 133628 74.834615
E4 43 329.627557 329.627655 0.000000 141574 70.634439
F4 44 349.228231 349.227339 0.000003 149992 66.670222
F4# 45 369.994423 369.993504 0.000002 158911 62.928306
G4 46 391.995436 391.996000 0.000001 168361 59.396178
G4# 47 415.304698 415.304676 0.000000 178372 56.062611
A4 48 440.000000 440.001022 0.000002 188979 52.915932
A4# 49 466.163762 466.164201 0.000001 200216 49.946058
B4 50 493.883301 493.882690 0.000001 212121 47.142904
C5 51 523.251131 523.251947 0.000002 224735 44.496852
C5# 52 554.365262 554.365106 0.000000 238098 41.999513
D5 53 587.329536 587.329268 0.000000 252256 39.642268
D5# 54 622.253967 622.253865 0.000000 267256 37.417308
E5 55 659.255114 659.255311 0.000000 283148 35.317219
F5 56 698.456463 698.457006 0.000001 299985 33.335000
F5# 57 739.988845 739.989337 0.000001 317823 31.464054
G5 58 783.990872 783.992000 0.000001 336722 29.698089
G5# 59 830.609395 830.609351 0.000000 356744 28.031305
A5 60 880.000000 879.999716 0.000000 377957 26.458036
A5# 61 932.327523 932.328403 0.000001 400432 24.973029
B5 62 987.766603 987.767708 0.000001 424243 23.571397
C6 63 1046.502261 1046.501566 0.000001 449469 22.248475
C6# 64 1108.730524 1108.730212 0.000000 476196 20.999756
D6 65 1174.659072 1174.658537 0.000000 504512 19.821134
D6# 66 1244.507935 1244.507730 0.000000 534512 18.708654
E6 67 1318.510228 1318.510622 0.000000 566296 17.658610
F6 68 1396.912926 1396.914013 0.000001 599970 16.667500
F6# 69 1479.977691 1479.978673 0.000001 635646 15.732027
G6 70 1567.981744 1567.981672 0.000000 673443 14.849067
G6# 71 1661.218790 1661.218703 0.000000 713488 14.015653
A6 72 1760.000000 1759.999432 0.000000 755914 13.229018
A6# 73 1864.655046 1864.654478 0.000000 800863 12.486530
B6 74 1975.533205 1975.533087 0.000000 848485 11.785712
C7 75 2093.004522 2093.005460 0.000000 898939 11.124225
C7# 76 2217.461048 2217.460424 0.000000 952392 10.499878
D7 77 2349.318143 2349.317074 0.000000 1009024 9.910567
D7# 78 2489.015870 2489.015460 0.000000 1069024 9.354327
E7 79 2637.020455 2637.021244 0.000000 1132592 8.829305
F7 80 2793.825851 2793.825697 0.000000 1199939 8.333757
F7# 81 2959.955382 2959.955018 0.000000 1271291 7.866020
G7 82 3135.963488 3135.963343 0.000000 1346886 7.424533
G7# 83 3322.437581 3322.437406 0.000000 1426976 7.007826
A7 84 3520.000000 3519.998863 0.000000 1511828 6.614509
A7# 85 3729.310092 3729.308955 0.000000 1601726 6.243265
B7 86 3951.066410 3951.066174 0.000000 1696970 5.892856
C8 87 4186.009045 4186.008591 0.000000 1797877 5.562116

max variance: 0.000039 at position 1
average variance: 0.0000036
The variances listed are actual, not percentages.