Você está na página 1de 14

A GAL Programmer for LINUX PCs

Abstract
GALs (Generic Array Logic) are reprogrammable digital integrated cir-
cuits which can be used to replace standard 74xx- or 40xx-family devices
to gain a higher level of integration and/or a more exible circuit design.
They are inexpensive, easy to obtain and you can get development software
for free. This project provides some software to use a home-made GAL
programmer (designed by Markus Hoffmann and published in the "Elektor"-
Magazine in 1993) with a PC using the LINUX operating system. Addition-
ally, it includes a small hardware patch to generate programming voltages
needed by recent device types. Currently, only GAL16V8- and GAL20V8-
series types are supported.
1 Disclaimer
galprog - Linux GAL Programming Software
Copyright c 5/1999 M.Prinke <matthias.prinke@surfeu.de>
This program is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foun-
dation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Li-
cense for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
This means in particular:
I will give absolutely no guarantee that the program or circuit will work as de-
scribed, that it will not destroy the GAL chips, the circuit, or even your PC and
any peripherials connected to it, and that it will program GAL chips and that pro-
grammed GAL chips will work as intended or will stay programmed.
If you want some guarantee, buy a commerial product. This is a hobbyist
grade product. If you intend to program GALs for a commercial product, go
1
and buy a professional programmer. Do not use any GALs programmed by this
hardware/software in places where failure or malfunction may be dangerous to the
health or result in monetary losses.
Caution:
The programmers circuit uses a voltage converter to produce a voltage which is
higher than the supply voltage. To prevent an electric shock or other insuries in
case of a malfunction, the printed circuit board should be mounted in a proper
enclosure.
2 What You Get
Before I bother you with the reason how and why this stuff came to be, here is a
short description of this project.
2.1 Hardware
The project uses the GAL programmer designed by Markus Hoffmann, which was
published in the "Elektor"-Magazine ([1]) and in the book "Das GAL-Buch" ([2]).
A small hardware-patch provides additional programming voltages of 14.00V and
14.50V . The programmer is connected to the PCs parallel port.
2.2 Software
The software consists of several programs:
gal: Device driver kernel module. Handles all hardware-dependent and
timing-critical tasks.
galtest: Simple, low-level program to test the hardware. Controls the
parallel port from user-space, so it has to be executed by root.
gal_adj: Simple programto adjust the programming voltages and to check
the logic levels. Controls the parallel port from user-space, so it has to be
executed by root.
repair_pes: Program to write the Programmers Electronic Signature
(PES). Useful if the PES was destroyed and you know its contents (e.g. from
another device of the same type). Uses the device driver.
galprog: The GAL programming software. It provides an ncurses user
interface and uses the device driver. Reads and writes JEDEC-les.
galprog2: A new version of the GAL programming software written in
Perl/Tk. It offers the same functions as galprog, but has a much nicer
graphical user interface. It also uses the device driver.
2
3 Overview
To be honest, GALs are not leading edge technology. If you really want to design
higly integrated digital circuits, CPLDs (Complex Programmable Logic Devices)
or FPGAs (Field Programmable Gate Arrays) are the things to watch out for. There
are CPLDs which can be programmed in circuit (ISP- or JTAG-interface, respec-
tively) via a simple PC parallel port interface. You can even get the design software
for free, at least for a limited period.
But if you only need some simple glue logic for your microcontroller de-
sign, your PC ISA-Bus-Card or whatever, a GAL may be sufcient and prefer-
able. GALs can provide combinatorial logic, tristate outputs and registered outputs.
They are:
inexpensive
easy to obtain
easy to use
easy to handle (e.g. 20-/24-pin DIP package)
and design software (GAL assemblers) is available for free
The major drawback for using GALs as a hobbyist is the need for a program-
mer
1
which is relatively expensive, but there are some options for home building
such a device at reasonable costs and efforts.
When I started some designs with 8051-series microcontrollers last year, I re-
alized that a GAL programmer would be handy. By that time, GALs hat been
available some time and a variety of books and articles on that topic had been pub-
lished. So I compared some designs and choose the one which seemed the most
simple and inexpensive to me.
When the hardware was built which was really easy, I realized that the ac-
companying software did not support the recent device types. Obviously, the GAL
stuff was so outdated by now that nobody considered to keep the software up to
date. The bad news was that even no source code was available for these oh-so-
great DOS programs. So I decided to write my own software from scratch. It took
some time for me to learn a little more about Linux device driver modules and to
get the ncurses user interface working. But that was nothing compared to the
fact that the programming algorithms are not available from the manufacturers as
far as you are not a recognized programming hardware company. But some people
have done the great and tedious job of revealing one of the best-kept secrets in the
world. And nally it worked.
For some reasons (see section 4), I would not recommend to choose the hard-
ware used in this project any more. Maybe the design described in [4] would be a
1
exception: the ispGAL22V10 is an in circuit programmable GAL, which is slightly more expen-
sive than a standard GAL22V10
3
better option. In this case, the device driver would have to be modied. If anyone
should modify/rewrite the device driver part for a different hardware, I would be
happy to hear about it. I also wonder if a GAL assembler exists, which could easily
be ported to Linux.
4 Building the Hardware
You can nd a description of the hardware in [1] and [2]. For copyright reasons,
I cannot include it here. I tried to contact the author on this topic, but I had no
success. If you are really interested in these articles and you cannot get any of
them (because they are out of print), you should ask someone who knows. (Hint,
hint. . .)
The design has two disadvantages: At rst, it uses a 74LS673 16-bit shift reg-
ister. This device is hard to obtain and sometimes very expensive. Since most of
its features are not used in this design, it can easily be replaced by two 8-bit shift
registers (e.g. 74HC(T)4094 or 74HC(T)595), but this would require a patch of the
PCB.
The second drawback is that the circuit was designed when only two different
programming voltages (15.75V and 16.50V ) were used. Currently, also voltages
of 14.00V , 14.50V and 15.00V are required by some device types. Some designs
use a D/A converter to provide the programming voltages. This is a good idea,
but I didnt want to spend any time on a redesign. I just added a simple patch to
the existing hardware (see g. 1) which provides 14.00V and 14.50V . If a GAL
should ever require another value, you could either (a) adjust any voltage to t your
needs or (b) simply choose a value which is close enough.
2
Once the hardware is ready, use the program gal_adj adjust the program-
ming voltages and to check if it works properly.
3
You will need a voltmeter and
a piece of wire to do this. Using the program should be straightforward. Table 1
shows the register settings for the respective test cases. If you want to do some
really low-level tests, you can use galtest to control the hardware.
5 Building and Installing the Software
5.1 Device Driver Kernel Module
5.1.1 Conguration
To build the Linux device driver for the programmer hardware, enter the directory
driver/. If you did not apply the hardware patch described in section 4, you
have to comment out the lines
#define EXT_VOLT_1
2
check the datasheet for the required accuracy
3
gal_adj has to be executed by root!
4
IC4/Pin 3
IC5/Pin 21
10k
7
k
5
1
0
k
B
C
5
4
7
Figure 1: Hardware-Patch for additional Programming Voltages
and
#define EXT_VOLT_2
in gal.c before you start to compile.
5.1.2 Linux Kernel 2.2.x/2.4.x
Copy Makefile.linux-2.4.x to Makefile, then compile the module:
$ cp Makefile.linux-2.4.x Makefile
$ make
The module gal.o should have been created. Now you can install the driver. You
will have to be logged in as root.
# make install
This will do the following operations:
remove any gal device driver loaded previously
create the directories /lib/modules/misc/
and /lib/modules/<kernel_version>/lib/ if they do not exist
yet
install the kernel module gal in these directories
create the device nodes /dev/gal0 and /dev/gal1
The devices minor number is used to determine the parallel ports address:
/dev/gal0 port address 0x278
/dev/gal1 port address 0x378
The module will be loaded automatically when the application program tries to
open the device le /dev/gal0, if you add the following line to your systems
/etc/conf.modules:
alias char-major-62 gal # gal programmer
Otherwise you will have to load the module manually by using modprobe or
5
insmod each time you want to use it. Please note that the module cannot be loaded
if another device blocks the associated parallel port, e.g. a generic parport/printer
driver. In this case you will have to unload this device rst.
The module gal generates some debugging information which should be logged
to your systems /var/log/messages.
5.1.3 Linux Kernel 2.6.x
With Linux kernel 2.6.x, kernel modules have to be compiled as a part of the ker-
nel source tree [8]. This requires write access to the kernel source tree (usually
/usr/src/linux/). You will have to be logged in as root.
# cp Makefile.linux-2.6.x Makefile
# make -C /usr/src/linux SUBDIRS=$PWD modules
The module gal.ko should have been created. Now the driver can be installed:
# ./install.sh
This will do the following operations:
remove any gal device driver loaded previously
create the directories /lib/modules/<kernel_version>/extra/
if they do not exist yet
install the kernel module gal in these directories
create the device nodes /dev/gal0 and /dev/gal1
The devices minor number is used to determine the parallel ports address:
/dev/gal0 port address 0x278
/dev/gal1 port address 0x378
The module will be loaded automatically when the application program tries to
open the device le /dev/gal0, if you add the following line to your systems
/etc/modprobe.conf.local:
alias char-major-62 gal # gal programmer
Otherwise you will have to load the module manually by using modprobe or
insmod each time you want to use it. Please note that the module cannot be loaded
if another device blocks the associated parallel port, e.g. a generic parport/printer
driver. In this case you will have to unload this device rst.
5.2 Compiling the low-level Tools
The low-level tools gal_adj, galtest and repair_pes can be found in the
directory tools/. There you will nde a Makefile, too. Just type make to
build the programs.
6
5.3 Compiling the GAL Programmer Application Program
The GAL programmer application program galprog and its Makefile can be
found in the directory galprog/. If you did not apply the hardware patch de-
scribed in section 4, you have to comment out the denes
#define EXT_VOLT_1
and
#define EXT_VOLT_2
in galprog.h!
As before, a simple make should build the executable. However, in some cases
the ncurses library may cause problems. It can either be linked dynamically
(which is the default) or statically. If you experience any difculties, just change
the linking option in the Makefile. When the program is build successfully, just
copy it to /usr/local/bin so you can access it from any working directory.
6 Using the galprog Software
6.1 General
When you start galprog, you will have to select the appropriate device driver
rst. Remember that the device driver determines which parallel port will be used.
Since there is no possibility to detect the programmer hardware automatically, you
have to watch the LED to check if the setup is correct.
Figure 2 shows a screenshot of the galprog user interface. The operation
is straightforward. The rst step is to select the GAL device type (GAL 16V8 or
GAL 20V8) you want to use. To prevent any demages, please insert/remove a GAL
into/fromthe programming socket only if the programasks you to do so. Make sure
that the device is inserted properly, i.e. in the correct position and orientation.
6.2 Menu Options
Set Port Selects the parallel port.
Set GAL Type Sets the general GAL device type. The specic type (e.g. 16V8D)
will be detected automatically.
Load JEDEC Loads programming data froma JEDECle into the internal fusemap
buffer. The le syntax is checked, but not very extensively.
Save JEDEC Saves the programming data in the internal fusemap buffer to a
JEDEC le.
Read GAL Reads the programming data froma GAL device (master) to the fusemap
buffer. This works only if its security fuse was not blown, otherwise the data
will be useless.
7
Figure 2: Screenshot of the galprog User Interface
Write GAL Programs a GAL device with the data stored in the fusemap buffer
and veries it. Note the security fuse is not blown automatically, even if the
source JEDEC le indicated it.
Verify GAL Checks a programmed GAL against the fusemap buffer. This works
only if the GALs security fuse was not blown.
Security Fuse Blows the security fuse to prevent reading back the fusemap data.
The effect is that the AND-matrix data will be read back as all logic ones.
Quit Exits the program.
6.3 Status Information
Device Driver The name of the selected device driver.
GAL family The selected general device type.
JEDEC le The current JEDEC le name.
Fuse Checksum The fusemap checksum as a hexadecimal number.
8
7 Using the galprog2 Software
The program galprog2 is a port of galprog to Perl/Tk. Therefore, the same
functionality and a very similar user interface is provided. Figure 3 shows the
galprog2 main window. When a function is selected by pressing a button, a se-
quence of dialog boxes show up. Please refer to section 6 for a detailed description
of the programms usage.
Figure 3: Screenshot of the galprog2 User Interface
8 To Do
If the JEDEC-le contains the directive "*G1", the security fuse shall be
blown. This is not implemented yet.
Bit 0. . .7 of the Programmers Electronic Signature (PES) may contain a
9
programming cycle counter. I am not sure if commercial programmers still
use this feature. Not implemented yet.
Bits 56. . .63 of the Programmers Electronic Signature (PES) contain a check-
sum. I do not know how this checksum is calculated. Not used.
9 Additional Information
The GALBlast archive ([4]) includes device IDs, manufacturer IDs and pro-
gramming algorithms of virtually all GAL devices.
The JEDEC le format standard can be found on the the JEDEC website
([5]).
GAL assembler GalAsm V1.5 for Linux by Volker Bosch [6]
A GAL assembler, some useful GAL programming information and other
GAL programmers can be found on [7].
Detailed background information on GALs and some application examples
can be found in [2] and [3].
The layout of the conguration fuses for the GAL16V8 and the GAL20V8
series can be found in appendix B.
You can nd this projects archive and other electronics and Linux stuff on
my website http://members.surfeu.de/matthias.prinke/
c 10/2000 M. Prinke <matthias.prinke@surfeu.de>
10
References
[1] Markus Hoffmann, GAL-Programmer mit Centronics-Schnittstelle, PC-
Projekte, Sonderheft Plus 15, Elektor, 1993
[2] Ulrich Hack, Markus Hoffmann, Das GAL-Buch, 2. Auage, Elektor, 1993
[3] Dieter Bitterle, GALs Programmierbare Logikbausteine in Theorie und
Praxis, 3. Auage, Franzis, 1993
[4] Manfred Winterhoff, GALBlast,
http://www.geocities.com/ResearchTriangle/Forum/8070/index.html
[5] Standard Data Transfer Format Between Data Preparation System and
Programmable Logic Device Programmer, JEDEC Standard JESD3-C,
http://www.jedec.org/
[6] Volker Boschs Homepage, http://www.s-line.de/homepages/bosch/
[7] Steve Walz FTP archive, ftp://ftp.armory.com/pub/electronics/GAL/
[8] William von Hagen, Migrating to Linux kernel 2.6 Part 2:
Migrating device drivers to Linux kernel 2.6, LinuxDevices.com,
http://www.linuxdevices.com/articles/AT4389927951.html
11
A GAL Programmer Register Settings
Socket Pin Voltage/Level Shift Reg. Latch Note
2 16.50 V 0x1000 Poti 1
15.75 V 0x9000 Poti 2
14.50 V 0x3000 Poti 4
14.00 V 0xB000 Poti 2+4
12.00 V 0xD000 Poti 3
low 0x0000
3 16.50 V 0x0800 Poti 1
15.75 V 0x8800 Poti 2
14.50 V 0x2800 Poti 4
14.00 V 0xA800 Poti 2+4
12.00 V 0xC800 Poti 3
high 0x0400
low 0x0000
4 high 0x0001
5 high 0x0002
6 high 0x0004
7 high 0x0008
8 high 0x0080
9 high 0x02
10 high 0x04
11 high 0x0000 0x01
low 0x0040 0x00
13 high 0x08
14 high 0x10
21 high 0x0020
22 high 0x0010
23 5.0 V 0x0200 LED on
24 5.0 V 0x0100 LED on
Table 1: GAL Programmer Registers (low: 0 . . . 0.5 V, high: 2.4 . . . 5.0 V;
Programming Voltages 14.00 V and 14.50 V require modied Hardware)
12
B Conguration Fusemap
Fuse Nr. Row Index Row Index Fuse Name
16V8 16V8A/B/C/D/Z/ZD
2048 32 0 XOR 19
.
.
.
.
.
.
2051 35 3 XOR 16
2052 46 78 XOR 15
.
.
.
.
.
.
2055 49 81 XOR 12
2120 37 5 AC1 19
.
.
.
.
.
.
2123 40 8 AC1 16
2124 41 73 AC1 15
.
.
.
.
.
.
2127 44 76 AC1 12
2128 0 9 PT 0
.
.
.
.
.
.
2159 31 40 PT 31
2160 50 41 PT 32
.
.
.
.
.
.
2191 81 72 PT 63
2192 45 77 SYN
2193 36 4 AC0
Table 2: CFG-Fuses GAL16V8 / GAL16V8A/B/C/D/Z/ZD
13
Fuse Nr. Row Index Row Index Fuse Name
20V8 20V8A/B/Z
2560 32 0 XOR 22
.
.
.
.
.
.
2563 35 3 XOR 19
2564 46 78 XOR 18
.
.
.
.
.
.
2567 49 81 XOR 15
2632 37 5 AC1 22
.
.
.
.
.
.
2635 40 8 AC1 19
2636 41 73 AC1 18
.
.
.
.
.
.
2639 44 76 AC1 15
2640 0 9 PT 0
.
.
.
.
.
.
2671 31 40 PT 31
2672 50 41 PT 32
.
.
.
.
.
.
2703 81 72 PT 63
2704 45 77 SYN
2705 36 4 AC0
Table 3: CFG-Fuses GAL20V8 / GAL20V8A/B/Z
14

Você também pode gostar