EE 101

Lab Exercise 9: Introduction to Programmable Logic - Altera EPM7032

(There is no pre-lab for this exercise)

 

Your assignment in this lab exercise is to use a programmable logic device (PLD) to implement a combinational logic circuit. The circuit you will program into the Altera EPM7032 EPLD is identical to the majority circuit we just designed in class (to blow up the Enterprise). For this lab, the AHDL (Altera Hardware Description Language) file that you would normally be responsible for writing has been provided for you below. The purpose of this exercise is merely to familiarize you with the Altera PLD programming software.

 

A sample AHDL program, Figure 1, implements the majority circuit. The truth table for this circuit is shown in Figure 2. The canonical sum of products expression for the majority circuit is F = A’BC + AB’C + ABC’ + ABC. Note that we did not reduce the equation before writing the Altera text design file in Figure 1. The Max+plus II software does this automatically.

 

SUBDESIGN majority
(
A,B,C :INPUT;
F :OUTPUT;
)
BEGIN
F=(!A and B and C) or
(A and !B and C) or
(A and B and !C) or
(A and B and C);
END;

 

Figure 1: AHDL program for a three input majority circuit.

 

A B C F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

 

Figure 2: Truth table for a three bit majority circuit.

1. Login to a PC (Windows NT network). Double click on the Altera icon on the desktop. The Altera software will take a minute to load. Altera can also be brought up by selecting it from taskbar, under the Programs menu (select MaxPlus II).

 

2. Under the File menu, select New. A small window will appear. Click on Text Editor File and OK. A window will appear. Before doing anything else, go to the File menu and choose Save As. Select the D: drive and, in the File Name field, type in majority.tdf and click on OK.

 

3. From the File menu choose Project and choose Name. Enter "majority" in the Project Name field, or select majority with the mouse and click on OK. Your path (d:\) and project name should appear on he bar at the top of the screen after a short wait.

 

4. Type the program as given in Figure 1 in the majority.tdf window. It would be wise to save your program (File menu, Save) after you complete every few lines. This way, if your computer or the network "crashes", you will not have to retype all of your work.

After you have finished typing in the program, save it one more time. Then, go to the Max+plus II menu and choose Compiler. Do not hit the Start button yet.

Before starting the compilation, you will specify the device type you want to use. Lots of PLDs are supported by the Max+plus II software, and there is a built-in feature that lets Altera pick the best chip for you. The PLD we are using in this lab is the EPM7032LC44.

We will make sure that the proper device and package are chosen by first going to the Assign menu and selecting Device. First, uncheck the box that reads Show Only Fastest Speed Grades. You should see two fields, one for Device family and the other for specific Devices. In the Device Family Field, select MAX7000 (if it is not already selected). In the devices field, select EPM7032LC44-15. Hit OK.

Now click the Start button on the compiler window. If there is problem with the .tdf file you created, you will find out now. If the compilation process stops and reports errors, fix these, re-save your program, and resume compiling (hit the Start button again). Ask for assistance if you have trouble fixing your errors and compiling. After the program compiles with no errors, hit OK. After compilation, several new files have been added to your directory. They are all called majority, but their extensions vary: .cnf, .fin, .fit, .hif, .ini, .mmf, .pof, .prb, .rpt, .snf, and .sym.

 

5. Take a look at your .rpt file. (File, Open majority.rpt, or just click the rpt icon in the compiler window). Scroll down to find the picture of the chip. Note the pinout, and which pins are connected to what, and which are deliberately not connected. Find the area where the device, turbo, and security options are listed (right above the pinout). Add your name around this area.

 

By highlighting the area with your mouse, select your name, the picture of the PLD, and the pinout information which follows it. Print out your highlighted portion. (File ~ Print ~ 1 copy ~ Selected Area). Go to the printer and wait for your printout. You will use this picture of the chip to wire up your circuit.

 

6. Simulate your program. Altera has a feature that allows you to simulate your program before you actually take the time to build your circuit.

a. From the File menu, select New. Specify a waveform file with an extension of .scf. A simulation file window will appear.

b. In the simulator file window, go to the Node menu and select Enter Nodes from SNF. Boxes for the input and output signals should already be checked. Click on the List button. The A, B, and C inputs and the F output will be listed (and highlighted) in the Available Nodes & Groups field. Click on the right arrow to send these signals to the Selected Nodes & Groups field. Click on the OK button to close the signal selection window. Signals A, B, C, and F should show up in your simulator window.

c. Click the File menu and select End Time. Enter a total simulation time of 800ns. Go to the Options menu and select Grid Size. Enter a grid size of 100ns.

d. Click on the tab next to the C input signal. The entire waveform for C should become highlighted. Go to the Edit menu and select Overwrite and then Count Value. Click on OK. The C signal should have become a periodic TTL waveform. (If needed, adjust the zoom controls so that you can see 4 high parts and 4 low parts for the C signal.) In the same way, highlight the B signal, go to the Edit menu and Select Overwrite. This time, enter a value of 2 in the Multiplied By box and choose OK. Finally, highlight the A signal and overwrite it as you did the others, changing the Multiplied By box to 4. Note that signals A, B, and C count from 0002 to 1112.

e. Save your file as majority.scf. Under the Max+plus II menu choose Simulator and Start. The F signal should be generated. Draw a truth table showing the results of your simulation. If your truth table does not agree with the one from Figure 1, check the program you wrote for obvious problems.

 

7. Program your chip. The Altera programmer is located in the Northwest corner of the lab. Since the programmer PC is networked with the rest of the lab, you can access your files from there. When you are ready to program your chip, let a lab assistant know so he or she can guide you through the process.

8. Take your chip back to your workstation and install it in the PLCC adapter board. Note that certain pins are always going to be tied to Vcc and GND. For the EPM7032, pins 3, 15, 23 and 35 are always tied to Vcc, and pins 10, 22, 30 and 42 are always tied to ground. We have designed the adapter board to join these Vcc and ground pins together. All you have to do is to connect a single wire from the VCC port on the adapter to +5 volts on the protoboard, and another wire from GND on the adapter to ground on the protoboard. Note (from the printout of your chip) that there are possibly other grounds and Vcc’s that you will still need to hook up. These pin assignments will vary from project to project.

Take care that your chip has the proper orientation, and let a lab assistant witness you plugging the chip into its socket. Make sure all GND and Vcc wires are hooked up properly to the device. Hook the output (F) of the Altera chip to an LED on the breadboard. Test your device first by using +5V and ground as inputs, and a logic probe for the output. Construct a truth table with your results. It should agree with the truth table in Figure 2.

 

9. Once you are convinced your circuit is working properly, hook up the stimulus generator (or counter) and logic analyzer as you did last week. It would be wise to exit Altera completely before running the logic analyzer and stimulus generator software. Refer to your lab from last week to remind you how to use the stimulus and logic analyzer. If you get stuck, ask for help!

Construct a truth table with your results. Again, this should agree with the truth table in Figure 1.

Print out a copy of your waveform data (for one cycle of inputs only) and tape it into your lab book.