MAKING FRIENDS WITH A FIELD PROGRAMMABLE GATE ARRAY
you enter both simple and complex designs. With the
symbol editor, you can view, create, and edit symbols
that represent designs.
Those symbols can be used in schematics created
with the graphic editor. The graphic editor also allows
you to open an OrCAD schematic file and use it as your
design. You can choose from libraries containing over
300 Altera-provided macrofunctions and primitives, or
use your own custom macrofunction symbols that represent other design files, including other graphic editor
files. A macrofunction is just a circuit that has been compiled and given a symbol of its own. After you get the
BCD counter working, you could turn it into a macrofunction with its own symbol and use that single symbol
in a whole new circuit.
There is a final method of programming your FPGA
chip in the MAX+PLUS software. You can use waveform
files. A waveform file will allow you to specify an input
waveform and a required output waveform, and then
have the software program your chip for you. I haven't
tried this yet but it sounds interesting.
When you receive your development board, you
should follow all the directions and make sure you can
program it with the sample program provided in the
instruction manual. It's called Majority Vote and is about
as simple as it gets. Use this to get used to placing parts
on the graphic editor screen and connecting them with
wires. Take some time to explore the built-in part
libraries, too. The help file is fairly extensive but I didn't
see where they mentioned which chips and functions
were in which libraries. Neither do they bother to give any
data on any of the chips represented. I guess it would be
way too much information. But, if you are like me, you
already have an extensive datasheet collection on your
Building the Counter
Though some other development boards do come
with LEDs, switches, and other discrete components for
testing, the one from HVW does not. That is one of the
things I like about it. You can plug the board into a breadboard and have complete flexibility over your design. So,
we'll have to add a couple things to complete the counter circuit. You'll need 11, 150 ohm, 1/4 watt resistors.
You'll need a common anode, seven-segment LED
numeric display. Finally, you'll need the breadboard,
power supply, and some method for triggering the
A seven-segment display is an LED display made up
of seven independent LEDs arranged to form a figure
eight. In a common anode display, all the anodes of each
LED are tied together so that you only need one positive
supply input. In order to turn on one LED in the display,
you supply a logic low on its corresponding input line. As
in Figure 2, the input lines are labeled "A" through "G."
Some displays have a decimal point available. Some
have other things available. We'll only use the A through
G inputs. Common cathode displays work the same way
except all the cathodes of each LED are tied together
and you must supply logic high to turn on the display
LEDs. In any case, if you turn on the correct LEDs at the
same time, you can form numbers from 0 to 9.
You can use a single resistor on the common anode
pin to limit the current, if you wish. However, the LED display will be brighter when fewer segments are lit (like in
the number 1), than it is when more segments are lit (like
in the number 8).
When I built this circuit the first time, I used a light-detecting transistor to construct something similar to a
barcode reader to trigger the count. You can use anything from a continuous pulse to a debounced switch.
On this circuit, I used a debounced switch built from two
inverters as shown in the diagram. Yes, I used a discrete
chip instead of putting the circuit into the FPGA.
One reason is that I would most likely want to trigger
the counter from outside the FPGA.
The other reason is that I could never get the
debounce portion of the circuit to compile without errors.
Apparently, only a tri-state buffer must drive the node —
the wire carrying a signal between two logical components. In this case, a primitive — the input pin from the
switch — drives it. The help file suggests placing a tri-state buffer between the input and the wire. Since the
debouncing circuit loops back on itself so often, we'd
need several tri-state buffers. It just seemed like a big
waste of time to add all that when I'll be better served by
using an outside trigger source.
Examine the regular schematic to see the chips and
The first integrated circuit to look at is the 7490
Decade and Binary Counter. It contains four master-slave
flip-flops and additional gating to provide a divide-by-two
counter and a three-stage binary counter. The complete
datasheet can be downloaded from Fairchild
Semiconductor ( www.fairchildsemi.com). The counter chip, with output A wired to input B, counts in binary
from zero to nine and then recycles. The second integrated circuit is the 7447 BCD to Seven-Segment
Decoder/Driver. It contains several logic gates wired
together so that it brings in a four bit binary number and
decodes it to turn on the correct output lines to form a
Figure 1. FPGA development board.
NUTS & VOLTS