CPLD-design

CPLD’s, Complex Programmable Logic Devices, are very interesting integrated circuits.

 

In short, a CPLD is a bunch of logic devices in one chip. So you can replace a lot of logic chips by only one CPLD. But, there is no free lunch: now you have to program the beast.

 

To explore this world, the world of programmable logic devices, I decided to build something, just for a learning experience. But where to start? There is already a bewildering number of different chips to choose from.

 

In the Elektuur magazine, a Dutch electronics magazine (also available in various ‘local’ language versions in Europe) of february 2004 a Xilinx CPLD evaluation board was described. You can order it directly from the internet for about $ 50,-. It is a complete design environment with cables, software and a very, very, useful printed tutorial/guide.

 

The link where you can find it is: http://www.digilentinc.com/XC2XL.html?Prod=xc2xl

This is the XC2-XL development board that I am using.

 

(a lot of other boards can be found using

this link: http://www.fpga-faq.com/FPGA_Boards.shtml)

 

In the following I will write some sort of a diary. I will try to write down my findings and show what an amateur like me does in his free time. Some of you will laugh at me, some of you will hopefully learn a little bit faster than I did.

Software development

The example in the tutorial (programmable logic guide, nov 2003, by Karen Parnell and Nick Mehta) describes a simple design of a traffic light controller.

 

The following steps are taken

Reference design

The board, out of the box, does not have many possibilities for experiments. Only two LEDs and one push-button. But there is a large breadboard area and all pins of the two CPLDs are accessible via 40 pin connectors.

 

Put two AA-size batteries in the battery holder and connect it to the board: the two LEDs are flashing and if you push the button, the pattern changes.

 

Ok, I take a piece of Eurocard and solder a 40 pin male angled header on it and one pin of a LED display with a 150 ohm resistor in series to ground. This circuit draws about 11 mA at 3.3 V. I connect this circuit to GND, which is pin 1, and the resistor to pin 39, because this pin on the connector happens to be in a convenient place for me.

 

The information of the connectors is in “Design_Kit_Resource_Manual.pdf” in the directory “Documentation” on the Xilinx CD.

 

I will use connector C which is connected to the XC9572XL because this CPLD can handle TTL-signals. When I connect my LED-board to the CPLD board nothing happens. Of course, beacause pin 39 on the C-connector is not (yet) defined to do something.

 

Now I put myself to a simple task: I want one segment of my LED display to flash. I decide to make a smal modification to the original reference design and define pin 39 to output the same signal as the flashing LED.

The modification

 

Tasks:

  1. where is the reference design?
  2. how can I change this design to define pin 39 as output?

 

The reference design can be found at

http://www.digilentinc.com/Data/Products/XC2/XC2-demo-cr2.zip

 

Create a directory and extract all files to this directory. Now I have all files extracted

in directory XC2-demo-cr2. There are sub-directories __projnav, _ngo and xst.

 

Start Xilinx visual development program Xilinx ISE 6 / Project Navigator.

 

File / Open Project / browse and select xc2_default.npl

 

Obviously this project was created on a previous version of the ISE software. I say ‘yes’ when the program offers me to adapt the project to the current software environment, what else could I do?

 

In the pane titled ‘Sources in Project’ I double-click on XC2_demo_bd.ucf because there I see something about package pins in the lower pane titled ‘Processes to Source: “XC2_demo_bd.ucf”.

 

There is a LED connected to P92. Is that the LED that flashes? Yes, from the documentation it is clear that pin 92 of the XC9572XL is connected to LED LD2. But figure 5 in the doc is incorrect. There are no 390 resistors but 500 ohm SMD-resistors. Oh, this not the pinout of the XC9572XL but the pins of the XC2C256.

 

Is there a design-file for the XC9572XL or do I have to create one myself?

 

Further investigation reveals: in the library there is XC2_demo_bd.vhd. This is the VHDL-file describing the behaviour of the LEDs and the button. There is also a debouncer implemented for the push-button.

 

Do I need the other file, DXC95-demo.zip? No, that is a different demo. In that design the button is simply connected to the LED.

 

In the very beginning of the project the choice for a certain CPLD is made. So I have to go back and first fully understand the traffic-light example before I can connect my LED-display…

Second attempt

In the tutorial it is described how you can change your design from one CPLD to another. It is a matter of right clicking the top-level file and change the target device into an XC9572XL. But then you have to reassign the pins too, of course.

 

The pins are assigned as follows for the XC2C256-5tq144:

 

Signal               I/O       Pin on XC2C256         Corresponding pin on XC9572XL

 

Reset               Input    P136                           P32      (arbitrary pin)

Osc_sw           Input    P143                           P33

LED                Output P92                             P39      (one segment of my LEDdisplay)

Clk                  Input    P38                             P1

 

From the source:

 

entity XC2_demo_bd is

    Port (                                  reset                : in std_logic;    -- reset button

                                               clk                   : in std_logic;   

                                               osc_sw                        : in std_logic;    -- Switch clocks button

                                               LED                : out std_logic

                                               );

end XC2_demo_bd;

 

From the documentation:

 

The pushbutton drives the GSR input on both CPLDs, and the LED is driven from a general I/O pin.

 

What is GSR? Global Set/Reset

 

osc_sw is the button, but how is the signal ‘reset’ implemented on the board? Is there a charging C in the schematic? Automatic at power up?

 

Two inputs on the same pin P33 is not accepted!

 

I have to find that out in the schematics of the board. How is the button connected to the XC9572 en what about the reset pin?

 

From the documentation:

 

A pushbutton and two LEDs provide basic I/O functions on the XC2-XL. The LED can be illuminated to verify that configuration has been successful, or flashed at a given rate to indicate a particular status. The pushbutton can be used to provide a basic reset function, or to select an operating mode. The pushbutton drives the GSR input on both CPLDs, and the LED is driven from a general I/O pin.

 

So, pushbutton and reset share the same pin on the XC9572XL!

 

ASSIGN AN ARBITRARY FREE PIN FOR THE SIGNAL RESET, THAT IS ALSO DONE FOR THE XC2C256!

 

Signal               I/O       Pin on XC2C256         Pin on XC9572XL

 

Reset               Input    P136                           P32      (arbitrary pin)

Osc_sw           Input    P143                           P33

LED                Output P92                             P39      (one segment of my LEDdisplay)

Clk                  Input    P38                             P1

 

The process ‘assign package pins’ now does not complain and it seems that all compiles well.

 

Let’s transfer this modified design to the XC2 demo board.

 

Now I need the jtag-programming cable. One end fits on the demo board in the jtag-header. The other end is a 25 pin male SUB-D connector to be connected to the parallel port of the PC.

 

Select boundary scan mode č connection established.

 

I see two icons, one for each CPLD

 

Erase before programming? Yes.

 

Hurra! I just successfully erased the content of the XC9572XL because one LED does not flash anymore (nor does my LED display however…).

 

I think the .jed-file is empty?

Third attempt and a little success at last

 

The DXC95 demo on the same URL as above is much easier adapted to let one segment of my LED display react to the button.

Note: C39 is the pin on the connector, P4 is the corresponding pin on the CPLD!

 

Now the LED reacts to the button and if I reassign the signals my LED display displays one segment when I push the button! Now I made the equivalent of a ‘hello world’ program. From here I can start experimenting.