Department of Electrical and Computer Engineering
ECED
4260 IC Design and Fabrication
Lab4 Arithmetic Logic Unit
OBJECTIVES
-
To
Design and Implement an Arithmetic Logic Circuit
-
Integrate a
behavioral control path and a structural data path in a single design
-
Implement a
digital system using MAX+plus II and UP1 boards and observe the operation
Design Problem
Consider the 4-bit Arithmetic Logic Unit (ALU) below:
This design lab will solve the GCD (greatest common divisor) problem.
That is to take two 4-bit unsigned binary numbers, a and b, and compute
their greatest common divisor, the largest number that will divide evenly into
both numbers. The digital system is implemented on the UP1 boards.
To solve the GCD
problem, the following GCD algorithm was used:
function gcd(u,v)
load u and v;
while u /= v do
if u > v then
u := u - v;
else
v := v - u;
end if;
end while;
output u or v;
end gcd;
The final digital
system should be like this:
1) When the system
is first powered up, the user shall press the RESET push button to force the
system into initial state. Then the user uses a set of four toggle switches to
input the two numbers a and b. a and b can’t be zero input.
2) The system
accepts a when the enter push button is pressed, same as number b.
3) The system
calculates the GCD of the two numbers after the two numbers are accepted. Four
LEDs labeled L3-L0 display the results.
4) An LED labeled
DONE indicates that the first GCD calculation has been computed. Then subsequent
GCDs may be computed using the same procedure.
The Lab Assignment
The design will be composed of a distinct control path and data path, which will
be put together and programmed into an Altera MAX7128SLC84-7 FPGA.
Part I: Data
Path
There are also some constraints for the data path design. First is that data
path should be designed structurally. Second is that behavioral or other
explicit comparator operations can not be used within design, and only one 4-bit
adder and four two-input XOR gates are allowed within code for the data path.
Base on the algorithm, we can design the data path.
Two binary numbers are input to the system through four switches. There are
three primary operations taking place after the loading of the initial values:
- Comparison of the values u and v.
- Subtraction of one number from another.
- Assignment of the difference to either the u or v register.
The following data path diagram can be derived from the above algorithm:

