In this article Steve tells us about GALs and how to get started with them. No we are not talking about female hobbyist or how to pick up girls. GAL is short for Generic Array Logic. If your home projects use logic parts then you will be interested in GALs. These parts may be the only device you need in your Logic parts bin. They are programmable to implement the logic of almost any logic device and they can do so much more.
This article was submitted by Steve Chamberlin as part of the “Hobby parts for articles” program. Steve will receive an Arduino compatible Really Bare Bones Board kit (RBBB) from the Modern Device Company for this great article.
A GAL (gate array logic) is a hobbyist-friendly reprogrammable chip that’s perfect for creating customized "glue logic" for your electronics projects. If you often work with common 7400-series parts like NAND gates, counters, and muxes, you’ve probably run into cases where you wished you could change just one little thing about a part, like make that active low output be active high, or change a synchronous clear input into an asynchronous one. Using GALs you can do this with ease. Can’t find a source for some of the more obscure 7400-series parts? No problem, create a work-alike with a GAL. Is glue logic eating up too much space on your board? You can typically replace 3-5 basic logic gates and similar parts with a single GAL.
GALs are the simplest member of the programmable logic family that also includes CPLDs and FPGAs. They are the modern replacement for the one-time programmable PAL devices that were first introduced in the late 1970′s. Unlike PALs, GALs can be erased and reprogrammed many times. And unlike CPLDs and FPGAs, GALs don’t require using a hardware synthesis language like VHDL or Verilog, or any other special design tools. Although it’s possible to use fancier tools to configure GALs, the simplest method is just to write logic equations in a plain text file, defining each output in terms of the inputs. Run your equations through a command-line tool to create the binary GAL data, and you’re ready to go. Easy as pie!
You’ll find GALs in many varieties, but the most useful to hobbyists is the 22v10 in a DIP package. The 22v10 GAL is a 24-pin 0.3" DIP, with 12 dedicated inputs, and another 10 pins that can be configured as outputs, inputs, or bidirectional. You’ll find them at electronics suppliers like Mouser and Jameco for about $2 to $4 apiece. Futurlec also has GALs at very attractive prices.
You don’t need to know or understand the internal structure of a GAL in order to use one, but it’s interesting nonetheless. Knowing the internal structure of the GAL also makes it possible to work backwards from the binary GAL data to the original equations, if you ever need to reverse-engineer a GAL program.
Take a look at the schematic diagram of the 22v10 internals on the Lattice Semiconductor datasheet page 6, you’ll see it’s really a marvel of clever engineering. Each of the chip’s inputs is routed to a horizontal wire row within a large array. Each output has a small block containing a single OR gate fed by between 8 and 16 AND gates, with each AND gate fed from another horizontal row in the array. The array also contains many vertical wire columns. At each point where a horizontal and vertical wire cross, there’s a fuse that can be programmed as opened or closed.
By burning the right fuses, any input wire can be connected to any AND wire by means of one of the vertical cross-wires, enabling the programming of an arbitrary sum-of-products equation, like Y = A*B*/C + /A*C + /B. In this notation * means a logical AND, + means a logical OR, and / means a logical NOT.
GAL equations are authored in a plain text file, using a format called EQN, and are then converted to a binary format called JEDCOM, or JED, which contains the fuse data. The DOS command-line program that does this conversion is named eqn2jed.exe. You can find this tool through a web search, or just grab it out of the Opal Jr package here, part of a National Semiconductor tool suite. The syntax of a .eqn file is:
- Optional comment lines, beginning with a semicolon
- A CHIP line, defining the chip’s name and type (e.g. MyChip 22v10)
- A list of symbolic names for each pin number
- An EQUATIONS heading
- A list of equations for each output, one per line, in sum-of-products format
For example, here’s a .eqn file that implements a 16-t
o-1 mux: A 4-bit select input A is used to select one of 16 data inputs D, which is passed to a single data output Q.
; 16-to-1 mux example
CHIP mux G22V10
d0=1 d1=2 d2=3 d3=4 d4=5 d5=6 d6=7 d7=8 d8=9 d9=10 d10=11 gnd=12
d11=13 d12=14 d13=15 d14=16 d15=17 q=18 a0=19 a1=20 a2=21 a3=22 nc=23 vcc=24
q = /a3*/a2*/a1*/a0*d0 +
The mux example has a single combinatorial output, which is always enabled, but the 22v10 is capable of much more interesting behavior. You can have up to 10 outputs, with each one being combinatorial or registered (changing state at a clock boundary, like a flip-flop). Outputs can also be used as input terms in the computation of other outputs. Additionally, outputs have an optional output enable term, allowing them to be connected directly to a bus that is sometimes driven by other chips.
More complex examples of GAL usage in hobbyist projects are things like address decoders or peripheral interfaces. In my current project, I configured a 22v10 GAL as an 8-bit stack register for a custom CPU design. In a single GAL, I was able to implement an 8-bit up/down counter with a parallel load input and an output enable. I also implemented the CPU’s address decoder logic and some other control logic using GALs. You can see the relevant .eqn files beginning on page 8 of the machine specs.
After you’ve written your .eqn file and used eqn2jed to create the .jed binary file, all that’s left is to program the chip. GALs are programmed using standard programming hardware, just like an EPROM or microcontroller. If you’ve got a decent universal programmer, chances are it already supports GALs. Unfortunately some of the most popular inexpensive programmers like the Willem EPROM Programmer don’t support GALs, so check the list of supported devices carefully. I use the Easy Pro 90B, which supports GALs as well as EPROMs, microcontrollers, and most other programmable devices.
Once you start using GALs in your project designs, you’ll wonder how you ever lived without them. No other cheap, hobbyist-friendly logic device offers the same combination of flexibility and ease-of-use. Where a CPLD or microcontroller would be overkill, and a pile of separate gates would cumbersome, a GAL is the perfect fit.
[David of uCHobby] I did a quick search for hobby programming options and found the following:
- Have you used any of these programmers?
- Have a programmer or parts supplier suggestion for GALs?
- Cool project that uses GALs?
Let us know with a comment.