aker

BUNNIE’S WORKBENCH

www.makezine.com/01/bunnie

FPGA Primer

An FPGA (Field Programmable Gate Array) is an integrated circuit found in all kinds of hardware products, from IP routers to MP3 players. They are used to implement highly integrated, custom digital circuits as a low-risk, low-NRE ( non-recur-ring engineering charges — the upfront engineering effort required to make a product) alternative to full-custom silicon designs.

A gate array is a custom chip fabricated in two stages: a set of generic transistor patterns is first put down, and a set of interconnects is added later on by the customer. Transistors are expensive to design; making a generic starting base for devices helps many small customers leverage economies of scale. “Field programmable” describes a device programmed “in the field” by the customer.

The FPGA I’ve chosen for this project uses metal interconnects connected via switches, each driven by 1-bit memory cells.

“ring oscillator” as a frequency source. A ring oscillator uses a chain of inverters looped onto itself to create an unstable system that oscillates. Such a ring oscillator can be easily implemented inside an FPGA with no external components by configuring the FPGA to wire a chain of inverting functions together in a ring topology.

The second problem I had to solve was the need for regulated power. All digital circuits are happiest when they have a nice, solid flow of DC current through them. The little board that I had lying around had no onboard capability to regulate the power input. Connecting a battery directly to the board would not be a very robust solution because a battery’s output voltage will vary by as much as 50 percent over its operational life.

So I had to add some kind of voltage regulator to the prototype. We will discuss the specifics of the voltage regulator implementation later; for now, let’s return to thinking about the more interesting problem of how to drive the LEDs with the desired flashing patterns.

Photograph courtesy of Xilinx

in standalone applications. There were a few other et’s take a look at the FPGA, illustrated features in the board, but they could be ignored for in Figure 2. This configuration provides this project. us with the ability to show up to 16 dif- There were two problems I had to solve. First, ferent sprites, and each sprite can be there was no onboard oscillator. All conventional as large as 32x16 pixels. Let’s see how digital circuits require a source of timing to drive L this works in detail. the rate of computation. The source of this timing The heart of the device is a 512x16-bit ROM. Each is often generically referred to as an oscillator. In ROM output bit drives an LED. The address bits to many applications, a precisely cut piece of quartz the ROM (nine address bits allows us to access up crystal is used, and the mechanical vibrations (or to 29 = 512 locations) are split into two logical banks, oscillations, if you will) of the crystal are used as the a “frame count” and a “sprite count.” The ring oscil-source of timing. However, this board had no such lator’s output, which runs at a nominal frequency of thing built into it, since it was intended to be used as 16kHz, is used to drive a 24-bit counter. part of a much larger system. Before discussing how the counter is connected The easiest way around this problem is to use a to the sprite ROM, let’s first review a few interesting properties about binary counters. The first is that each successively significant bit of a counter toggles at a rate equal to exactly one half of the previous bit.

Figure 2: Block diagram of the FPGA internals used in the first prototype. The large box around the three leftmost elements indicates the boundary of the FPGA.

Ring Oscillator

24-bit Counter

5-bit Sprite Count

4-bit Frame Count

512 x 16 Sprite ROM

16 LED Outputs

36 Make: Volume 01

References:

http://www.makezine.com/01/bunnie

Archives