Introduction: Ghetto Programmable Logic (CPLD) Development System
For the past several months I have been enjoying the Ghetto Development System for the AVR processors. In fact, this nearly zero dollar tool has proven so fascinating and useful that it got me wondering if it were possible to extend the concept to FPGA/CPLD development as well. (FPGA: Field Programmable Gate Array. CPLD: Complex Programmable Logic Device.)
So I did a little digging on the web and came up with a development system for Atmel CPLDs. Comparison with Altera devices shows their pinout to be the same (within the restrictions I detail below), so they'll work also. By building the development board and interface cable I'll present, then downloading the tools, you can develop your own CPLD applications.
Please note the following limitations and restrictions. I've tried to balance capability and simplicity so you can build something that you'll enjoy and learn from.
5V devices only. Extending the system to cover additional voltages (3.3V, 2.5V, 1.8V are supported by Atmel devices in the same family) is not difficult, but it complicates both the development board and the programming cable. Let's skip it for now. Note that you have to provide a 5V supply to the board.
44 pin PLCC only. Specifically, I've programmed the Atmel ATF1504AS. The Ghetto CPLD concept can be easily extended to other Atmel devices, but this device seemed like a good compromise between price, ease of use, and capability. The concept should also extend to other devices such as those from Altera, Xilinx, Actel, etc. In fact, the Max7000 family EPM7032 and EPM7064 will work in the same socket as long as you use the 44 pin PLCC versions. So far I've only used the Atmel programming cable, but the Altera Byte-Blaster is supported by the Atmel software and should also work fine. It's actually a little simpler design than the Atmel cable. (I built the Atmel version and it works, so I haven't tried the Altera version.) SparkFun offers a $15 version of the Altera cable. Since this will work for both Atmel and Altera, I recommend it. If you're going to develop with Altera parts, you'll want to get the Altera software as well. I haven't actually tried this, but there's no reason I can think of that it wouldn't work.
Speed is limited. Since the Ghetto CPLD Development System is built with hand wiring and no ground plane, don't expect reliable operation at speeds over a few megahertz. Even that's not guaranteed your mileage may vary! Of course, if you build prototype hardware that has a ground plane then your CPLD may work just fine at higher speeds. Just don't expect it to go fast mounted in the Ghetto Development System.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Go Order Parts
You'll need a 44 pin plcc socket, some decoupling caps, some unprogrammed CPLDs, sockets for breadboard connections, a pull-up resistor and maybe some perf board to build it on. If you have any of this in your junk box you can save a few bucks.
For your convenience, here are Digikey Part Numbers:
CONN PLCC SOCKET 44POS TIN PN: 1-822473-4-ND
SOCKET IC OPEN FRAME 14POS .3" PN: 3M5462-ND Qty: 2
SOCKET IC OPEN FRAME 18POS .3" PN: 3M5464-ND Qty: 2
CAP ELECT 10UF 50V SU BI-POLAR PN: P1280-ND Qty: 1, C1
CAP CER .10UF 50V 20% DISC RAD PN: 478-4275-1-ND Qty: 4, C2-C5
RES METAL FILM 5.10K OHM 1/4W 1% PN: P5.10KCACT-ND
PC BOARD FR4 1-SIDE PPH 4.0X4.0 PN: V2010-ND
IC CPLD 64 MACROCELL 10NS 44PLCC PN: ATF1504AS-10JC44-ND
A few parts may have minimum quantities, but should still be pretty cheap.
If you want to build some blinkenlights (Step 8) or make a set of switches (step 9) you may want to order these also. Keep in mind that Digikey has a $25 minimum to avoid a handling charge, so you might want to get a couple of extra unprogrammed CPLDs or an AVR processor or two just for fun.
I recommend you buy the Altera programming cable from SparkFun. Here are the part numbers. Get the cable and connector as well. (Otherwise, order parts for the cable from Digikey if you're building your own.)
Altera FPGA Compatible Programmer PN: PGM-08705
2x5 Pin IDC Ribbon Cable PN: PRT-08535
2x5 Pin Shrouded Header PN: PRT-08506
Step 2: Get and Install Software
I'm currently using the Atmel Prochip Designer 5.0 tool chain. This tool requires that you register with Atmel and fill out their official request form. I told them I was a design engineer, currently unemployed, and my primary purpose was to learn their devices and VHDL (all true, BTW). They approved the license request. The only catch is that the license is good for only 6 months. I'm hoping to find a public domain tool chain by the time it expires. Altera also has a tool chain I may check out. Any suggestions will be appreciated. See comments and links in the last step.
The Atmel Prochip Designer 5.0 is here. If you get it, be sure to get the Service Pack 1 for it as well.
Step 3: Make Programming Cable
The easiest approach here is to buy the Altera Byte-Blaster work-alike from Sparkfun (see Step 1). If $15 is more than you care to spend, then you can use the SparkFun Altera Cable schematic or use the Atmel Cable schematic and scratch-build one. (If there's a lot of interest in scratch-building the cable, I can offer some suggestions, but the Sparkfun kit seems like the right answer to me.)
Step 4: Make Programmer Cradle
Have a look at the Atmel programmer. This is very flexible and is a great option if you have the bucks and plan to do a lot of CPLD development. Altera offers something similar, I believe. But I went with a cheaper approach - that's what this is all about!
The pictures show front and rear views of the cradle I built. Note the DIP sockets used as breadboard connectors. All pins on one side of each connector are connected to ground; pins on the other side connect to signal pins on the CPLD. I included a few power connections as well; put these in where they fit. The diagrams are sort of pictorial schematics; only the extra power connections aren't shown. Look at the pictures for ideas on these.
Step 5: Building the Cradle - Part 1
Start building the cradle by inserting the sockets in the locations where you want them. Allow a vacant row or two so there will be room for the decoupling caps. This also makes it easier to connect to the CPLD signal pins.
Anchor the sockets with a bit of solder or epoxy depending on the type of perf board you use. Allow some extra room at the top (above pin 1 of the CPLD socket) for the JTAG connector and the power connector. Refer to the pictures of the one I built.
Route a bare wire (20 gauge or so) around the outside of the sockets for a ground bus. Route the power bus also. (The red wire in the pictures.) Refer to the pictures for some guidance, but your board will probably be a little different - and that's just fine.
Solder the outside pins of the sockets to the ground bus. This will help anchor the bus wire.
Step 6: Building the Cradle - Part 2
Install the decoupling caps and connect them to the ground and power pins on each side of the CPLD socket. I suggest routing the wires up and over the outer rows of pins to reach the inner rows. Refer to the pin number diagrams to get the correct pins - the pin-out of the CPLD socket is far from obvious. Leave enough room to allow connection to any pins you pass wires over.
Once the cap connections are done, connect the power and ground bus. All the red pins on the diagrams are Vcc and should be connected. The black pins are ground and should be connected also. Again, routing it in the air is a good approach. Look at the pictures for ideas.
Step 7: Building the Cradle - Conclusion
Route the JTAG connections to the correct pins. Have a look at your Programming Cable to be sure the connector is oriented correctly. Don't forget the pull-up on the TDO pin. This is shown in the picture only and goes between the TDO pin and Vcc.
The last step is to connect each I/O pin of the CPLD to a pin on the sockets. Use the numbers in the diagrams for the connections. This takes the longest time! If you follow my numbering scheme, then you can use the Top View diagram as a guide when hooking up your circuits. You really don't have to hook up all of these initially you can wait until you need them for the circuits you design.
Check your work carefully. Be sure power and ground aren't shorted!
Step 8: Make Blinkenlights (TTL Version)
You'll want to see your circuits work, of course. So you'll want some blinkenlights (made famous by The Real Elliot).
The only catch is that CPLDs don't have the beefy outputs that the AVR processors have. Use LEDs rated for 10ma and use 1KOhm series resistors. These will give you clear output signals without straining the CPLD outputs.
Step 9: Make Switches
To provide stimuli for your circuits, you'll need some switches. You have some options here, but the requirements are different than for AVR processors. The CPLD outputs don't have the built-in pull-ups and it's not so easy to do debouncing in software. (It's possible, but takes resources you probably want to use in your circuits.) The DIP switches shown provide several switches in a convenient package, but have to be pulled up. I used 1K pull-ups.
Pushbutttons can be made using the circuit Atmel recommends for their demo board. Schematics are on page 36 or so.
Another option is to hook up an AVR processor to provide stimuli - and even check responses. But that's an exercise left to the student.
Step 10: Create Your First Circuit
By this time you should have obtained and installed the software. Follow the thorough, detailed tutorial to create your first simple CPLD circuit (two-input AND gate; doesn't get much simpler). Be sure to select the correct device (44 Pin PLCC, 5V, 1504AS [details]) and pick I/O pin numbers that are available (I used 14 and 16 as inputs; 28 as an output). These details differ slightly from the tutorial, but shouldn't give you any trouble.
Step 11: Program Your First CPLD
Hook up your programming cable to the parallel port on your PC , hook it to your Programmer Cradle, hook up 5 Volts to the Power connector and follow the tutorial to actually program your very first CPLD. Select the correct version of cable. Note that the Altera Byte-Blaster is one of the options.
Step 12: Test Your Programmed Part!
Disconnect your Programming Cable from the cradle. Plug in the switches and blinkenlights to the correct pins, turn on the power, and try it out. Since you're starting with a simple circuit, testing isn't a big challenge. If it works, you're off and running!
The top view diagram will guide you in connecting your switches and blinkenlights for testing.
Step 13: The End and Some Web Resources
It is not the purpose of this tutorial to teach you how to use VHDL. (I'm just starting to learn that's why I created the programmer, remember?) That said, I've found several very helpful tutorials and some useful resources that I can point you toward. Feedback and other suggestions are greatly appreciated.
Note that you can also use the Ghetto CPLD Development System to learn Verilog and other CPLD programming techniques the hardware doesn't care.
VHDL Resources on the Web:
Basics and some links here and here.
Links to free tools.
Tutorials I like are here and here, but you'll find lots of others.
Finally (for now), you'll want to check out the discussion group.
Enjoy, learn a lot, and share what you know.