Generic Array Logic Devices

I’ve been blogging a bit about digital electronics lately.  One of the devices that I have never had the opportunity to experiment with is the Programmable Array Logic or PAL.  The last time I built a circuit was when I was in College in the early 90’s.  At that time I owned a Mac Plus and a 386sx generic PC.  With my limited resources (see college student), I couldn’t afford a device to program PALs or EPROMs.  I ended up building my own EPROM programmer to program some 2716s and 2732s.  Those days are long gone.  Now things are cheaper and better.  Now the PAL has been kicked to the curb and even the GAL is obsolete.  Fortunately, the GAL was manufactured for so long that there are a lot of cheap chips available.  I’m going to get into the weeds on the GAL16V8 device.  My purpose is to publish some information that is very difficult to find on the web.  Lattice is the company that made these devices and they have stopped manufacturing them as of 2014 (not to worry, there are substitutes from other companies).

Programming the GAL16V8 Device

I own the MiniPro programmer which can program a bazillion different devices.  I bought it to program EPROMs, but it’ll do PALs, GALs and a bunch of other embedded devices.  It’s a simple USB connected device and it’s cheap.  Here’s the product website: TL866 Universal Programmer.  I wasn’t able to find a copy of the PALASM program in any language other than FORTRAN and I decided I needed to make progress on programming this chip, so I reverse engineered the JEDEC file and manually set the fuse links.  Technically, the GAL doesn’t have any fuses.  The old PALs used to have a fuse link on each grid wire and you blew out all the fuses for pathways you didn’t want.  This leaves the paths you want intact which form a circuit.  Your programmer blows the fuses based on a JEDEC file.  If you make a mistake and blow a fuse you didn’t intend to blow, well, you throw away the chip and program another one.  The fuses are permanent, like a PROM (Programmable Read Only Memory).  The GAL uses flash memory to represent the fuses and they can be erased and reprogrammed.  This is very convenient because it took me about 20 tries to get my first GAL to do something simple.

The JEDEC file is a text file that contains the fuse definitions.  I discovered the details of this file by opening my programmer window and saving a blank file (after selecting the correct device).  The programmer created a .JED file and I opened it with Sublime to see what format it was in.  I was pleasantly surprised that it was in text format and not binary.  So I changed some of the “1”s into “0”s, saved the file and read it back into my programmer software and it worked.  Next was the task of figuring out the layout.  This took a lot of research (a.k.a. Internet searches) plus trial and error.

First, let’s describe the device.

How the GAL16V8 Works

The spec for the device can be found here: GAL16V8.  If you scroll down to page 8 you’ll see this diagram (this is just the top):

This diagram shows the grid of wires that connect the internals.  The OLMC is a configurable block of logic that can determine how the chip behaves.  Each row of wires can connect to any wire in the 32 columns of wires.  However, each row is not really one wire.  Each row represents the AND of each wire leading to the OLMC.  You can see the tiny AND gates to the left of the OLMC blocks:

Inside the OLMC is an OR gate that ORs all the ANDed lines together.  Like this:

What this really represents is something like this:

The idea is to set fuses to connect input lines to the inputs of the AND gates.  Pin 1 and Pin 2 inputs can be setup so that one of the AND gates will trigger an output if both inputs are a “1”.  Here’s an example of the fuses to set (all others will be removed):

The left “X” represents a connection from pin 2 high and the right “X” represents the connection from pin 1 high (pin 1 wraps around the OLMC).

You might have noticed the little “PTD” and “2128” at the top of the GAL diagram.  That fuse allows you to turn off any AND gate that you don’t want to include in your circuit (PTD stands for Product Term Disable).  So you need to keep fuse 2129, but you can remove fuses for 2128 and 2130 through 2135.  This will prevent any other lines from interfering with your first circuit.

Next, you’ll need to understand that all the OLMCs can be programmed to behave in different ways.  To get them to behave as a simple OR gated output, you can set the SYN and AC0 fuses to 1 and 0 respectively.  SYN is fuse number 2192 and AC0 is fuse number 2193 (the last two fuses in the file).  For the first OLMC you’ll need to set the AC1 mode bit to a “0”.  AC1 for the first OLMC is fuse 2120.

