Lab Exercise 10: 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 a simple majority circuit. 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, below, 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 = !ABC + A!BC + AB!C + ABC. Note that we did not reduce the equation before writing the Altera text design file below. 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).  Load up the Altera (MaxPlus II) software.
  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 U: 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 (u:\) and project name should appear on he bar at the top of the screen after a short wait. Or, since you already have a program open for this project, you can simply select Set project to current file from the File:Project menu.
  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.
  5.  

  6. 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 ("Reserved"). Find the area where the device, turbo, and security options are listed (right above the pinout). Add your name around this area.
  7. 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. You should also put a copy of this diagram in your lab book.

     

  8. Simulate your program. Altera has a feature that allows you to simulate your program before you actually take the time to build your circuit.
    1. From the File menu, select New. Specify a waveform file with an extension of .scf. A simulation file window will appear.
    2. 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.
    3. 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
    4. 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.
    5. 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.

     

  9. Program your chip. The Altera programmer is located in the Southwest 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.
  10.  

  11. Take your chip back to your workstation and install it in the PLCC adapter board.

     

  12. Use the logic probe to test the output of your circuit by sampling the F output from your Altera chip. If you slow the protoboard clock enough so that you can hear the transitions, you should be able to match the lights and tones to the timing diagram output "song" you expected.

     

  13. Call one of the lab TA's over to look over your wiring and confirm your working circuit. TA sign here _______

     

  14. Now you need to use a logic analyzer to visually confirm the timing diagram for your circuit. Take your chip out of the socket and bring it to the protoboard connected to the logic analyzer testing station.

    1. Plug your chip into the socket in the testing station. The testing unit should already be connected to the logic analyzer. If not, follow these instrutions:
      • From the logic analyzer pod, attach line 0 on the pin header to signal A on your circuit. Likewise, attach lines 1 and 2 to signals B and C, respectively. Having the three input stimuli attached to the logic analyzer will enable you to monitor your A, B, and C inputs.
      • Next, attach line 3 from the logic analyzer pod to a pin header that comes into contact with the output ("F") of your circuit.

    2. Note: When working with digital circuits, it is extremely important to establish a common ground between all parts of the circuit and any instruments acting on the circuit. Otherwise, the circuit simply may not work. On the logic analyzer pod, locate a ground lead (the black wires with green heat shrink) and connect this into a GROUND on the protoboard. This establishes a common ground between your circuit and the logic analyzer.

    3. Login to the PC that your logic analyzer is connected to (log into windows only, you do not need to log into the network). Open the logic analyzer software called LA Viewer. There should be an icon on the desktop, or you can find it in the start menu.
    4. To be sure you haven't damaged your wiring while moving and attaching it to the logic analyzer, use the logic probe again to confirm that your output F is still working.

    5. It is best to obtain software instructions from the Instructor or TA and have them help you through this process.

      • In LA Viewer you will see 16 channels on the left (0-15) where each one corresponds to a colored wire coming out of the logic analyzer. In our case, we are only using 4 channels (Ch-0...Ch-03) for A, B, C, and F. We should get rid of all remaining channels by holding control to select multiple channels with the mouse, highlight all channels except the ones we are using. Press delete or right-click on the selected and choose 'delete label'.
      • To the upper right of the program you will see a clcok speed in Hertz, this is how fast the program is going to sample the input, so you want this speed to be much faster than the protoboard clock. A good speed for each is 10kHz for the function generator and 5MHz for LA viewer.
      • When the clock speeds are set at the desired values, acquire the signal by clicking the "man running" icon. Your data should appear on the screen. Depending on your clock speeds, you may need to zoom in or zoom out (using the magnifying glass) to clearly see about two cycles through the truth table combinations on A, B and C. An easy way to check your values is to slide the blue marker at the top of the window over a transition period of the timing diagram and check to make sure that the blue numbers on the left match your truth table.

    6. When you are finished with the logic analyzer timing diagram, print a copy for your lab book. The simplest way to do this is to print an application screen shot.
      • Unmaximize the application window.
      • Using the corner drag tool, resize the application window such that it shows only the portion of the window we need (including your signal lines with minimal blank space below).
      • Hold 'Alt' and press 'Print Screen'. This places a screenshot of the application window on the clipboard.
      • Use Open Office to open a text document and paste the image into the document (ctrl-v works to paste).
      • Print the document.

     

  15. Paste the waveform printout into your lab book and describe the results.

 


March 2001

Copyright 2001, New Mexico Tech