Verilog Design of a 32-bit ALU
Objective: In this lab exercise, you will
use Verilog hardware description language to design and simulate a simple
ALU, which will be used in later lab exercises. Verilog design provides an
alternative to ALU design in schematic.
ALU Specification: A 32-bit ALU that performs
AND, OR, addition, subtract, and set on less than.
The 32-bit ALU is shown in the figure. In your
design, output Overflow will not be considered. For the detail description,
please read Section 4.5 in the text book. The values of the three ALU control
lines Bnegate (Binvert and Carryln) and Operation and the corresponding ALU
operation are shown in the following table.
ALU control lines |
Function
|
000
|
and
|
001
|
or
|
010
|
add
|
110
|
subtract
|
111
|
set on less than
|
For the set on less than operation, the result
of ALU is 1 if a < b, and 0 otherwise.
Lab Requirements:
- to get familiar with Verilog design using Cadence, Prof. Chu provided
the help for your first erercise. The working steps for Verilog desing are
listed in Help of Lab 1. For more details about Cadence
version 4.4.5, go to User's Guide
to Cadence version 4.4.5 or online help.
- to get familiar with Verilog language, you could study the following
codes for a 32-bit ALU (see the figure 1 and
figure 2) that performs AND, OR, and addition.
The code alu3.v gives higher level behavioral descriptions
of the ALU. It uses case statement. Later you will learn to use other statements
to do the same design.
- to use Verilog (either structural description or behavioral description)
to design a 32-bit ALU that performs AND, OR, addition,
subtract, and set on less than operations described in the ALU Specification.
Hints:
- modify the code alu3.v to add subtract and set on less than operations.
- for the set on less than operation on
a and b, the result of ALU depends on the sign bit of (a-b), i.e., the highest
bit of (a-b).
- to debug the code and test the designed ALU on the cases given in
the following tables. Hints for Verilog code simulation:
- When there are no bugs in the Verilog code, save it and then open it
in read-only.
- In the window of Verilog-Editor Editing, select Verilog-XL from Tools.
The following steps are the same as those in schematic simulation.
- After the successful simulation, create the symbol of your designed
ALU. You need include ALU symbol in your later CPU design.
- to write report in English. The report
must be typed and include the Verilog code with short comments and simulation
results. In your report, you should explain why result of comparison (D8A3
B8D3 < 63B9 D6F2) is 0 rather than 1. Note D8A3 B8D3 is
negative.
AND: ALU control input: 000
|
a
|
b
|
Zero detect
|
Result
|
0000 0000
|
0000 0000
|
1
|
0
|
0F0F 0F0F
|
F0F0 F0F0
|
1
|
0
|
F0F0 F0F0
|
0F0F 0F0F
|
1
|
0
|
FFFF FFFF
|
FFFF 0000
|
0
|
FFFF 0000
|
D8A3 B8D3
|
63B9 D6F2
|
0
|
40A1 90D2
|
|
OR: ALU control input: 001
|
a
|
b
|
Zero detect
|
Result
|
0000 0000
|
0000 0000
|
1
|
0
|
0F0F 0F0F
|
F0F0 F0F0
|
0
|
FFFF FFFF
|
F0F0 F0F0
|
0F0F 0F0F
|
0
|
FFFF FFFF
|
FFFF FFFF
|
FFFF 0000
|
0
|
FFFF FFFF
|
D8A3 B8D3
|
63B9 D6F2
|
0
|
FBBB FEF3
|
|
addition: ALU control input: 010
|
a
|
b
|
Zero detect
|
Result
|
0000 0000
|
0000 0000
|
1
|
0
|
0F0F 0F0F
|
F0F0 F0F0
|
0
|
FFFF FFFF
|
4FFF FFFF
|
0000 0001
|
0
|
5000 0000
|
FFFF FFFF
|
0000 0001
|
1
|
0
|
D8A3 B8D3
|
63B9 D6F2
|
0
|
3C5D 8FC5
|
|
subtract: ALU control input: 110
|
a
|
b
|
Zero detect
|
Result
|
0000 0000
|
0000 0000
|
1
|
0
|
0000 0000
|
0000 0001
|
0
|
FFFF FFFF
|
0000 0001
|
3000 0001
|
0
|
D000 0000
|
0000 0001
|
0000 0001
|
1
|
0
|
D8A3 B8D3
|
63B9 D6F2
|
0
|
74E9 E1E1
|
|
Set on less than: ALU control input: 111
|
a
|
b
|
Zero detect
|
Result
|
0000 0000
|
0000 0000
|
1
|
0
|
0000 0000
|
0000 0001
|
0
|
1
|
0000 0001
|
3000 0001
|
0
|
1
|
0000 0001
|
0000 0001
|
1
|
0
|
D8A3 B8D3
|
63B9 D6F2
|
1
|
0
|
|
Back to Exercise Page of Computer Architecture Course
.