 It's chiptips, chiptips, I have no music and I can't sing. Greetings, chip friends. I'm working on a part of the Retrocomputer's front panel that can read and write memory through switches. To implement what I envision, I need another state machine. And this time, it's much bigger. It would normally require a 512x16 prom along with a 16-bit register, but instead I'm going to use a programmable logic device, specifically a Gal, or generic array logic. The predecessor of the Gal was the PAL, or Programmable Array Logic. It was introduced in 1978 by Monolithic Memories, whose data book featured this cheeky little dude. The PAL was an array of AND gates, followed by an array of OR gates and inverters, which could get you most combinatorial logic that you wanted. These took the place of PROMs that would normally have been used to replace lots of logic chips, and they were faster as well. Let's look at the smirk on that dude's face. Early versions could only be programmed one time, but then came UV Erasable versions. There were many, many devices to choose from, all having different capabilities. The ones with registers in them were particularly suited towards implementing state machines. The Gal came in 1985 from Lattice Semiconductor. It was more generic in that it could be configured to act like any number of PALs, and it could be electrically erased and reprogrammed. Today, however, these chips have been overshadowed by FPGAs, which have capabilities vastly exceeding those of Gal's, but they also come with high complexity. Here's the context for these programmable devices. An engineer from Fairchild founded MMI in 1969, which developed the PAL in 1978. In 1969, AMD, Advanced Micro Devices, was also founded and eventually bought MMI in 1987. Meanwhile, an engineer at Intel founded Lattice in 1983, which developed the Gal in 1985. Amusingly, AMD spun off its programmable device business as a wholly owned subsidiary in 1996 called Vantus. It didn't last long, and Lattice bought it up in 1999. Today, in the programmable logic space, we still have Lattice, along with Xilinx and Altera, founded in 1983, and bought by Intel in 2015. Now, nobody sells PALs or Gal's anymore except for Atmel, which sells two different kinds, the popular 16v8 and 22v10. Atmel, by the way, lasted from 1984 all the way up to 2016 when they were bought by Microchip. Atmel seems to have gotten into the programmable logic device market around 2000, and I'm not quite sure how it came to sell their version of compatible Gal's. Anyway, aside from these Atmel chips, you can also find surplus Gal's on eBay. Okay, I'm going to be using 22v10s to implement my state machine. A 22v10 has 22 IO pins, and at most 10 of these pins can be configured as output pins. A 16v8, on the other hand, has 16 IO pins, and at most 8 of these can be configured as output pins. Since my state machine has 9 inputs and 13 outputs, I need to use 2 of any of them. Atmel 22v10s are currently US 176 each, while 16v8s are 96 cents each. The much bigger difference though is that the outputs of the 16v8 are limited to 8n terms. If any output in your logic requires more than 8n terms, you have to go to a 22v10, and that's where I'm starting. I can always change to the smaller device later. So suppose you have your logic equations done and you've formatted them in terms of products or logical ands, of inputs and inverted inputs, and then sums or logical ores of those. Now you need to determine which fuses to program in the device. The product terms are easy. Each input and inverted input has a line going vertically. Every available product term has a line going horizontally. Just program the fuses at the intersections and you have your product terms. Of course, not every product term goes to every output, so you have to carefully select which lines you need. The sums of the product terms are carried out by the output logic blocks. You also configure the output logic blocks to be either registered or not, inverted or not, tristated or not, and whether there should be internal feedback. This configuration is done through more fuses. There's also one product term on the chip for an asynchronous reset, and another for asynchronous preset. So now presumably you know the state that you want all the fuses on the chip to be. How do you program that? None of the chip manufacturers publish their programming algorithm, instead only revealing them via non-disclosure agreements with programmer manufacturers. Over the years, people have figured out how to program pals and gals anyway, so you could go that route and Google for programmer circuits, or you could just use an existing programmer as long as it supports the chip you want to program. The mini-pro I have doesn't support the Atmel chips, and given their non-responsiveness to requests, I got another programmer. This is the well-on VP598, which does support the Atmel chips. Someone really really needs to make an open hardware programmer, collecting all the known chip programming algorithms, and that also lets you specify your own algorithm. Anyway, a standard file format for fuses is Gedeck Standard 3C, linked down below. It's pretty simple, you just specify how many fuses the device has, what the default state of a fuse should be, and then the state of each non-default fuse. Give that to the programmer software, and it goes and programs the chip. Now since pals and gals are pretty much obsolete, the software to generate the Gedeck files is also obsolete, except for WinCouple, which is distributed by microchip, linked down below. It's Windows only. Basically, you put in the logic equations you want, and it minimizes the logic, and then generates the Gedeck file for you. There are open-source Boolean minimizers available, so you could write your own software, but WinCouple is somewhat convenient. We start with a few informational fields, and then we specify the signal names for the pins. Remember that you can configure each output as inverted, so the bang in the signal name indicates that. The minimization software should figure out for itself whether to use the output blocks inverter, so that if there are too many product terms with the inversion, it can try to invert the logic all the way back to the inputs to see if there might be fewer product terms that way. Anyway, we can declare fields, which are just lists of IO signals. We can define constants. We can define intermediate signals. Then we can define the asynchronous reset signal using the .ar suffix, while the .d suffix indicates the d input to the registers. We don't have to tell it that we are using the registers in the output block, and the software will figure that out for itself based on whether you specified the d input or not. There's some special syntax I'm using here. A PEND lets you keep a running sum. colon is an equality comparison. Note here that I'm setting all four state outputs according to one boolean, ANDed with a constant pattern. Doing this for each output individually would be a pain. Also note that the hash character, or number sign, or pound sign, or octothorpe, or whatever you want to call it, stands for the OR operation. The syntax is pretty limited compared to what you would see in Verilog. For example, you can't perform arithmetic operations on signals. Then again, gals are limited in what they can do, so limiting what you can specify to ANDs and ORs makes sense. There is more specialized syntax for state machines, but I decided not to use that because my state machine is split across two chips, and it made more sense to me to use a consistent method. When WinCouple compiles your file, it generates both the JEDEC file, and also a nice document with lots of information. One nice bit is to show the minimized equations. Note that the equation for q0 has 10 terms, meaning that I cannot use a 16v8. Well, I might be able to by splitting this equation, but that's a lot of work just to save 80 cents, and I'm not building a million of these. The document also shows you a nice map of the fuses it will program. And at the end, you also get a convenient pinout. Next I just pull out my VP598 programmer, pop the chip into the programmer, the right way around of course, and then I fire up the software that comes with the programmer. I open up the JEDEC file corresponding to the thing that I want to program, and then I select the appropriate device, which in this case is going to be an Atmel 22v10 version C. And then I just hit the program button, and that goes ahead and programs the chip. Once that's done, I can just pop the chip out and stick it in my circuit, and see that it works. And that's all there is to programming a gal.