Pages created and updated by Terry Sturtevant Date Posted: January 31, 2017


PC/CP220 Digital Electronics Lab

Introduction to CPLDs

Objective:

Background:


In this circuit, you'll wire up a CPLD and a bargraph LED.

inputs and outputs

Programmable Logic Device, or PLD, is a general name for a digital integrated circuit capable of being programmed to provide a variety of different functions.(The "C" in CPLD stands for "complex".)

Why use a PLD?

A PLD is good for prototyping designs. Only a single chip is required to implement a complete logic design. It allows us to simplify designs and reduce development times. Changes in the design can be easily implemented by reprogramming the device. Simple PLDs (such as the one we use in our lab) can realize from 2 to 10 functions of 4 to 16 variables on a single integrated circuit

One style of CPLD board looks like this:
pld board
[click image to get a larger image]

The other style of CPLD board looks like this:
pld board with JTAG library
[click image to get a larger image]

Functionally the two types of boards are the same.

Bargraph LED displays

bargraph LED

A bargraph LED is a collection of LEDs arranged side-by-side in a single device. It's a compact way to display several bits at once.
As with any LEDs, each one needs to be used with a resistor to limit current. This can be done by putting an individual resistor in series with each one. However, since they're all in a row, it's much easier to use a resistor array instead.
bargraph LED
If the common pin of the resistor array is grounded, then a high on the other side of any LED should light it up, provided the LED is the right way around. If you're not sure which way the display should go, just turn it around if it doesn't work one way.

bargraph LED connections

bargraph LED with active high output

If you want a LOW (0) signal to light up the LED, simply reverse the common connection and turn the bargraph display around. (You need to turn the bargraph around since current will need to flow in the opposite direction.)

bargraph LED with active low output

The actual resistor value isn't critical; anything between about 100 Ω and 1 k Ω should work. With smaller values, the LED will be brighter; with larger values, it will be dimmer. Ideally you want to choose a large value that makes the LED bright enough to see clearly.

The image below shows how the connections are the same as for an individual LED. (The signals come in on the yellow wires.)

bargraph and normal LED compared

As wtih individual LEDs, they can be connected either active high or active low. In the image below, the LED and bargraph on the right are connected for active high signals, on the yellow wires, while the LED and bargraph on the left are connected for active low signals, on the orange wires.

bargraph and normal LED compared with active high and active low
  signals

Task:

Parts list

Using Altera Quartus II with the CPLD board

Creating a New project

(If you need a reminder of how to do this, go to the Quartus II introduction)

  1. Create a new project called Myxor.
    Always start by creating a new folder and a new project first, and then create a BDF file. Do not start by creating a BDF file.

    You'll be creating an exclusive or from AND, OR, and NOT gates.

    For two inputs, A and B, the XOR function is given by:

    f = AB + AB

  2. Draw the circuit and compile it.

    For the device, choose the EPM7064SLC44-10 from the MAX7000S Family as before, which is the device we are using in our lab.
    choosing the 7064slc

    If you get a message like this, don't worry; it's fine.
    logic lock message

Assigning Pins

  1. Select Assignments | Pin Planner  from the pull-down menu.
    assigning pins
    You'll see a schematic of your device which shows the status of various pins, with a list of your inputs and outputs below.
    assigned pinout
  2. You will notice that the pins around the edges of the chip have different symbols. The plain round circles with nothing written inside of them are used for input and output. Note: Even though pin 1 and pin 44 show as round circles, they have special functions so don't try to use them.

    Don't assign any of the extra signals that Quartus creates; only assign the inputs and outputs that you created. Assign all of your pins to fit in one "bank" of CPLD connections, so pins are close together. Banks are:
    • 1-10 (This has 5 i/o pins available.)
    • 13-22 (This has 7 i/o pins available.)
    • 23-32 (This has 7 i/o pins available.)
    • 35-44 (This has 5 i/o pins available.)

    The following diagram shows the useable I/O pins in white.

    pld44 useable pins


    One style of CPLD board looks like this:
    pld board bank
    [click image to get a larger image]
    The other style of CPLD board looks like this:
    new pld board bank
    [click image to get a larger image]
    Here is bank two.
    One style of CPLD board looks like this:
    pld board bank
    [click image to get a larger image]
    The other style of CPLD board looks like this:
    new pld board bank 2
    [click image to get a larger image]
  3. Select each input and output from the bottom of the screen and drag it on top of the pin you would like to use - make sure you click on the name. (ie. if you want A to be pin 4, click A on the bottom of the screen and drag it on top of the circle under the label 4). Remember, use ONLY the plain round circles!!
    You only need to assign your inputs and outputs; you will probably see some other signals listed that you didn't specify. Leave them as they are.
    When you are finished you can close the window.

Recompile

You will need to compile your design again to fit your design on the PLD board.

  1. Click on Processing | Start Compilation to start compilation.

