DIY CPLD board

These are my first steps into the world of CPLDs/FPGAs!

Similar projects worth following
This is my first project here. My intent is to learn about
- CPLDs (and FPGAs) as a device in general and about VHDL for the programming
- PCB layouting (using KiCad - )
- toner transfer DIY PCB making
- (SMD) soldering
- someday later, maybe :) : how to run my two LCD panels I have lying around here for ages that need a custom progammed CPLD / FPGA as a controller, but that's probably for another project

I found a tutorial on how to build my very first CPLD board including PCB schematics on ( ). A side project to this will be to build the necessary parallel port JTAG programmer to program the CPLD ( ).

The project will feature a XC9536XL CPLD from Xilinx.

A CPLD is basically a simpler version of an FPGA - both are microchips. 

But what is a CPLD or FPGA for that matter and what makes them different from other microchips (as for example the ATmegas and ATtinys from Atmel used in Arduino boards etc.)? 

CPLDs and FPGAs basically have 'programmable internal wiring'. That is the chip can be reconfigured via software / programming to do (almost) any task you want it to do.

And how is that different to simply programming an Arduino?

The part that is different is that the reprogramming / reconfiguring happens on the hardware level, not on the software level. So programming happens 'much closer to metal' than 'ordinary programming' (very vaguely like programming a chip in Assembler in terms of 'close to metal-ness').

In other words, programming it does not only mean telling the chip what to do (do A, then B, then C) but it also means telling it how each little part inside is connected with each other part and how these parts work together and at what timings. Timings can be defined down to a few nanoseconds accuracy depending on the chip. With other µCs you ideally have single-cycle execution commands (like with the µCs from Atmel - PICs from Microchip are more difficult here) and factor in the clock speed to take the guesswork out of program timing. And you have to progam them in Assembler which is much too time consuming and complex for most tasks.

A CPLD's / FPGA's highly precise timing allows them to do stuff like producing the video output for a LCD panel or video output in general and their computing power and speed is used in (real-time) signal analysis and processing tasks, image analysis tasks (for example in robotics: object detection, face detection etc.) and also in cryptography (some projects use them as cheap 'supercomputers' to break weaker encryptions).

They have two other significant advantages that make them different by design:

a) different parts of the chip can be assigned different tasks and these tasks can run in parallel! That means where a 'normal' microchip would do task A then B then C one after the other, a CPLD/FPGA would do them concurrently (vaguely similar to a GPU compared to a CPU) and be done in literally a third of the time. The only limit to the amount of tasks is the amount of 'logic gates' or 'logic units' the chip offers (more logic units => higher price) and the (computational) complexity of the tasks involved.

b) they consume relatively little power for the amount of work they can do, provided it is work that can be done in parallel.

As for my choice of device: why a CPLD and not a FPGA?

CPLDs offer less computational resources than FPGAs (from 5-100x) but they also are cheaper in general, not by a large margin though. The cheapest CPLDs can be had for 2-5$ (most in the 2-50$ range), the cheapest FPGAs start at about 5-10$ (up to several hundred dollars, depending on complexity).

