ALU design
I. Introduction
In this lab you are basically building a 2-bit ALU. You are required to
write a behavioral description of an ALU. Note: when constructing the
ALU, do not use LE's, AE's, and FA's as shown in the book. All you
really need are case statements, etc ...
For VHDL help look on the home page
The ALU should take in two
2-bit numbers and have the following functionality:
- Add the numbers (s2=0, s1=0)
- Subtract the numbers (0,1)
- NOR the numbers (1,0)
- NAND the numbers (1,1)
The output of the ALU will consist of one 2-bit result and a
carry/borrow bit. You are also required to write a testbench for
this design. You will have to feed values into your design and
demonstrate that it is correct by simulating your desgin using
ALDEC Active-VHDL--using the testbench you wrote.
Notes on design:
There are many ways to correctly implement this design.
You have to be careful to account for the carry bit and the borrow bit. You are subtracting B from A. Therefore, if B is bigger than A, the borrow bit will be one (the borrow bit is the sign bit in this instance).
When NOR'ing and NAND'ing, the borrow bit will always be zero.
Notes on testbench:
Your testbench should show that the design works in a good sample of problems--proving that it works in every possible situation would be difficult.
For our purposes, you should test at least each of the functions (add, subtract, nor, nand) and situations that use the borrow and carry bits. For this design, a good testbench will have a minimum of eight different cases. If you want to make more, it shouldn't be too difficult using cut and paste with a few changes.
II. Procedure
Implementing and simulating the design
- Run Active VHDL by clicking on the icon on the desktop.
If a window pops up regarding evaluation terms, click
on "I Agree"
- Create a new design and store in in C:\temp
- Select "Add existing resource files" if you have already typed
up your vhdl, otherwise select "Create new source files now"
- Once you have gotten you files loaded and compiled into Active
VHDL, select Simulation->Initialize Simulation. (If you
do not remember how to load and compile files go back to
the Aldec tutorial)
- Click on the small button next to the save icon to create a new
waveform.
- Select "Waveform->Add Signals" and add all the signals in your
testbench.
- Push the "Run" button and see if the output is what you hoped it
would be.
- If the design works correctly, demonstrate it to your TA.
- Copy your files to your network drive or a disk and remove them from the local machine so that other people cannot copy them.
- E-mail your lab report, design vhdl file, and testbench vhdl file to your TA.