The algorithm can be distilled into the following processes:
- If the sum of the register v and -u is greater than zero, that sum is
placed un-inverted into the v register.
- If the sum of the register v and -u is less than zero, that sum is placed
into the u register.
- If the sum is zero, the algorithm is done and the result can be found in
either the -u or v registers (since the difference is zero, one result is
inverted and the other is not).
Therefore the three operations of comparison, inversion, and assignment are
accomplished as follows:
-
Comparison
- The comparison result comes from the carry out of the adder. (The zero
detection should be fairly obvious).
-
Inversion - The 2's complement of a
number is found by XOR-ing the number bit-wise with a 1, and then adding a 1
afterwards using the carry in of the adder.
Assignment - when the sum is presented, it is loaded into one of the u or v
registers as the algorithm requires.
Part II: Control
Path
Part III: Final Design
Part IV: Hardware
Implementation
As a portion of this lab involves actual implementation of a digital
system in hardware, it is important that several important points be made about
how to handle this hardware.
Large transient voltages such
as those present with static electricity can permanently damage the FPGAs. In short, you must take special precautions in handling
the UP1 boards and preventing the build up of static electricity on your
body.
The following guidelines will help in greatly reducing the chance
of damage to the devices:
-
When the board is not in use, store it in the static bag
that is provided.
-
When handling the board, hold it by its edges. Do not touch
any of the components or board traces directly (except, of course, for
the switches and the power).
-
Do not carry the board in or work with the board in clothing
or near other material that may generate static electricity, particularly
wool or fleece.
-
Do not work with the board on carpeted surfaces.
-
Ground yourself by using a grounding strap whenever handling
the board.
Static electricity is not the only concern, and the following
points will also help to prevent harm to the board and ensure proper operation:
-
Do not lay the board on any metal surface. The back side
of the board has exposed traces, and you will short out the board pins
and probably destroy the FPGA. This also means do not lay the board
on the static bag.
-
When powering the board, ensure that the applied polarity
is correct. A protection diode exists in case you reverse power and ground,
but do not rely on this.
-
Do not carry the board in a backpack near heavy objects or
a jacket pocket where it might get broken.
-
Do not use the board for any other projects or courses.
-
When programming the board, ensure that the device part number
in the MAXplusII software exactly matches the device on the board.
The replacement cost of the UP1
board has been estimated
to be upwards of $200. By taking these precautions and using common sense,
you will hopefully be able to return the hardware intact.
Programming the UP1 board with the final design.
- Ensure that your VHDL code simulates properly before you try
programming the UP1 board. It is the EPM7128SLC84-10 device.
- Also make sure that you did the pin assignments including the clock.
- The pin outs of the number switches, LEDs, and push buttons can be found
on the UP1 Help Sheet.
- FTP your *.pof file from your design directory onto the local hard drive.
- You will notice there are two connections that you have to make to your
board - the ByteBlaster cable and the power. The Byte Blaster cable
should be on the bench and is connected to the computer you are using to program.
- Connect the ByteBlaster cable to the UP1 board, and then connect the power
from power supply. Use the wires and wire strippers provided in the room to
connect power. Note: do not connect power the wrong way, and align the
notch on the ByteBlaster cable with the connector when inserting, or you risk
damaging the board. Check the polarity of the power connection before
you try turning on the power supply.
- Turn on the power supply. You should see the power light come on.
- Start MAXplusII from the Programs menu in Windows.
- Click on the Programmer menu selection under the MAXplusII menu. You should
see a new window pop up. Make sure it is selected for the rest of the programming
procedure, or you will miss some of the menu items.
- Click on Multi Device JTAG Chain setup under the JTAG menu. Then choose
the device name to be EPM7128S.
- In the same window, click on the Select Programming File button and choose
the top level file name with the .pof extension. Then click on Add which is underneath the Cancel button.
- In the same window, click on Detect JTAG Chain Info. When this is done,
you can click on Ok. Note: For those of you who don't know, JTAG is
a digital test standard (IEEE 1149.1) that happens to be built into the MAX7000
FPGAs. The details of how it works won't be covered here, but it is important
that you set this up or programming will not proceed properly.
- Finally, click on Program in the Programmer Window to program your device.
When it is finished, unplug power first and then the ByteBlaster cable.
- Plug power back into your FPGA and assert Reset. wiring
up the FPGA and go through your test cases
and see if your board works.
Pin Assignments
To assign pins on the MAX7128SLC84-7 FPGA use one of the following procedures:
Using Back Annotation
This method of assigning pins is useful if you are planning on assigning all
(or most of the signals) in your design, as you can have Maxplus II auto assign
the pins and just modify the pin assignments without having to remember the
list of external signals that need to be assigned.
- Assign the device (EPM7128SLC84-7) to your project and compile your design.
- Click on Assign->Back-Annotate Project and check Chip, Pin & Device
and click OK.
- Click on Assign->Pin/Location/Chip, in the window with the title
Existing
Pin/Location/Chip Assignments is the list of pins that have been assigned
to signals.
- Select each one and reassign each pin by changing the value in the
Pin
box and clicking on the Change Button. If there are any signals in there
that shouldn't be (such as test signals you created) then select them and
click on the Delete Button. Note that vectors are assigned bit-wise, e.g.
a[3..0] is assigned as a3, a2, a1, a0. Make sure all the necessary signals
are assigned.
- Recompile your design and as long as you do not delete your acf file, you
will not need to reassign the pins (unless you made a mistake or have to add
something).
- Pin assignments are stored in files with the extension *.acf, if you need
to delete files created by Maxplus II, this is one file that you will want
to save with your VHDL files and this way you don't have to reassign the pins
for your design.
Normal Pin Assignments
This method of assigning pins is useful if you need to assign only a subset
of the external signals (maybe because some of them are test signals and you
don't want to assign those).
- Assign the device (EPM7128SLC84-7) to your project and compile your design.
- Click on Assign->Pin/Location/Chip
- In the Node Name box, type in the signal name and the direction of
the signal (input or output) will be automatically specified in Pin Type
box, make sure this is what you expected. Enter the pin number in the Pin
box and click on the Add button. For signals that are vectors, assignment
has to be done bit-wise, so for a signal A[3..0] you need to assign pins to
A3, A2, A1 and A0.
- Once you are done entering all your pin assignments click on the OK button.
- Recompile your design and as long as you do not delete your acf file, you
will not need to reassign the pins (unless you made a mistake or have to add
something).
- Pin assignments are stored in files with the extension *.acf, if you need
to delete files created by Maxplus II, this is one file that you will want
to save with your VHDL files and this way you don't have to reassign the pins
for your design.
Final Report
- The preparing elements from Part I and Part II.
- Your VHDL code from Part I and Part II
- Your annotated waveforms from Part I and Part II.
- Your experimental results from Part III
- Answer the lab questions in the body of your report if there is any.
Created by Jason Gu
Last Updated: September, 2011