Computers Overview
Commodore PET
Sinclair ZX80
Sinclair ZX81
BBC Micro
Sinclair Spectrum
Memotech MTX
    About
    Library
    Manuals
    Options
    Photos
    Projects
      CFX
      Hardware Hacks
      Legacy (1980s)
      MAGROM
      MTXPlus+
      PAL Reader
          Construction
          Hardware
          Software
                Option 1
                Option 2
      PC Keyboard I/F
      Programmers
      ReMemotech
      ReMemorizer
      SDX
      SFX
    Repairs
    Software
    Tools
      Development
      Web Tools
    User Groups
    Video Wall
Memotech CP/M
Atari ST
PDAs
DEC 3000 AXP
OpenVMS
Raspberry Pi

 

 
 
 

The Memotech MTX Series

 

PAL Reader / Decoder for PAL14L4s 

 

PAL Reader Software

You can see details of the design and construction of my prototype on this page.

The Reader is based on 4 x 74LS163 4-bit binary counters which are used to generate each of the possible 16384 input combinations to the PAL. The counters are controlled by the host computer using two outputs to control the counter clock (CLK) and reset (CLR) signals and four inputs to read back the corresponding output states from the PAL.

The 74LS163 has two counter enable inputs, "ENP" and "ENT", both of which must be enabled to count, as well as a "ripple carry output" (RCO) used to enable successive cascaded stages. To generate the 16384 input combinations, four counters are required, using 14 of the available 16 bits. The "ENP" and "ENT" inputs of the first counter are held "high" which enables the counter at every clock pulse from the computer. The "ENP" and "ENT" bits for the subsequent counters are set by the RCO of the preceding counter as shown below:

When counters IC1 to IC3 reach their maximum count (15) and "roll-over", the corresponding RCO bit is pulsed to increment the next counter in the chain. The individual counter output bits are fed to the 14 inputs, I0 to I13, of the PAL whose 4 output bits are fed to 4 inputs of the computer I/O port.

 

Computer Program for CP/M, PALRD.COM

The program first synchronously sets the active low CLR signals to low, clearing the counters, and the CLK signal high, generating a "0000" pattern on the counters. 16383 subsequent CLK low-high transitions (with CLR  held high) "clock" the counter to generate each of the possible 16384 input combinations to the PAL. After each counter increment, the computer reads the state of the PAL outputs to determine the output state for a given input combination.

The program then attempts to analyse the 16k states to find the product terms that generate outputs and remove the redundant terms, these can run into many thousands and whilst it is conceptually simple, requires a not insignificant programming effort to implement. To save on programming time, CP/M disk routines are not supported and the CP/M "SAVE" command is used to write the data to disk as either a Binary or Text file. The program prompts the user to save a number of memory blocks to file, for binary files, the user is prompted to "SAVE 64" blocks (16kbytes) to disk, the number of blocks required to store the logic expressions in text format depends on the relative complexity of the logic, but the program advises the user of the required number.

The Binary file allows the PAL to be read once only, then replaced in its socket. The PAL program can be decoded from the Binary at any later time on any system with the appropriate software.

Since the PAL decoder board does not know the names or functions of the individual PAL input pins, the program can only produce generic equations of the form :

/Output 1 = Input 1   *   /Input 2   *   Input n  . . . .

e.g., /PIN17 = PIN2 * /PIN3 * /PIN4 * /PIN5 * PIN6 * PIN8 * /PIN9 * /PIN12

In this example, the output is a function of a single "AND" term

Using the relevant board circuit diagram to determine the function of the PAL input pins, you can then manually translate the equations into the more usual form, such as :

/CE = A13 * /A14 * /A15 * /MREQ * R0 * R1 * /R2 * /RELCPMH

or /READY = + /INDISK + /MOTOR

In the second example, the output is a function of the simple "OR" of two inputs

Note :  PALRD.COM is not available for download.

Whilst it is beyond my abilities, for anyone with a knowledge of Z80 assembler and CP/M, writing the code to to exercise the PAL and write the resultant data to a binary file should be relatively simple.

Depending on whether you have access to PALRD.COM, analysis of the resultant binary file can be achieved in two ways, as described below.

 

Design Verification

To verify that the PAL Reader was correctly reading the logic and creating the correct PALASM equations, a PAL (GAL) with a known configuration was read and processed by PALRD.COM. Andy had previously sent me a GAL to replace the one on my RS232 board should I ever want to run REMEMOrizer with the serial card installed. The "raw" equations produced were "translated" into the expected form by referring to the RS232 circuit diagram and the resulting equations compared to the expressions in the REMEMOrizer equation source file.

You can see the results of the comparison in this document, but the outcome was that the PAL was successfully read and decoded, suggesting that the hardware and software were working correctly.

 

Further Development

However, whilst generation of the binary file containing the logic outputs was reliable, it was found that the equations produced by the PALRD program, though apparently correct for most PALs, when used with PALs having more complex equations, could generate extraneous terms. Until the obscure error causing this behaviour was identified+, Tony developed a work-around, allowing the binary file to be analysed using an external program on a PC. Tony found that a freeware tool called Logic Friday was ideal for finding minimised equations from the binary file, after formatting it for Logic Friday.

Decoding of the PAL then became a four stage operation :

  • PALRD.COM generated a binary file containing the output states for all of the possible logic input states.
  • A QBASIC program, PALRD.BAS, formatted the binary file into a CSV file for processing by Logic Friday
  • Logic Friday re-wrote the .CSV file to save minimised equations
  • PALRD.BAS formatted the Logic Friday .CSV into a text file containing more readable equations.

PALRD.COM has now been modified to correctly generate the PAL logic equations, but, providing that you can generate the binary file as described, the mechanism of analysing the file externally is described as Option 2. Again, PALRD.BAS is not available for download, but the program description under Option 2 should allow you to generate a suitable file for processing by Logic Friday and find the PAL equations.

+ As it turns out, the "obscure error" was caused by a bug in MyZ80, the Z80 emulator that Tony used to develop PALRD.COM. MyZ80 is a widely used, fully featured, Z80 emulator for PCs, it is available on my CP/M emulators page. Version 1.11 of MyZ80 does not correctly execute the Z80 "RES 1,C" and "RES 1,B" instructions. Tony uses the "RES 1,B" instruction in PALRD.COM and upgrading his version of MyZ80 to Version 1.24 has resolved the issue with PALRD.COM.

 

Analysis of the binary file

As described above, there are two options for determining the PAL equations

  • Option 1 - Using PALRD.COM - the method that I use

 

  • Option 2 - Generate your own binary file and process it on PC

 

 

 

mailto: Webmaster

 Terms & Conditions