Another small advantage, a bit depending on the task: CPLDs have a quicker startup time since they have an internal non-volatile memory (i.e. its contents don't disappear on power off) for their configuration. FPGAs have to read their configuration from an external flash memory which can take a few seconds on startup.

Since CPLDs are a bit simpler by design as mentioned but are programmed in the same languages as FPGAs (VHDL and Verilog are the main ones - the former oftentimes used in Europe, the latter mainly in the US), they are a good starting point for getting into the world of reprogrammable or rather reconfigurable microchips (or so I hope). And last but not least, I did not find a good tutorial for a FPGA board ;)).

  • 1 × XC9536XL CPLD from Xilinx (36 macrocells, 800 gates)
  • 1 × Atmel ATtiny2313 Companion processor on the board, only used as a clock for the CPLD, maybe usable for other things??
  • 1 × 2x7 pin JTAG header for programming the CPLD
  • 1 × 2x3 pin header for programming the companion ATtiny2313
  • 1 × a few other components - see tutorial

  • A few further thoughts on the board layout

    hackhead7908/03/2015 at 08:06 0 comments

    The project has been sleeping for ages now but it has not died (yet ^^). A few simple thoughts came to mind recently on how to improve it.

    I was thinking, why not improve the board design directly from the start and add a few components:

    - I have a few ULN2003A darlington driver arrays lying around: each chip has 7 outputs that can each drive about 500mA. Useful for stepper motors, LED arrays and other higher current (and inductive load) devices and the outputs can be tied together for even higher currents. An extra voltage supply would be needed (external or onboard, probably external) that I could hook to the board and let the ULN's (or TIPs) do the switching

    - add a few TIP120's for switching even higher loads as some sort of electric relay similar to the ULN's, I probably would only need either TIP's or ULN's

    - add a few EEPROMS for extra storage (data values, settings, what have you, possibly even new CPLD configurations, i. e. store several sets of CPLD programs in the EEPROMS and let the MCU (PIC or Attiny) do the programming if that is possible)

    - and if I'm totally nuts add a 2.7V/500F capacitor (about 0.5Ah worth of energy) + converter to the board to power the board from xD (only bad: the cap is pretty big, about 5x2.5cm and would add huge bulk to the board).

    Another thought that came to mind: I am thinking of replacing the Attiny with a PIC16F. I know that they are more difficult to program than the Atmels but as a learning exercise it would do. So far just going a bit nuts on the specs for the fun of it. We'll see what the first version will include.

  • Parts arrived today

    hackhead7904/03/2014 at 17:35 0 comments

    The box with the parts from arrived today at the same time as my eBay order of a breadboard (came from the UK). Nice timing.

    Searching my DIY stock I found a 600g bin of sodium persulfate that will come handy when it is time to etch my PCBs. 600g will be largely enough for the next few boards (it is mixed at a ratio of 1:5 with water). Since sodium persulfate works best at around 40-50°C (104-122°F), I have to find a solution for heating up the etching bath. Some people simply use an electric kettle and some tap water to mix water to >40°C which seems to be hot long enough for about one or two PCBs and will probably be my method of choice for the first few tries.

    I would like to have a permanent heating option though with some kind of double-boiler to heat the etching solution to avoid the hassle of calculating and mixing hot fluids. I still have a few peltier elements lying around that I could throw into a design. Peltier elements are small pads that convert electricity into heat/cold - on they start at 20$, on they start at around 3€ =~ 5$. 

    Since there is a large hardware store nearby that has a 3D printing facility, this sparks up a few ideas for a new project (read: 3D printed µC operated adjustable temperature controlled double-boiler etching bath using peltier elements - could probably be made for under 25$, at least with the cheap peltiers on

    But lets not overdo it project-wise. Should I really go that far, it will certainly appear as a project here on hackaday ;) with STL files and the like so that other people can have their own one printed.

    For now I'll do a bit of Arduino hacking and see to the CPLD boards in the next few days.

  • Components hunting

    hackhead7904/02/2014 at 20:09 0 comments

    So yesternight I went component hunting for my two beginning projects (this CPLD board and the parallel port JTAG programmer necessary to program the CPLD). 

    At first I searched at or rather HBE sells the complete range of products Farnell does at a very slight markup but they also ship to individuals in contrast to Farnell.

    For component search the main Farnell site is a real trove though: they have free datasheets to just about any product they have on sale (I did not come across one they had no sheet for), their search is much more detailed and they list more product specifics per listing. So all in all a very good start.

    I had some difficulties finding some of the parts though (in particular the 2x7 JTAG header, 9 pin 8 resistor network, etc.) so after a cursory search on I switched to In Germany (where I live and come from), is pretty cherished among DIY electronics enthusiasts because it offers a very large range of products at a very decent price point.

    One or two hours later, I had all the products in my shopping cart with one exception: the tutorial board uses a PLCC socket for the main chip (as in the first example picture below - the socket is the brown thing around the chip) but Reichelt only had the VQFP-44pin version. They seem to be stocked on pretty much everything (including the 2x7 JTAG header and the resistor network) but CPLDs are a bit niche it seems (more so than FPGAs).

    (nevermind the image placing / sizing - it is not quite working yet - all images from Wikipedia under Creative Commons)

    A socket gives you the advantage of being able to switch the chip (second pic is an example socketable chip) in case you want to program another CPLD. The VQFP-44 version I got (reading: Very small Quad Flat Package with 44 pins - example TQFP 80-pin: third pic above) has to be soldered onto the board.

    That means:

    a) should I fry the chip when soldering it or by a wiring mistake or similar I'll have to (re)solder a new one - bummer! Only good thing: they cost 1.80 € a pop (about 2.50 US$) so I ordered three of them ;). I don't think I will send them all to chip nirvana if any, so I'll have one or two spare ones for other pet projects.


    b) I'll have to learn how to change the PCB schematic provided by the tutorial. I'll have to switch the PLCC socket diagram for a 44-pin TQFP SMD part diagram and wire it correctly in KiCad.


    c) I'll have to learn to solder small pitch SMD parts which is not one of the easiest things to do.

    Sounds challenging to me but (hopefully) offers some worthwhile learning.

    All in all I spent about 13-17$ per board plus components (CPLD board and JTAG programmer board) plus a parallel port PCI-Express card needed for the programmer (at about 15-20$) - so all in all not that very expensive for a start :).