Set up Programming Hardware

Setting up Programming Hardware in Quartus II Software:

  1. Connect your USB-Blaster cable to one of the USB ports on your computer.
  2. Choose Tools | Programmer. The Programmer window will open.
    selecting programmer
    The selected programming hardware is identified as. If it says "USB-Blaster [USB-0] mode JTAG" you have the correct hardware (skip to connecting programming hardware to the device).
    select programmer
  3. Click the Hardware Setup button to open the Hardware Setup window.
    Programming hardware that is already set up appears in the Available hardware items window.
    usb blaster
  4. If the USB-Blaster is not listed as the Currently selected hardware, select it and click the Add Hardware.
    usb blaster selected
  5. Click Close.
    At the main window, ensure it displays USB-Blaster[USB-0] mode JTAG (see figure below)

Downloading Your Design to the CPLD

Connecting Programming Hardware to the Device:

  1. Connect CPLD board to USB-Blaster cable (connected to a USB port on your PC).

    One style of CPLD board looks like this:
    The cable should be attached so that the red edge of the USB-Blaster cable is next to the number (usually a "1" or a "2") that has been written on the board with a marker. IF YOU'RE NOT SURE, ASK!!!

    JTAG cable pld board with JTAG library
    [click image to get a larger image]

    The other style of CPLD board looks like this:
    The cable should be attached so that the red edge of the USB-Blaster cable is away from the edge of the board as shown below. IF YOU'RE NOT SURE, ASK!!!

    JTAG cable pld board with JTAG library
    [click image to get a larger image]

  2. Connect the ground and power (5v) to the CPLD board and turn the power on.
  3. Click Auto Detect, and Quartus II should detect the CPLD.
    If it doesn't, there are three possibilities:
    1. You haven't chosen the correct device.
    2. Your cables aren't connected correctly.
    3. Your CPLD is faulty.
    Problem Solution
    Unable to scan device chain.

    This is generally a problem with power. Check:

    1. Are the power and ground connected properly and turned on?
    2. Is the red strip on the USB-Blaster cable connected to the proper side of the board?
    JTAG error

    This is generally a problem with the connection. Try:

    1. Make sure you have the correct device selected
      • ensure 7064 (not 7032)
      • ensure SLC (not STC)
    2. Unplug the USB-Blaster cable and reconnect.
    3. Try a new USB-Blaster cable.
    4. Try a new CPLD board.
    License error

    This is generally a problem if you haven't done anything with the software recently. The server times out and loses the connection to the licensing file.

    1. Close Quartus and reopen.

    Once it autodetects correctly, you can proceed.
  4. Delete the file that shows up.
    auto detect device
  5. Click Add File choose 'pof' file
    select 
programmer
  6. Check Program/Configure
  7. Select Start, you should see the progress indicator increasing. (If it instantly jumps to 100% it indicates a problem.)

Wire Input and Output

  1. You can unplug the USB-Blaster cable and turn off the power while you are wiring your circuit. You will not lose your program.
  2. Use the debugger board to wire the input (use control mode) and a bargraph LED display for the output. If you want, you can display the inputs on the bargraph display as well.
  3. Be sure to daisy-chain the breadboard(s) and the debugger board, rather than using several clip leads or having clip leads holding more than one wire.

You may want to use the debugger board for output to see that the CPLD is working, and then wire up the bargraph display once you know it should be getting the correct signals. This is another example of modular design.

Troubleshooting

If you smell smoke turn off the power immediately and DO NOT touch the Altera chip. It gets extremely hot if it is short circuited. Check all your power and grounds, have someone else check your power and grounds - something IS wrong!! Hopefully, your chip will still work. :)

  1. First, double check your simulation to ensure that your Quartus design is correct. If it is not correct then you will not get the correct output no matter how well everything else is connected.
  2. Next, check your device, even if you think it's right... double check. If you need to change it make sure you recompile.
    • At the top of your pin out file make sure it reads ASSIGNED TO AN: EPM7064SLC44-10
      • ensure 7064 (not 7032)
      • ensure SLC (not STC)
  3. Check your pin assignments and make sure you have not assigned any of your inputs or outputs to reserved pins or specialized pins. Plain circles only (with no writing inside).
  4. Make sure you have power and ground to your boards (CPLD, debugger, breadboard).
  5. Make sure you have the debugger board set up for input and output correctly.
  6. If some signals seem to be right and some seem to be wrong, check your pins to make sure you are in the correct place and use the multimeter to ensure you have good connections.

Demonstrate the circuit to the lab demonstrator before you leave.

After Quartus II is closed, if you worked on the C: drive copy your directory to the E: (flash) drive or to the I: drive, since C: drive files will be erased when the computer is shut down.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG 2.0
(Level AA)

Wilfrid Laurier University