Microphone controller

The microphone controller handles the low-level details of receiving sound samples from the DE2-115's microphone input. The microphone controller is implemented in microphone.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).

microphone_command and microphone_response implement the standard I/O protocol. There are no command parameters. The response parameter is microphone_sample, which contains the most recent 32-bit sound sample received by the microphone.

The microphone controller takes input from the microphone at an 8 KHz sampling rate. A new sample overwrites the current sample, even if the E100 has not yet read the current sample. After the E100 reads the current sample via the I/O protocol, the microphone controller will not respond again until there is a new sample from the microphone.

On the DE2-115 board, plug the microphone into the pink MIC connector.

ase100 simulates the microphone 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 reads microphone samples from the computer's microphone. Use kmix to enable the microphone jack that your microphone is plugged into, or to adjust the microphone sensitivity (screenshot 1, screenshot 2).

Many computers run ase100 too slowly to read sound in real time. In this case, you can direct ase100 to read microphone samples from a WAV file. The WAV file must be in PCM format, with 32-bit, mono samples at an 8 KHz sampling rate (such as the concert A file given in the handout on digital audio). You can use the sox program on Linux to convert a file to the right format. For example, run the following command to convert file1.wav to file2.wav:

sox file1.wav -4 -s -c 1 -r 8000 file2.wav

Lab 7 task

Write a device driver for the microphone controller that a program can call to read a sound sample from the microphone controller. Then, write a test program that continuously reads the samples from the microphone and displays the minimum and maximum values for the sound samples it has received from the microphone onto the hexdigits.

Optional: If one of your teammates has written a driver for the speaker, try sending the values you read from the microphone to the speaker.