View all 3 project logs

Enjoy this project?



Peter Burkimsher wrote 06/30/2014 at 19:32 point
Is it too late to give some fundamental advice? I've actually done a very similar project before!
For the XC9536XL CPLD, I'm using a PCI debugger that I bought in Shenzhen last year. It also came with a Nokia screen :-).
It's already on a board, and I soldered a JTAG header into place.
For a JTAG programmer, I'm using the GuzuntyPi gz_load tool on my Raspberry Pi.
I made 2 test programs earlier this year when I was in South Korea, and I had access to a Xilinx USB programmer. Those just turn the LED on or off.
About a month ago, I used my Raspberry Pi to program the CPLD successfully, to my great relief! The LED is on or off as expected.
Do you have any ideas of further projects I can use this for? I enjoy circuit design, and learned Verilog and VHDL in university, but I'm not actually sure what to do with it now.

  Are you sure? yes | no

hackhead79 wrote 02/03/2015 at 00:05 point

Using a Pi as JTAG programmer is an awesome idea. I have a Pi lying around and after checking my PC case I noticed that there is no further PCI slot free so the Pi might be the way to go. 'real life' has kept me pretty busy so the project is still lying around 'in parts' so to speak but not forgotten.

I also thought what I might use a CPLD for. Maybe low quality (monochrome) PAL video generation? Or use the CPLD to interface / (de)multiplex several I2C lines? Also I've read that some audio ICs use I2S (a kind of similar protocol) that I could not find much infos or libraries about - maybe a good use for the CPLD to write an interface to I2C so that the audio chips (ADC/DAC) can be interfaced via a microcontroller.

  Are you sure? yes | no

Peter Burkimsher wrote 02/03/2015 at 01:15 point

Why stop at PAL? Go all out for VGA, using fewer GPIO pins. If you succeed, I'll be tremendously grateful! It's on my to-do list, along with a myriad of other projects.

  Are you sure? yes | no

hackhead79 wrote 02/03/2015 at 01:45 point

What I would love to do is color PAL signals. I haven't found a good & understandable explanation of it yet. Do you have any useful links that explain color PAL nicely? Monochrome seems to be pretty doable even on lowend micros (like small PICs) albeit at a low resolution but for info screens this would be enough.

  Are you sure? yes | no

