CSE467: Advanced Logic Design

Carl Ebeling, Winter 1999


Lab 2

Distributed: Jan. 19 - Due: 29 

Objectives

In this lab you will design and implement a complete circuit using the Xilinx chip on the XESS board along with some discrete components on a protoboard. The circuit you are to design is a 1-hot counter that increments whenever an edge occurs on the input. This counter will be displayed using the 7 LEDs on the 7-segment display on the XESS board. The input to this circuit will come from a pushbutton switch on the protoboard. Mechanical switches like this do not make "clean" connections because the switch contacts actually bounce. We will first count these bounces using the edge counter. We will then "debounce" the switches using a couple gates.

You should work on this lab in teams of two. Remember that you both of you will be responsible for knowing how to do everything even if you don't  do everything. Your partner next week will probably not be the same partner as this week.

Edge Counter

Use the Xilinx Foundation tools to design the edge counter. Your counter should be a 7-bit, one-hot counter. Your circuit should have two inputs, a data input which will contain the edges we are looking for, and a reset input which will be used to reset the counter. For this lab, do not use any LogiBLOX components. That is, design your 1-hot counter from scratch using gates and registers from the Xilinx library.

Simulate your design first to make sure it works OK.  The following section will describe how to connect your circuit to the appropriate Xilinx chip pads so that you can implement and test it on the XESS board.

Implementing the circuit

To actually run your circuit in the Xilinx XESS board, you need to first produce a "bitstream file" and then download this file into the XESS board. Here's how you do this:

Once you have designed and simulated your circuit, you are ready to add the elements necessary for implementing it on the XESS board. In particular you need to add the following symbols:

  1. Any inputs to your circuit must go through an IPAD symbol and then an IBUF symbol.
  2. Any outputs from your circuit must go through an OBUF symbol and then an OPAD symbol.
  3. If you ever use a system clock, it should use a BUFG symbol instead of an IBUF symbol.
In addition to PADs and BUFs, you need to tell the Xilinx tools how to map your inputs and outputs to actual pins on the Xilinx chip. Perhaps the most common way to do this is to use a User Constraint File (UCF). The format of a UCF is fairly simple: you simply specify which net names (from you schematic) should get mapped to which pins on the XESS board. For more details, take a look at this example UCF. You will probably want to use this file in your designs, since some outputs (such as for the LED display) must be mapped to particular pins on the XESS board, and our example file already takes care of such things.

To use use this UCF in your project (instead of the default one Xilinx creates), first copy it to your project directory. Then go into the Project Manager, select Implementation -> Implementation Options, and choose this constraint file. You can edit the UCF file by double-clicking on it in the Project Manager.  To modify our example UCF for your own use, just un-comment the lines that pertain to your design, and add any additional pin mappings that you require. In addition, you need some way to tell Xilinx which PAD/BUF in your schematic corresponds to which net name in your UCF. To do this, simply name the wire between the desired BUF and PAD (in your schematic), giving it the exact same name (case-sensitive!) as the corresponding net name in the UCF.  Note, however, that bus names can be given as either X[2] or X<2> in the UCF file.

The UCF contains lines for the pins connected to the 7-segment display.  Use these pins to connect the 7 outputs of your circuit.  Then add two lines for the data input and reset inputs for your circuit and assign them to pin 27 and pin 28.

We should point out that there's an alternative way of specifying pin mappings which you may wish to use. To do this, your first double-click on an IPAD or OPAD in the schematic to bring up its Symbol Properties dialog box. Under Parameters, enter LOC for the name, and Pxx for the Description (where xx is a pin number, from 0 to approximately 84). Then click on Add, and close the window. This can be convenient for user-definable pin locations, but for signals that need to be mapped to specific pins on the XESS board, using the UCF is probably much safer.

Downloading the Circuit to the XESS Board

Once you've added the necessary implementation infrastructure, you are ready to run through the implement phase of the Xilinx tools to produce a bitstream for the Xilinx part. To do this, go to the Project Manager and click on the Implementation button. In the dialog box that appears, make sure that you select 4010XLPC84 for the device, and '3' for the speed. If you don't see this device, then you need to go back to the File menu and change the Project Type to use the 4000XL series parts. Then click on the Run button. The Xilinx tools will start going through the five-phase implementation process.

At this point, it's possible you will get warnings or errors that will need to be looked at very carefully. To view the report file, select the Reports tab from the Project Manager screen, and then double-click on Implementation Report Files. If you get any errors, check the implementation report; you most likely just need to go back and tweak some things related to the I/O BUFs and PADs, or perhaps the pin assignments in the UCF.

