DSP Simulator (TMS320C54x)


This little program is a working, though incomplete, implementation of the Texas Instruments TMS320C54x C interface, and a digital modem as an example of its use. The TMS320C54x is the Digital Signal Processor (DSP from now on) used in the ECE320: DSP lab class at UIUC.

Whew! You made it past the acronyms. I'll elaborate, assuming you know what DSP is. I took ECE320 at UIUC, a course intended to give real world experience with DSPs. We wrote small assembly and/or C programs for the 54x DSP - FIR filters, IIR filters, Fourier transforms, that kind of dinky crap. All this code we wrote was specific to the 54x processor, and therefore, in order to test it, we had to have access to a 54x processor. Having to go all the way to lab to test my code on their DSPs offended me as a lazy bum.

That's where DSPSim comes in. As the name implies, it simulates the 54x DSP by implementing the C API (which is really only a bunch of functions which give access to the machine instructions of the DSP). I used it to test my ECE320 final project (a digital modem).


To use DSPSim, it helps to know how to write C programs for the 54x DSP. Very briefly, you communicate with the DSP via the WaitAudio() call. Your program calls WaitAudio() to get 64 bytes of input from up to 2 input channels, processes it, optionally sticks 64 bytes of data in up to 6 output channels, and repeats. All DSPSim does is emulate the WaitAudio() call to read and write the data using regular files instead of a DSP.

As long as you don't use any non-standard libraries or try to do file IO, any C program you write for DSPSim should theoretically work for the 54x. It could also work the other way, but I haven't yet implemented all the C functions available on the 54x. I probably never will, but they're not too hard to add yourself.


In a DSP lab, you usually watch the output on an oscilloscope. On your home computer, you'll have to settle for a less real-time approach. All the data input and output from your DSP programs are saved in text files called "outN.dat" and "inN.dat", where N is the channel number. You can run your program and analyze all the data generated by reading these files.

I wrote some MATLAB (well, Octave, actually) scripts for reading the data output by your DSP program and graphing it for you.


For my ECE320 final project, I co-wrote a digital modem for the 54x DSP with Andi Susanto. The modem consists of a transmitter and a receiver. In the lab, you type characters at the transmitter, causing some annoying noise to come out of the speakers. The noise then picked up by a microphone and processed by the receiver, and the correct characters show up on the receivers screen.

At home, the same basic concept applies. Run the receiver in one terminal and the transmitter in the other. Instead of speakers and a microphone, they simply communicate through files.

You can also look at some output of my DSPSim-powered modem as graphed by octave.

For those of you who know communications, this is the output of the PLL (Phase-Locked Loop) in the receiver. The green line is the signal as received. The red line is the signal after being locked onto and lowpass filtered.


You can download the whole shabang here, or browse the source here.