The speaker controller handles the low-level details of producing audio output on the DE2-115 and provides a simple interface for the E100 to send samples to the DE2-115 line out connector. The speaker controller is implemented in speaker.v. You will also need i2c_config.v, which configures the DE2-115's audio codec chip, the Wolfson WM8731 codec (codec stands for encoder/decoder).
See the handout on digital audio to learn how samples values correspond to sound, and how to extract sound samples from standard audio files.
speaker_command and speaker_response implement the standard I/O protocol. The command parameter is speaker_sample. There are no response parameters.
Using the standard I/O protocol, an E100 program sends a sequence of speaker_sample values to the speaker controller. The speaker controller plays these samples at an 8 KHz sampling rate. If the E100 program sends samples more quickly than 8 KHz, the speaker controller will delay the response to a new sample until it has played the last sample. If the E100 program sends samples slower than 8 KHz, the speaker controller will generate periods of silence between samples.
On the DE2-115 board, plug the headset's speaker cable into the green LINE OUT connector.
ase100 simulates the speaker controller accurately enough for you to test your device driver and to run assembly-language programs. If ase100 can access your computer's audio device, it outputs sound to the computer's speakers.
Many computers run ase100 too slowly to produce sound in real time. In this case, you can click the Save speaker button to save the samples that have been sent to the speaker as a WAV file, then play back the WAV file on your computer.
Write a device driver for the speaker controller that a program can call to send a sound sample to the sound controller. Then, write a test program that repeatedly sends a set of samples to the speaker, looping when it reaches the end of the set. The set of samples should be stored in an array, with the length of the array specified by another variable. Remember that sample values are in the range [-231, 231-1].