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:

  1. 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.
  2. 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.
  3. 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:
  4. to debug the code and test the designed ALU on the cases given in the following tables. Hints for Verilog code simulation:
  5. 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 
Zero detect 
Result 
0000 0000 
0000 0000 
0F0F 0F0F 
F0F0 F0F0 
F0F0 F0F0 
0F0F 0F0F 
FFFF FFFF 
FFFF 0000  
FFFF 0000 
D8A3 B8D3 
63B9 D6F2 
40A1 90D2 
OR: ALU control input: 001 
 Zero detect
 Result
0000 0000 
0000 0000 
0F0F 0F0F 
F0F0 F0F0 
FFFF FFFF 
F0F0 F0F0 
0F0F 0F0F 
FFFF FFFF 
FFFF FFFF 
FFFF 0000 
FFFF FFFF 
D8A3 B8D3 
63B9 D6F2 
FBBB FEF3 
addition: ALU control input: 010 
Zero detect
Result 
0000 0000 
0000 0000 
0F0F 0F0F 
F0F0 F0F0 
FFFF FFFF 
4FFF FFFF 
0000 0001 
5000 0000 
FFFF FFFF 
0000 0001 
D8A3 B8D3 
63B9 D6F2 
3C5D 8FC5 
subtract: ALU control input: 110 
Zero detect 
Result 
0000 0000 
0000 0000 
0000 0000 
0000 0001 
FFFF FFFF 
0000 0001 
3000 0001 
D000 0000 
0000 0001 
0000 0001 
D8A3 B8D3 
63B9 D6F2 
74E9 E1E1 
Set on less than: ALU control input: 111 
Zero detect 
Result 
0000 0000 
0000 0000 
0000 0000 
0000 0001 
0000 0001 
3000 0001 
0000 0001 
0000 0001 
D8A3 B8D3 
63B9 D6F2 
1

Back to Exercise Page of Computer Architecture Course .