|
|
|
Lab 4 - Tutorial - Introduction to Sequence
Detectors and Coolrunner CPLDs
This tutorial highlights the initial steps of creating a project on programmable logic. The main difference between this lab and earlier ones is that this lab will not stop with merely simulating the project. The programmable device you will be using is the Coolrunner CPLD. The sequece detector creater here will detect the sequence 10010. Launch Project Navigator from the desktop or from the Start menu. Go to File, New Project. Make sure the chosen values are the ones listed below. It is essential to choose the correct CPLD part number for the project to work. There are ways to change this part number after creating the project, but it is just easier to get it correct the first time. As for project name, choose whatever name you wish.
There are certain things you should gain from looking at the simulation.
First, look for specific output occurrences based on specific inputs.
This current simulation says that if the required sequence is accompanied
with a low reset and rising clock edges on each instance of the
bit, the result will be a high output on Z. It says nothing about
what will happen given any other set of inputs. For an exhaustive
and complete simulation, you would have to spend a great deal of
time actually working through ALL the possible combinations of inputs.
This is beyond the scope of this project. It is impossible to say
enough about simulation. Every hour you spend on making sure your
simulation works and that your device is operating the way you expect
pays you hours that you will not spend debugging your projects later.
The fact that your simulation works is not a guarantee that your
final project will work, but it is an indication that you might
be heading the right direction. The intention of this project is
to tie three inputs to three switches and seven outputs to seven
LEDs. My original plan was to use SW1 for my clock but this did not work. The reason it did not work is an excellent aside that you should be aware of. There is a term called debouncing. If you can imagine a ball bouncing between one and zero, that is what happens with some mechanical devices like switches. Even though to you it may seem that you are sliding the switch from zero to one, the delicate circuitry within the CPLD sees this as a series of ones and zeros. These switches are described as dirty due to these characteristics. For our benefit, the buttons on the xcr board are debounced which means that each time we push them, we get exactly one transition from zero to one and then back to zero when we release it. To solidify my inputs and outputs, I have to edit my user constraints. This means I am going to constrain my project to do what I wish in terms of my inputs and outputs. Make sure you have the main file highlighted (not the testbench). Go to the Project menu. Select New Source. You should be looking at a window like the one below.
This will actually be very important in later projects where you will be using 5-10 VHDL files in a single project. As you can see, it shows our three inputs and our seven outputs. This is where we will identify our locations (pins) on our CPLD and tie them to our desired descriptive outputs. This is one of the places where the real beauty of programmable chips begins to shine. If I were to make a mistake and pick the wrong pins, it is easy enough to come back to this spot and make a change. The pinouts for the Digilent board ARE HERE. By opening up this document and looking at the bottom of the last page you will find a chart (table 3) that translates from pin number to function. Here are the desired assignments for my variables. clk BTN1 You will need to look up the pin numbers and enter them into the Location field. Once you have finished entering the pin numbers click the Save button and close the window. This closes the Constraints Editor and brings us back to the project. Ensure that the project VHDL is highlighted and then double click on the Synthesize circular icon. You may get a notice asking you to reset or return. Choose reset. You are now leaving your test bench behind. Its sole purpose is to help with simulation. Once you double-click on synthesis then the software is going to begin to transform your descriptive language into what is called a netlist. Next you will need to double click on the circle next to Implement Design. Here is a slide from Xilinx that shows you how they interpret what is going on.
You may receive a warning about invalid target architecture. You will know this by seeing a yellow explanation mark on next to exclamation. If you do not, do not worry about it. If you do, scroll up (in the lower section) until you find the warning. You will note that it has a little yellow "web" symbol next to it. If you right click on it and go to solution record it will take you to the Xilinx solutions Internet site. If there is a record of your error or warning, it will identify it and provide you with any additional information. This is a very handy feature for larger projects. Once implementation is complete you will get a green check mark or a yellow exclamation mark next to Implement Design (both are acceptable). Let's go into Implement Design and see some of the results. Click on the "+" to expand Implement Design. Expand Fit and double click on Fitter Report. You will want to print the first couple of pages of this since you will need it for one of your deliverables. Now double click on View Fitted Design. This will lauch ChipViewer. You will need to be patient as this program may take a few minutes to launch. Click on the top view button on the top tool bar. By looking at the chip above you can see where your three inputs and seven outputs are located. The black dot in the upper center can be seen on the chip as a small dimple above and over the side from the word Xilinx. Please avoid putting your fingers on the chips, as they are extremely electrostatic discharge sensitive. Close chip viewer and return to the main program. Now we will want to double click on the circle next to the Generate Programming File. You should be rewarded with a green check mark. Now we are down to the final steps of actually programming the device. Expand the Generate Programming File section and double click on the Configure Device (iMPACT) icon to launch iMPACT. iMPACT stands for intelligent Multi-purpose Programming And Configuration Tool. An Operation Mode Selection dialog box will come up. Choose Configure Devices and click Next. Then a Configure Devices dialog box will pop up. Choose Boundary-Scan Mode and click Next. Then a Boundary-Scan Mode Selection dialog box will come up. Choose Automatically connect to cable and identify Boundary-Scan chain and click Finish. Click Ok. An new window like below will pop up. Browse to the directory of your project and open seq_req.jed (unless you renamed the file).
Click on the Xilinx chip to highlight it. It will turn green.
Then, click on Operations, Program. The following window will appear. Make sure all of the options are the same and click OK.
Once the device has been successfully programmed you will see the following:
We start by resetting the board, which means setting the reset high. Pushing switch 2 away from you does this. It will probably be helpful for you to be looking at your state diagram (ModelSim waveform from testbench) and your VHDL while you are testing out the device. What you will notice is that with reset high, no matter how many times you change X or how many clock pulses you give the button, you will stay in state A. Now we are going to set reset to low and begin looking for the sequence. Give X a high by pushing it away from you and then giving the clock (BTN1) a push. You should have stepped to state B with corresponding LD2 being lit. Set X to 0 by pulling SW3 back to you and giving a clock pulse. Continue through your sequence until you see Z (LD7) lit. As a design engineer you would continue testing your design until
you were comfortable that it worked as requested. You could think
of the sequence as a series of failures in a device and the corresponding
output of LD7 as activation of a warning light. Now reach up and
switch the power off and on to the power strip. What you will find
out is that the devices programming (and your UES) are stored on
the chip. At this point you could remove the device and ship it
off (but please do not do so). |
alnz - Last update: June 21, 2004