Peter Burkimsher wrote 02/03/2015 at 02:01 point

I'm just searching like you, but here's a few links that I feel like posting here instead of bookmarking:

  Are you sure? yes | no

hackhead79 wrote 02/03/2015 at 02:13 point

Thanks a lot for the links. The info about monochrome is quite useful!

I am looking into the PAL/NTSC stuff since I want to repurpose old TVs as info screens (for example as el-cheapo oscilloscopes).

In the same vein DVI/HDMI would be pretty interesting too but that is out of the scope of a CPLD. A much faster FPGA would have to do that job. Maybe a project for later down the road.

Just curious, what kind of projects do you have in mind for the VGA signals?

  Are you sure? yes | no

Peter Burkimsher wrote 02/03/2015 at 02:35 point

Hmm, HDMI would be a good use for my Virtex-II, which I rescued from a scrapyard in Korea. I still need to build a 3.3V-2.5V JTAG level converter to program it though.

The VGA project is for putting basic text slides onto a projector, e.g. for presentations or song lyrics in church. Black & white would be enough, but I want it to be pocket-sized. I'll probably go for something based on my Arduino Pro Micro or ODroid-W.

  Are you sure? yes | no

hackhead79 wrote 02/03/2015 at 02:49 point

Yeah, HDMI would be pretty useful indeed. Does the projector have a composite link or only VGA?

  Are you sure? yes | no

Peter Burkimsher wrote 02/03/2015 at 03:51 point

I've seen many different projectors in lecture theatres, conference rooms, churches, etc. Occasionally there's HDMI, almost always there's VGA. I've only seen PAL composite once or twice, and that required climbing up to the wall-mounted projector.

  Are you sure? yes | no

hackhead79 wrote 02/04/2015 at 15:55 point

Ok, yeah, true, climbing up to the projector every time to attach a composite cable is out of the question ;). I've found a link that has some helpful information on how VGA exactly works (which seems to be close to DVI/HDMI according to the second link by K.C.Lee above your post). Maybe it helps you. Also, this might help: - it proposes a way to drive a VGA signal from 11 pins (it uses a 12 pin connector).

  Are you sure? yes | no

K.C. Lee wrote 02/03/2015 at 03:46 point

Here are HDMI links I have:

- Xilinx xapp460

- TI's tfp410 (flat panel driver) can generate DVI signals from LVTTL pixel inputs

  Are you sure? yes | no

hackhead79 wrote 02/04/2015 at 16:06 point

Thanks, K.C., for the links they are very informative. Also the tfp410 looks pretty interesting and it goes for 3-5€ so this might be an option too!

  Are you sure? yes | no

hackhead79 wrote 02/04/2015 at 16:40 point

Seems I found 'my' solution to the color PAL signal question. A simple PIC will be to slow for the maths involved (although I am not sure if this could not be circumvented via sin and/or cos tables) but maybe my 2560 Arduino or the CPLD will do.

Also, I have some (10bit I think) DACs lying around. Could be interesting. Hope I will find the time to do some of this soon.

  Are you sure? yes | no

hackhead79 wrote 04/02/2014 at 21:49 point

Ha, the socket would have been great ;) - the socketable (PLCC) part is the one that is intended by the tutorial and indeed is a great idea since you could program different CPLDs and use them in other projects. Unfortunately, I only got the VQFP-44 version from the supplier I chose so I'll have to solder it by hand :-/, and yes, I'm quite hesitant too (bought 3 chips in case I fry the one or other). We'll see how the soldering goes once the parts are there and the PCB is ready.

  Are you sure? yes | no

hackhead79 wrote 04/02/2014 at 21:50 point
And thanks for skull & follow!

  Are you sure? yes | no

Mike Szczys wrote 04/02/2014 at 21:40 point
I like your choice of using a socket for the CPLD. I was specifically wondering which chip package you had chosen because I hesitate to solder these by hand.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates