Fun with CPLDs

philmurr

Active member
vacBacker
Feedback
48 (100%)
Credits
2,378CR
I've wanted to learn about using CPLDs for a lot of years but never really got round to it until now. The main reason for me doing it now was that (despite still being advertised on a well-known US arcade parts supplier's website), the single chip VRA and SBC replacements for Pacman have been unavailable for years, and the big SBC daughterboard gets in the way of my Pacman high score save kit. And while I was at it I thought I might as well try to get the VRA done too. Both the big SBC and VRA boards are easily damaged by plugging them in the wrong way round, and they are very often missing when you get a Pacman/Ms Pacman PCB.

What's the SBC? It's the sync bus controller which interfaces external devices to the CPU.
What's the VRA? It's the VRAM addresser which determines the address to be accessed by the video output circuitry based on values of horizontal and vertical timing.

So a few days of learning, the CPLD carrier and JTAG interface board designed and delivered from China and just this week I've got it all to work.

I've built the carrier boards to work with Microchip/Atmel ATF15xxAS series 44-pin CPLDs. Attached are photos of the 2 boards built. Even though the CPLD itself is small, TQFP format, it's quite easy to hand-solder, just make sure you use a lot of flux then check with a magnifying glass for any shorts. The only other component shown is a Schottky diode for reverse-voltage protection, and there's space for an optional capacitor if needed.

SBC and VRA built top 0224.jpg SBC and VRA built bottom 0224.jpg

Turns out the VRA will fit into a ATF1502AS but the SBC is a bit too big and needs an ATF1504AS with its extra macrocells. Handily though they both have the same pinout so both fit on the carrier board.

So once the code is compiled it needs programming to the boards. That's where the 4 connections at the top of the carrier board are used, the JTAG interface. I designed another board to be the interface between the CPLD boards and the Microchip JTAG programmer - photo below (including 5V power supply that is needed). The CPLD board just plugs in and can be programmed/erased/reprogrammed until the final design works. You only need one JTAG interface board as it's reusable.

JTAG and PSU 0224.jpg

So that's about it, I now have a working Pacman board with high score save and my own replacement VRA and SBC boards. Photos below. showing the SBC (installed next to the CPU socket which is where the high score save kit plugs in) and Pacman running perfectly.

SBC installed 0224.jpg Pacman running 0224.jpg

The CPLD module can be used for recreating other custom chips that I may start experimenting with, along the same lines as the excellent work @NivagSwerdna has been doing with Konami customs.

I won't be selling assembled boards, but I will put up a separate for-sale thread for bare boards if anyone wants some to experiment with.
 

John Bennett

Senior Member
vacBacker
Feedback
10 (100%)
Credits
5,332CR
Yeah, those chips are cool - I used them when playing about doing a couple of Namco customs. Not a lot of storage, but at least they're 5V!
They were unobtainable for a couple of years with the chip shortage, but great if they're back now.

The one irritation was the shonkiness of the toolchains - having to get an ancient version of Quartus, work with equivalent (obsolete) IC names, output file converters etc. I can't even remember if I used a USB or Parallel programmer on an ancient laptop (hopefully the former).
So if you've worked out a slicker way of doing it all, that's neat :cool:
 

philmurr

Active member
vacBacker
Feedback
48 (100%)
Credits
2,378CR
The one irritation was the shonkiness of the toolchains - having to get an ancient version of Quartus, work with equivalent (obsolete) IC names, output file converters etc. I can't even remember if I used a USB or Parallel programmer on an ancient laptop (hopefully the former).
So if you've worked out a slicker way of doing it all, that's neat :cool:
Prochip is good but AFAIK you can only get a 2 week licence before you have to fork out £600+ for 2 years.

I couldn't see me making good use of that kind of money so I did a crash course in WinCUPL which seems to do enough for my needs and generates code native to the ATF1502/4. Then programme the chip via JTAG using the Microchip version of the USB Blaster
 

Mc-Q

Active member
Credits
1,450CR
how is everybody programming these?

i looked at microchip and their programmer is £71 + tax,
the schematic shows a pretty expensive FTDI chip and i dont like that company anyway.

my "universal" programmer supports upto 750 and then the 2500 but not the 1500 series currently :(
 

BillZ

Newbie
Credits
0CR
I've wanted to learn about using CPLDs for a lot of years but never really got round to it until now. The main reason for me doing it now was that (despite still being advertised on a well-known US arcade parts supplier's website), the single chip VRA and SBC replacements for Pacman have been unavailable for years, and the big SBC daughterboard gets in the way of my Pacman high score save kit. And while I was at it I thought I might as well try to get the VRA done too. Both the big SBC and VRA boards are easily damaged by plugging them in the wrong way round, and they are very often missing when you get a Pacman/Ms Pacman PCB.

