As shown in Figure 2, the module has four inputs. There are clock and reset inputs, plus a four-bit input to
select one of 16 tones and an additional input to silence the audio output. There is a single output signal,
which is intended to be connected to some form of audio output device.
clk clock signal, 50 MHz from oscillator
rst reset signal
note[3:0] frequency select
hush stop toggling; be silent
speaker audio output
The module must drive the speaker output to generate a square wave at the frequencies specified in the next
section. The speaker output must stop toggling in response to the assertion of the hush signal. The hush
signal is to be treated as an active low enable signal for the speaker output. Assertion of hush should
simply disable future transitions – it should not cause the speaker signal to change value. The reset signal,
on the other hand, certainly disables transitions on the speaker output, but it also forces the speaker output
to a known initial value.
Designing the Module
There are many different techniques for creating audio output. The simplest technique for creating
elementary tones is to generate a periodic waveform and then send that waveform to a speaker. For
example, if you take a function generator (available in most analog laboratory courses) and connect the
output to a speaker, you can actually hear the output when it is in the range of human hearing. This range
is approximately 20 Hz to 20,000 Hz. With the function generator, you can control:
• The frequency – which your brain interprets as the pitch, or note heard.
• The amplitude – which your brain interprets as the volume, or loudness heard.
• The waveshape – which your brain interprets as a timbral characteristic, or “instrument” heard.
You are probably familiar with frequency and amplitude. The waveshape changes the quality of the note
you hear, because the waveshape changes the number and amplitude of harmonics associated with the
fundamental frequency of the waveform. A sinusoidal waveshape gives a perfect tone; that is, if you were
to look at the Fourier transform of the time domain signal, you would see a spike at the fundamental
frequency of the waveform itself, and no other frequency components. On the other hand, if you were to
look at the Fourier transform of a square, saw tooth, or triangle waveshape, you would still see the largest
spike at the fundamental frequency of the waveform, but you would see other, smaller spikes at multiples
of the fundamental frequency. These are called overtones, or harmonics.
Without the aid of digital to analog converters or other analog circuitry, it is cumbersome to produce
anything other than a square wave with digital logic, so we will create square waves as output. Square
waves are simple to create; you can periodically toggle a signal, and then send that signal to a speaker to
create audio output. For the amplitude parameter, we will simply use the output of the FPGA device
directly, with no provision for controlling the amplitude.
The final parameter is the frequency parameter. In designs that only require a buzzer, such as an alarm, any
audible frequency will suffice. In this lab, however, the frequency is important since we will later use the
resulting tones to play music that was intended for a keyboard instrument, such as a piano. Keyboard
instruments are tuned using what is called the equal tempered music scale. In short, what this means is that
the frequency of each note is related to the frequency of the adjacent notes by a constant multiple. The
result is that music can be played equally well, or equally badly, in any key. Figure 3 shows a keyboard of
sixteen notes. The piano design will be capable of playing any note on this keyboard.