The implementation phase, once successful, will create a bitstram (.bit) file in your project directory. (Note: if you need an older .bit file, it will be located in a \verXX\revXX subdirectory, since Xilinx automatically creates a new version and/or revision each time you complete the implement phase. The current version of your project can be found by looking on the Project Manager screen, right above the Design Entry button.)

Once you have the bitstream file you can download it to the XESS board using the 'xsload' program (located in 'c:\xstools\bin\'). This program downloads a bitstream onto the XESS board through a parallel-port cable that you plug into the PCs. To use it, simply connect the XESS board to your PC via the parallel cable, and plug-in the XESS board's power cord. Then run the xsload program from the Windows command prompt, giving it the name of your .bit file as an argument. That's all there is to it! Please note that the PCs in the lab are the only ones that have the xsload software installed, so you should not remove the parallel cables or the XESS boards from the lab.

Design Kits

To test your circuit, you will need to connect the XESS board to a protoboard containing two push-button switches.  This protoboard is supplied in your Design Kit.  Your project team will check out a Design Kit for the entire quarter.

PLEASE READ THE INSTRUCTIONS on using the protoboard is contained in the Design Kit web page. For this lab, you should pay particular attention to the section on switches.

Using the push-button switches

We will be using two push-button switches to provide the two inputs to the edge-counting circuit. Find the pushbutton switches in your Design Kit that have three terminals. One of these terminals is a "common" terminal while the other two are "normally-closed" (NC) and "normally-open" (NO). When the switch is not being pushed, it is in the open state. In this state, the common terminal is connected to the NC terminal. When the switch is being pushed, the common terminal is connected to the NO terminal. Use the multimeter to determine which terminal is which by measuring the resistance between terminals. Using either a resistor pak or a discrete resistor, connect the push-button switch as shown in the figure above, using the "normally-open" terminal so that the connection is made when the switch is pushed. The output of this switch should then go through an inverter in a LS7404 chip.  See the data sheet to see how the inverters are connected to the pins of this chip. Remember to connect Vdd and GND to the 7404 chip.  The output of the inverter should be 0 when the switch is not pushed, and 1 when it is. Test this out using your logic probe.

Repeat this process with the second push-button switch so that you now have two switches connected up. The next step is to connect these two switches to the inputs of your circuit in the Xilinx chip. This means that you will need to connect the XESS board to the protoboard. When you do this, you will use one power supply for the protoboard and another power supply for the XESS board.  To make this work without ruining things, you MUST CONNECT THE GROUNDS OF THE TWO BOARDS.

First disconnect all power supplies from the protoboard and the XESS board. The XESS board should be already be inserted into a couple protoboards to make it easy to connect to pins of the XESS board, which are connected to the Xilinx chip pins. The pins of the XESS board are numbered from 1 to 84, counter-clockwise around the board, starting in the center of the left-hand side of the board, down to the bottom pin (pin 21) then up the right-hand side of the board from pin 22 to 63, then down the left-hand side of the board from pin 63 to 84.

IMPORTANT:  Connect pin 52 (GND) of the XESS board to a GND bus on the Design Kit protoboard.  Before you plug power into the XESS board, doublecheck to make sure that you have the GND signals connected correctly. Use the multimeter to measure the resistance between the grounds on the two boards - it should be 0.  Also measure the resistance between Vdd and GND on the two boards - it should be very high (e.g. high enough not to register).

Next connect the two switches to pins 27 and 28 of the XESS board, which are connected to pins 27 and 28 of the Xilinx chip.

Now plug power into the XESS board and download and try out your circuit. Each press of the switch should give you a random number of counts because of the bouncing in the switch.

Debouncing Switches

We can debounce a switch by using a latch and using both the normally-open and normally-closed terminals of the switch as shown in the figure below.  The first contact of the switch will cause the latch to change state.  Then, even if the switch bounces, the latch will stay in the same state. Use a 74LS00 chip to implement the switch debounce circuit.
 
Reconnect the data input switch so that it is debounced and test your circuit to see if the debouncing worked.  Remember to disconnect power before you start rewiring your circuit!

Turn In:

  1. Schematics for your edge-counter.
  2. How many bounces do you count on average for your switch?
  3. Demonstrate both the un-debounced switch input and the debounced switch input to the TA and have them sign off on your schematic.

ebeling@cs.washington.edu