What's the SBC? It's the sync bus controller which interfaces external devices to the CPU.
What's the VRA? It's the VRAM addresser which determines the address to be accessed by the video output circuitry based on values of horizontal and vertical timing.

So a few days of learning, the CPLD carrier and JTAG interface board designed and delivered from China and just this week I've got it all to work.

I've built the carrier boards to work with Microchip/Atmel ATF15xxAS series 44-pin CPLDs. Attached are photos of the 2 boards built. Even though the CPLD itself is small, TQFP format, it's quite easy to hand-solder, just make sure you use a lot of flux then check with a magnifying glass for any shorts. The only other component shown is a Schottky diode for reverse-voltage protection, and there's space for an optional capacitor if needed.

View attachment 15646 View attachment 15647

Turns out the VRA will fit into a ATF1502AS but the SBC is a bit too big and needs an ATF1504AS with its extra macrocells. Handily though they both have the same pinout so both fit on the carrier board.

So once the code is compiled it needs programming to the boards. That's where the 4 connections at the top of the carrier board are used, the JTAG interface. I designed another board to be the interface between the CPLD boards and the Microchip JTAG programmer - photo below (including 5V power supply that is needed). The CPLD board just plugs in and can be programmed/erased/reprogrammed until the final design works. You only need one JTAG interface board as it's reusable.

View attachment 15648

So that's about it, I now have a working Pacman board with high score save and my own replacement VRA and SBC boards. Photos below. showing the SBC (installed next to the CPU socket which is where the high score save kit plugs in) and Pacman running perfectly.

View attachment 15649 View attachment 15650

The CPLD module can be used for recreating other custom chips that I may start experimenting with, along the same lines as the excellent work @NivagSwerdna has been doing with Konami customs.

I won't be selling assembled boards, but I will put up a separate for-sale thread for bare boards if anyone wants some to experiment with.
I've wanted to learn about using CPLDs for a lot of years but never really got round to it until now. The main reason for me doing it now was that (despite still being advertised on a well-known US arcade parts supplier's website), the single chip VRA and SBC replacements for Pacman have been unavailable for years, and the big SBC daughterboard gets in the way of my Pacman high score save kit. And while I was at it I thought I might as well try to get the VRA done too. Both the big SBC and VRA boards are easily damaged by plugging them in the wrong way round, and they are very often missing when you get a Pacman/Ms Pacman PCB.

What's the SBC? It's the sync bus controller which interfaces external devices to the CPU.
What's the VRA? It's the VRAM addresser which determines the address to be accessed by the video output circuitry based on values of horizontal and vertical timing.

So a few days of learning, the CPLD carrier and JTAG interface board designed and delivered from China and just this week I've got it all to work.

I've built the carrier boards to work with Microchip/Atmel ATF15xxAS series 44-pin CPLDs. Attached are photos of the 2 boards built. Even though the CPLD itself is small, TQFP format, it's quite easy to hand-solder, just make sure you use a lot of flux then check with a magnifying glass for any shorts. The only other component shown is a Schottky diode for reverse-voltage protection, and there's space for an optional capacitor if needed.

View attachment 15646 View attachment 15647

Turns out the VRA will fit into a ATF1502AS but the SBC is a bit too big and needs an ATF1504AS with its extra macrocells. Handily though they both have the same pinout so both fit on the carrier board.

So once the code is compiled it needs programming to the boards. That's where the 4 connections at the top of the carrier board are used, the JTAG interface. I designed another board to be the interface between the CPLD boards and the Microchip JTAG programmer - photo below (including 5V power supply that is needed). The CPLD board just plugs in and can be programmed/erased/reprogrammed until the final design works. You only need one JTAG interface board as it's reusable.

View attachment 15648

So that's about it, I now have a working Pacman board with high score save and my own replacement VRA and SBC boards. Photos below. showing the SBC (installed next to the CPU socket which is where the high score save kit plugs in) and Pacman running perfectly.

View attachment 15649 View attachment 15650

The CPLD module can be used for recreating other custom chips that I may start experimenting with, along the same lines as the excellent work @NivagSwerdna has been doing with Konami customs.

I won't be selling assembled boards, but I will put up a separate for-sale thread for bare boards if anyone wants some to experiment with.
Hello, late to party but is there are chance to get the board and maybe the source code for the Space Invaders and the Pacman? Thanks
 

Rene

Newbie
Credits
1CR
I recently did the same, I made pcbs at JLCPCB and programmed the atf 1502 and 04's with a ft232HL board. But for the VRAM I keep having the same problem each time: A copy of the bottom line with CREDIT 0 or the remaining pacman's are flashingly appearing on the right side with complete tiles and readable text from top to bottom like this:

0

T
I
D
E
R
C
CREDIT 0
(but the vertical line is on the right side, not the left as the forum is showing here ;-) )

I also still have problems how to get the ATF's to reset properly on power on of the board. Right now I can only get them started by (re)inserting the small ATF pcb.
Can I maybe get your files to compare? Or shall I share mine over here?
 

philmurr

Active member
vacBacker
Feedback
48 (100%)
Credits
2,378CR
I also still have problems how to get the ATF's to reset properly on power on of the board. Right now I can only get them started by (re)inserting the small ATF pcb.
Can I maybe get your files to compare? Or shall I share mine over here?
Feel free to share your code on here
 

Rene

Newbie
Credits
1CR
my pld for VRAM in atf1502:
Name NVC284VRAM ;
PartNo 284 ;
Date 2026-08-27 ;
Revision 01 ;
Designer r ;
Company - ;
Assembly NVC284VRAM_ATF1502 ;
Location U13 ;
Device f1502ispplcc44 ;

/*****************************************************************************/
/* Namco / Midway Pac-Man "284" V-RAM Addresser, reimplemented in an */
/* ATF1502AS (PLCC44). Pin numbers match U13 in NVC284VRAM_ATF1502_with_org */
/* Logic reverse-derived from the discrete 74LS157/257/86/02 recreation on */
/* the same board and verified against it over all 16384 input states. */
/* */
/* Function: the 12 video-RAM address lines AB0..AB11 are a 3-way select */
/* between horizontal counters, vertical counters and a few constants, */
/* with every H/V bit XOR-ed by FLIP (cocktail screen flip). Outputs are */
/* tri-stated while 2H = 0 (the CPU half of the shared-RAM time slice). */
/*****************************************************************************/

/** Inputs (game timing bus) **/
PIN 4 = H2 ; /* 2H - also the output-enable phase */
PIN 5 = H4 ; /* 4H */
PIN 6 = H8 ; /* 8H */
PIN 8 = H16 ; /* 16H */
PIN 9 = H32 ; /* 32H */
PIN 12 = H64 ; /* 64H */
PIN 14 = H128 ; /* 128H */
PIN 16 = H256 ; /* /256H - the main H/V mux select */
PIN 17 = V8 ; /* 8V */
PIN 18 = V16 ; /* 16V */
PIN 19 = V32 ; /* 32V */
PIN 20 = V64 ; /* 64V */
PIN 21 = V128 ; /* 128V */
PIN 41 = FLIP ; /* screen flip */

/** Outputs (video RAM address bus) **/
PIN 40 = AB0 ;
PIN 39 = AB1 ;
PIN 37 = AB2 ;
PIN 36 = AB3 ;
PIN 34 = AB4 ;
PIN 33 = AB5 ;
PIN 31 = AB6 ;
PIN 29 = AB7 ;
PIN 28 = AB8 ;
PIN 27 = AB9 ;
PIN 26 = AB10 ;
PIN 24 = AB11 ;

/* Note: pins 7,13,32,38 (TDI/TMS/TCK/TDO) are wired to JTAG header J1 and */
/* are reserved for ISP - leave them unassigned. */

/*---------------------------------------------------------------------------*/
/* Intermediate terms */
/*---------------------------------------------------------------------------*/

/* Every counter bit XOR FLIP (the "prime" signals) */
H8P = H8 $ FLIP ;
H16P = H16 $ FLIP ;
H32P = H32 $ FLIP ;
H64P = H64 $ FLIP ;
H128P = H128 $ FLIP ;
V8P = V8 $ FLIP ;
V16P = V16 $ FLIP ;
V32P = V32 $ FLIP ;
V64P = V64 $ FLIP ;
V128P = V128 $ FLIP ;