Finally, there is a fuse that defines if the output is active high or active low (inverted).  The fuse for the first OLMC is 2048.

The OLMC configuration for simple mode is on page 9 of the specification at the link.

The JEDEC File

The TL866 programmer uses JEDEC files to define the fuses that will be set in the GAL device (.JED extension).  The fuse map portion of this file looks like this:

*L00000 00000000000000000000000000000000

*L00032 01011111111111111111111111111111

*L00064 00000000000000000000000000000000

*L00096 00000000000000000000000000000000

*L00128 00000000000000000000000000000000

*L00160 00000000000000000000000000000000

*L00192 00000000000000000000000000000000

*L00224 00000000000000000000000000000000

*L00256 11110111111111111111111111111111

*L00288 11110111111111111111111111111111

*L02048 00001111111111111111111111111111

*L02080 11111111111111111111111111111111

*L02112 11111111000000000100000011000000

*L02176 111111111111111110

The *L is the starting address of the line of fuses.  You can skip addresses that are not defined and they will become the default value as defined by the *F line in the file (zero being the default in this case).  As you can see L0000 through L00224 line up with the diagram of the circuit above.  One thing you’ll notice is that a “0” represents a fuse and a “1” is no fuse (that caused me a lot of frustration, when trying to reverse engineer this).

L02048 is the line that begins the XOR outputs (to define active low or active high).  Fuse 2056 through 2119 is a signature, so you can ignore these fuses.  Fuses 2120 through 2128 define the AC1 config parameter for the OLMC modules.  As mentioned earlier fuses 2128 through 2191 are the PTD fuses to define which AND gates will be turned off.  Finally the last two fuses are SYN and AC0.  You can see in the JEDEC file above that SYN and AC0 are set to 10.  That means that this GAL is setup for simple mode (each OLMC will behave in the simple configuration).  Here’s a list of fuses and their purpose in the GAL16V8 device:

0 - 2047 matrix

2048 XOR for OLMC 0 (0=active low [led lights], 1=active high)
2049 XOR for OLMC 1
2050 XOR for OLMC 2
2051 XOR for OLMC 3
2052 XOR for OLMC 4
2053 XOR for OLMC 5
2054 XOR for OLMC 6
2055 XOR for OLMC 7

2056 - 2119 Signature

2120 AC1 for OLMC 0
2121 AC1 for OLMC 1
2122 AC1 for OLMC 2
2123 AC1 for OLMC 3
2124 AC1 for OLMC 4
2125 AC1 for OLMC 5
2126 AC1 for OLMC 6
2127 AC1 for OLMC 7

2128 - 2191 PTD

2192 SYN
2193 AC0

There are other fields used in the JEDEC file.  Some are not used by the TL866.  One field in particular is the *C field, which is the checksum field.  The TL866 will compute this number and save it correctly, which is good because other software might blow up if the field is not right.  However, I have changed fuse patterns and not updated the *C field and the TL866 ignores it.  In the sample JEDEC file above, I also have fuses setup for the third input (pin 3).  This circuit will cause the second OLMC to output a “1” when pin 3 is a “1”.  You can download the file by clicking here and unzipping the zip file.  The specifications for the JEDEC file can be found here: PLD File Formats.

Where to Find GAL Devices

If you go to the on-line Jameco catalog and navigate to the semiconductor section, you’ll see a section called “Logic, Programmable“.  You’ll see a list of programmable chips.  There are some 16V8 devices as well as 22V10 and 20V8 devices.  I’m starting small and simple.  These things can get complicated in a hurry and it took a lot of re-programming to get it down.  The devices are about $2.25 each (as of this blog post) and Amazon has the TL866 programmer for around $50.  If you own the devices I listed in my last blog post on “Digital Electronics for the Beginner” you should have enough hardware to experiment with GAL devices.

If you have any specific questions about the GAL16V8 and how it’s programmed or the JEDEC file format, or if you know something about this device and think it should be appended to this blog post, please feel free to leave a comment.

 

Leave a Reply