CSE 171 Lab 6. Oct. 14-16, 2002.

EXPERIMENT 6: Adder/Subtractor

PRE-LAB

1.Read and understand text Sec. 6.2, Adders and Subtractors, pages 107-117.

2.Using textbook Figure 6.27 as a guide, write an ABEL program called addsub.abl for a 4-bit full adder/subtracter using a Xilinx XC95108 PC84 chip on a PLDT-1 unit. Start by assigning inputs A3..A0 to switches 1 to 4 (pins 6, 7, 11, and 5 respectively) and write a vector equation, A=[A3..A0]. Assign inputs B3..B0 to switches 5 to 8 (pins 72, 71, 66, and 70 respectively) and write a vector equation, B=[B3..B0]. Assign the control input E to the push-button switch (pin 10). Assign outputs SD3..SD0 to LEDs 5 to 8 (pins 39, 37, 36, and 35) and define a vector, SD=SD3..SD0. Also assign an overflow flag output, OVF, and a carry/borrow flag output, CBF, to LEDs 1 and 4 (pins 44 and 40 respectively).

3.In addition to input and output terms, you will need intermediate nodes to describe the 'B' input terms to the full adders and the intermediate carry terms. Simply add the equation, Bin=B$E, to describe a 'B' input vector and, for intermediate carry terms, add the following node and vector definitions:

C4..C0 NODE ISTYPE 'com'; " internal carry/borrow vector

Cin = [C3..C0]; " carry/borrow input vector

Cout = [C4..C1]; " carry/borrow output vector

4. In the EQUATIONS section, set C0 equal to E. Then, using textbook Figure 6.14 as a guide and by substituting the vectors SD for Si, Cout for Ci+1, Cin for Ci, A for Ai, and Bin for Bi, write equations for SD and Cout as a function of Cin, A, and Bin. Then, write equations for the overflow and carry/borrow flags, OVF and CBF, as a function of the intermediate carry terms, C4 and C3. Print out a copy of your file.

5.Complete the following table of test values for the adder/subtracter:

E A B BinOVFCBF SD

000000000______

000001111______

011110000______

001010101______

010101010______

000011111______

011110001______

011111111______

100001111______

100000001______

111101111______

101011010______

110100101______

100000000______

111111111______

111110000______

Using the results from this table make a set of test vectors in the following format and add them to the end of your ABEL program.

test_vectors ([E,A,B] -> [OVF,CBF,SD])

[0,0,0] -> [0,0,0];

------

------

------

LAB

1.Create a directory called <your name> under C:\CSE171 on the computer you are using in the lab. Create a new project called Lab6 using the Xilinx Project Navigator program. (See the Lab 2 tutorial for details.) Add your program addsub.abl to the project by using Project->Add Copy of Source… on the Project Navigator toolbar. Compile your program by double-clicking Generate Programming File.

2.Select addsub-vectors in the Sources in Project window. Double-click Generate Blif Simulation Report under Simulation Reports in the Processes for Current Source window. Double-click View Blif Simulation Report under Generate Blif Simulation Report. If there are no errors, print out this Blif Simulation Report.

3.Select addsubp.abl in the Sources in Project window. Program the Xilinx XC9508PC84 CPLD on the PLDT-1 board by double-clicking Configure Device (iMPACT) and then right-clicking on the picture of the Xilinx chip.

4.Test your adder/subtracter by setting the toggle switches to each of the test values given above in Pre-lab step 5 and confirm correct results for each. Demonstrate your adder/subtracter to your lab instructor and obtain your lab instructor's signature for your work on the .abl listing for the program addsub.abl.

5.Include the following in the lab report:

  1. A listing of your file, addsub.abl.
  2. A listing of the Blif Simulation Report.
  3. A copy of the results from Pre-Lab Part 5 above.

6.Delete the directory C:\CSE171\<your name> that you created at the beginning of this lab.