Image Map Image Map
View RSS Feed

Chuck(G)

Cloning a PAL/HAL (Part 3)

Rating: 2 votes, 5.00 average.
Part 2 of this series can be found Here

With the hardware to read the PAL "brute force", all we need is a program to do it.

Code:
//	Read a 10L8 PAL and come up with a truth table.
//
//		Uses the little board with the 393s
//

#include <stdlib.h>
#include <stdio.h>
#include <dos.h>

#define PRINTER 0x378			// printer base port
#define PAL_DATA 0x80			// bit representing the PAL data
#define PAL_RESET 0x01			// reset PAL
#define PAL_INCR  0x02			// increment count
#define PAL_COUNT 1024			// how many total count?
#define PAL_BITS  16			// how many bits out
#define CLOCK_PULSE { outp( PRINTER,3); outp(PRINTER,1); }

FILE *outfile;

void main( int argc, char *argv[])
{

  int i,j;
  unsigned int pd,tbit;

//  Open the output file

  outfile = 0;
  if (argc >= 2)
  {
    outfile = fopen( argv[1], "w");
    if ( !outfile)
    {
      fprintf( stderr, "\nError - could not open %s\n", argv[1]);
      exit(1);
    }
  } // if file specified


//  Set the printer port up.  Hold reset active.  Note that increment
//  happens on low-to-high transition.

  outp( PRINTER, 0);			// clock low, reset active

  outp( PRINTER, 1);			// release reset

  for (i = 0; i < PAL_COUNT; i++)
  {
    pd = 0;
    for ( j = 0; j < PAL_BITS; j++)
    {
      tbit = (inp(PRINTER+1) & 0x80) ? 1 : 0;
      pd |= tbit << j;
      CLOCK_PULSE;
    } // for each bit
    printf( "%04x\n", ~pd);
    if (outfile)
      fprintf( outfile, "%04x\n", ~pd);
  } // for each byte
  if ( outfile)
    fclose( outfile);
  printf( "\nAll done.\n");
} // end of main
This is run under DOS or Win9x, but not under NT/XP/2K/Vista/Win7 because of the OS blocking direct hardware access. However, you could try it on any of the NT family with something like the GIVEO utility (google it!).

This gets us a list of 1,024 entries that looks like this:

Code:
00f4
00f4
00fd
00fd
00fc
00fc
00fd
00fd
00f6
00f6
00ff
00ff
00fe
00fe
00ff
00ff
00fc
00fc
00fd
00fd
00fc
00fc
00fd
00fd
00fe
...and so on...
If we were lazy, we could burn the entire lot into a 1Kx8 bit bipolar PROM, construct a socket adapter and claim we have the PAL function duplicated.

Except that we'd have to fit a 24-pin device in the space of a 20 pin one, and bipolar PROMs are power-hungry and slower than PALs. It might work, but maybe not, depending on the application.

We can duplicate the function in something called a GAL for Generic Array Logic, a later device with much enhanced functionality, but still capable of emulating the older PAL and HAL devices. We'll use the GAL16V8, which datasheet can be found here. You'll note that our PAL10L8 is mentioned among the devices that can be emulated by this IC.

Even better, if you goof, a GAL can be erased and reprogrammed. And they're fiendishly fast when compared to the older logic.

All we need to do is take our 1,024 output values and derive 8 logic equations, one for each of the PAL outputs.

Easier said than done? Not really!

Click here to go to part 4...

Submit "Cloning a PAL/HAL  (Part 3)" to Digg Submit "Cloning a PAL/HAL  (Part 3)" to del.icio.us Submit "Cloning a PAL/HAL  (Part 3)" to StumbleUpon Submit "Cloning a PAL/HAL  (Part 3)" to Google

Updated June 12th, 2019 at 09:57 PM by Chuck(G)

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments

  1. 1980s_john's Avatar
    Would the program run on an XP machine using DOSBOX? I've used this with some old DOS software that talks over the serial port that didn't work under plain XP.
  2. Chuck(G)'s Avatar
    You could recompile it under 32-bit C and then run thegiveio or UserPort drivers. I haven't tried it, but it should work.