/* 74LS157 select: high only when 16H = 32H = 64H */
SSEL = !( (H16 $ H32) # (H32 $ H64) ) ;

/* Top-level 74LS257 select line */
SEL = H256 ;

/*---------------------------------------------------------------------------*/
/* Address outputs */
/* out = SEL ? <H-prime> : ( SSEL ? <V-prime / H> : <const> ) */
/*---------------------------------------------------------------------------*/

AB0 = SEL & H8P
# !SEL & SSEL & V8P
# !SEL & !SSEL & H4 ;

AB1 = SEL & H16P
# !SEL & SSEL & V16P
# !SEL & !SSEL & H16 ;

AB2 = SEL & H32P
# !SEL & SSEL & V32P
# !SEL & !SSEL & H32 ;

AB3 = SEL & H64P
# !SEL & SSEL & V64P
# !SEL & !SSEL & H64 ;

AB4 = SEL & H128P
# !SEL & V128P
# !SEL & !SSEL ;

AB5 = SEL & V8P
# !SEL & H8P
# !SEL & !SSEL ;

AB6 = SEL & V16P
# !SEL & H64P
# !SEL & !SSEL ;

AB7 = SEL & V32P
# !SEL & H64P
# !SEL & !SSEL ;

AB8 = SEL & V64P
# !SEL & H64P
# !SEL & !SSEL ;

AB9 = SEL & V128P
# !SEL & H64P
# !SEL & !SSEL ;

AB10 = H4
# !SEL & !SSEL ;

AB11 = !SEL & !SSEL ;

/*---------------------------------------------------------------------------*/
/* Tri-state: drive the bus only during the video half-cycle (2H = 1), */
/* matching the 74LS257 /OE = NOR(2H,GND) = !2H on the original board. */
/*---------------------------------------------------------------------------*/

AB0.OE = H2 ;
AB1.OE = H2 ;
AB2.OE = H2 ;
AB3.OE = H2 ;
AB4.OE = H2 ;
AB5.OE = H2 ;
AB6.OE = H2 ;
AB7.OE = H2 ;
AB8.OE = H2 ;
AB9.OE = H2 ;
AB10.OE = H2 ;
AB11.OE = H2 ;
 

NivagSwerdna

Active member
Feedback
1 (100%)
Credits
855CR
I also still have problems how to get the ATF's to reset properly on power on of the board.
That is quite weird because your design has no register logic it is completely combinatorial. I don't know your tool chain but it looks like some of your pins may not be set correctly or you have a hardware issue?
In verilog it would look like...
Code:
//-----------------------------------------------------------------------------
// Namco / Midway Pac-Man "284" V-RAM Addresser, reimplemented in an
// ATF1502AS (PLCC44). Pin numbers match U13 in NVC284VRAM_ATF1502_with_org.
// Logic reverse-derived from the discrete 74LS157/257/86/02 recreation on
// the same board and verified against it over all 16384 input states.
//
// Function: the 12 video-RAM address lines AB0..AB11 are a 3-way select
// between horizontal counters, vertical counters and a few constants,
// with every H/V bit XOR-ed by FLIP (cocktail screen flip). Outputs are
// tri-stated while 2H = 0 (the CPU half of the shared-RAM time slice).
//
// Direct translation of NVC284VRAM.pld (CUPL) -- equations unchanged.
// Pin numbers below are noted for reference only; lock them in the
// fitter's pin-assignment / location constraints, not in this file.
//-----------------------------------------------------------------------------

module NVC284VRAM (
    // Inputs (game timing bus)
    input  wire H2,    // pin 4  - 2H, also the output-enable phase
    input  wire H4,    // pin 5  - 4H
    input  wire H8,    // pin 6  - 8H
    input  wire H16,   // pin 8  - 16H
    input  wire H32,   // pin 9  - 32H
    input  wire H64,   // pin 12 - 64H
    input  wire H128,  // pin 14 - 128H
    input  wire H256,  // pin 16 - /256H, the main H/V mux select
    input  wire V8,    // pin 17 - 8V
    input  wire V16,   // pin 18 - 16V
    input  wire V32,   // pin 19 - 32V
    input  wire V64,   // pin 20 - 64V
    input  wire V128,  // pin 21 - 128V
    input  wire FLIP,  // pin 41 - screen flip

    // Outputs (video RAM address bus), tri-stated when H2 = 0
    output wire AB0,   // pin 40
    output wire AB1,   // pin 39
    output wire AB2,   // pin 37
    output wire AB3,   // pin 36
    output wire AB4,   // pin 34
    output wire AB5,   // pin 33
    output wire AB6,   // pin 31
    output wire AB7,   // pin 29
    output wire AB8,   // pin 28
    output wire AB9,   // pin 27
    output wire AB10,  // pin 26
    output wire AB11   // pin 24
    // Note: pins 7,13,32,38 (TDI/TMS/TCK/TDO) are wired to JTAG header J1
    // and are reserved for ISP - not part of this port list.
);

    //-------------------------------------------------------------------
    // Intermediate terms
    //-------------------------------------------------------------------

    // Every counter bit XOR FLIP (the "prime" signals)
    wire H8P   = H8   ^ FLIP;
    wire H16P  = H16  ^ FLIP;
    wire H32P  = H32  ^ FLIP;
    wire H64P  = H64  ^ FLIP;
    wire H128P = H128 ^ FLIP;
    wire V8P   = V8   ^ FLIP;
    wire V16P  = V16  ^ FLIP;
    wire V32P  = V32  ^ FLIP;
    wire V64P  = V64  ^ FLIP;
    wire V128P = V128 ^ FLIP;

    // 74LS157 select: high only when 16H = 32H = 64H
    wire SSEL = !((H16 ^ H32) | (H32 ^ H64));

    // Top-level 74LS257 select line
    wire SEL = H256;

    //-------------------------------------------------------------------
    // Address outputs (combinational)
    // out = SEL ? <H-prime> : ( SSEL ? <V-prime / H> : <const> )
    //-------------------------------------------------------------------

    wire ab0_d  = ( SEL & H8P)   | (!SEL &  SSEL & V8P)  | (!SEL & !SSEL & H4);
    wire ab1_d  = ( SEL & H16P)  | (!SEL &  SSEL & V16P) | (!SEL & !SSEL & H16);
    wire ab2_d  = ( SEL & H32P)  | (!SEL &  SSEL & V32P) | (!SEL & !SSEL & H32);
    wire ab3_d  = ( SEL & H64P)  | (!SEL &  SSEL & V64P) | (!SEL & !SSEL & H64);
    wire ab4_d  = ( SEL & H128P) | (!SEL & V128P)        | (!SEL & !SSEL);
    wire ab5_d  = ( SEL & V8P)   | (!SEL & H8P)          | (!SEL & !SSEL);
    wire ab6_d  = ( SEL & V16P)  | (!SEL & H64P)         | (!SEL & !SSEL);
    wire ab7_d  = ( SEL & V32P)  | (!SEL & H64P)         | (!SEL & !SSEL);
    wire ab8_d  = ( SEL & V64P)  | (!SEL & H64P)         | (!SEL & !SSEL);
    wire ab9_d  = ( SEL & V128P) | (!SEL & H64P)         | (!SEL & !SSEL);
    wire ab10_d = H4 | (!SEL & !SSEL);
    wire ab11_d = !SEL & !SSEL;

    //-------------------------------------------------------------------
    // Tri-state: drive the bus only during the video half-cycle (2H = 1),
    // matching the 74LS257 /OE = NOR(2H,GND) = !2H on the original board.
    //-------------------------------------------------------------------

    assign AB0  = H2 ? ab0_d  : 1'bz;
    assign AB1  = H2 ? ab1_d  : 1'bz;
    assign AB2  = H2 ? ab2_d  : 1'bz;
    assign AB3  = H2 ? ab3_d  : 1'bz;
    assign AB4  = H2 ? ab4_d  : 1'bz;
    assign AB5  = H2 ? ab5_d  : 1'bz;
    assign AB6  = H2 ? ab6_d  : 1'bz;
    assign AB7  = H2 ? ab7_d  : 1'bz;
    assign AB8  = H2 ? ab8_d  : 1'bz;
    assign AB9  = H2 ? ab9_d  : 1'bz;
    assign AB10 = H2 ? ab10_d : 1'bz;
    assign AB11 = H2 ? ab11_d : 1'bz;

endmodule
I am afraid I am not familiar with this arcade PCB or the custom so cannot be much use. All I can suggest is to check the pin assignments, pin functions (however you do that in your toolchain) and double check your hardware.
 

patzik

Active member
Feedback
1 (100%)
Credits
408CR
I know it's been done before by several of you, but having reverse engineered 2 of the custom replacement pcb's of my Time Pilot pcb, the next logical step is a cpld version so I designed my version of a universal pcb, also for the ATF15xxAS series cpld. Asking those who went before me, did you encounter any pitfalls that I should look out for?
1792101483463.png1792101503358.png
 
Top