sAGAs

So, I’m working on a new FPGA project, using Milkymist, instead of working on Joaf.

Why drop Joaf? Well, the only reason I was doing Joaf was because I thought it would be fun. There was no plausible “market” for it (the possible, but implausible, one I could think of was that it could become a platform for demosceners to play with). Having done as much of the design as I did, I got a lot of the fun out of it, and actually producing it isn’t necessarily that much more fun. It would be nice to actually have working hardware, but if another project comes along that has some actual utility, it probably makes more sense to move onto that.

That project is called “sAGAs”.

sAGAs is an FPGA (or ASIC or whatever) component for performing audio synthesis.

It is capable of many modes of synthesis: PCM waveforms, additive, band-limited analog, granular, and FM.

It’s not going to change the world or anything, but there might actually be a market for it: a boutique “analog” synthesizer that’s fully, deeply programmable.

To make this work, probably in many cases you would want to synthesize at a higher frequency and downsample to reduce aliasing. These means making it run very fast is useful. When running at 44.1Khz, therefore, it should be able to produce an absurdly high number of voices (leaving headroom for oversampling at 4x or whatever).

Back-of-the-envelope calculations suggest a single sAGAs core can compute about 9000 mono sine waves or mono PCM-sampled voices per second with 44.1Khz output. However, the PCM-sampled voices would be RAM bandwidth limited (if every wave is independent, it requires 6Gb/s), and it may not be possible for the soft CPU to feed all this data fast enough. In practice, if the waves are independent, you’re actually limited to about 2000 voices/waves per second, since the mono-to-stereo mixer will become the gating factor. The higher numbers are achieved by mixing together multiple waves into a single mono sound. For example, additive synthesis with 128 partials (harmonics) would allow 70 mono voices, thus barely touching the mono-to-stereo mixer’s limits. (70 isn’t absurdly large, but additive synthesis doesn’t require oversampling, as you simply don’t mix in the partials that exceed 22Khz.)

You can also throw in some filter effects using an IIR biquad–basically each cycle the waveform-generating unit can either produce a pair of waveforms, or perform an IIR biquad. So if you split half and half, you can do about 2000 PCM waves, each with one biquad applied, and be running every functional unit at 100%.

This is all using one sAGAs core. The FPGA in the Milkymist easily has room for two, and might even have room for three (each sAGAs core uses 14 “DSP” multipliers, of 58 total). The sweet spot is probably two plus an additional coprocessor dedicated to generating the command stream for generating the waves, since the soft CPU is going to have trouble keeping up.

One goal would be to create a standalone sAGAs device (for now, using the Milkymist hardware), which could be used as a low-latency programmable synthesizer and possibly also be designed for monome input, picking up the work I was doing on sGAR.

Why do this on an FPGA? Partly to scratch my FPGA itch that Joaf was for. An alternative, I could use the Beagleboard; the OMAP DSP is pretty powerful (eight 16×16 multiplies every cycle, clocked at 1Ghz; dunno what fraction of those you could achieve, though, but that’s a potential 8B/sec, where one sAGAs core delivers ~1B/sec). But a cool thing about sAGAs on Milkymist is that the whole system would be open source; although the FPGA itself isn’t, you can build it on any FPGA with 18×18 multipliers, or even make an ASIC. With Beagleboard you’re locked into that DSP.

Or it could just be on an x86, like a laptop. sAGAs is computing 4 interpolated wavetable lookups every cycle at 100Mhz. On a PC, you’d probably need around 15 instructions to do one interpolated lookup (and extra stuff); with a 2Ghz processor and 2 instructions/cycle that gives you about 2.6 interpolated lookups at 100Mhz — using only one core. For sine waves, you can compute them by rotating a 2D point; this costs 4 multiply-adds plus some setup, so call it 10 cycles/sample–but you can use SIMD to compute 4 simultaneous ones. That brings you to 16 sine waves per 100Mhz cycle on one core. Of course the x86 isn’t open source, but it’s ubiquitous. (Then again, we’re not comparing equal-cost chips. I’m not sure what that would be. The highest-end Spartan-6 offers 180 multipliers, so on one of those we could have 12 sAGAs cores for 48 sine waves per 100Mhz cycle. Might hit memory bandwidth limits there, though. The highest-end Virtex-6 has 864. The forthcoming Xilinx next gen will be many more.)

Regardless, I think I like the idea of top-to-bottom open-source hardware, like the monome. A monome-philosophy programmable synth would be awesome, I think. So that’s why I’m going with the FPGA.

Over the next few posts I’ll describe how sAGAs works, and the many different synthesis modes it supports; to whet your appetite, here is an incomplete circuit diagram for the core mono-synthesizer/biquad-filter.

3 comments ↓

#1 Skyler Saleh on 05.09.12 at 10:53 pm

What FPGA are you using?

#2 Skyler Saleh on 05.09.12 at 11:06 pm

Sorry, I had never heard of milkymist before, and didn’t realize that was the fpga…

Did you design your own SDRAM controller or are you using a controller that someone else designed?

#3 sean on 05.10.12 at 12:22 am

Milkymist is the system-on-a-chip design based on the Xilinx Spartan-6. See my previous post for a little bit, and see here for all the details about Milkymist, including info about the DDR SDRAM controller.