0% found this document useful (0 votes)
11 views7 pages

Computer Architecture Project: Ministry of Education Taif University College of Computers & Information Technology

The document outlines the design and implementation of an 8-bit Arithmetic Logic Unit (ALU) for a Computer Architecture course at Taif University. It details the project objectives, design stages, including requirement analysis, functional specification, and implementation in Verilog HDL, as well as testing procedures. The ALU is capable of performing 14 operations, including arithmetic, logic, and shift operations, and adheres to modular design principles.

Uploaded by

mohmmadmohy52
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Computer Architecture Project: Ministry of Education Taif University College of Computers & Information Technology

The document outlines the design and implementation of an 8-bit Arithmetic Logic Unit (ALU) for a Computer Architecture course at Taif University. It details the project objectives, design stages, including requirement analysis, functional specification, and implementation in Verilog HDL, as well as testing procedures. The ALU is capable of performing 14 operations, including arithmetic, logic, and shift operations, and adheres to modular design principles.

Uploaded by

mohmmadmohy52
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Kingdom of Saudi Arabia

Ministry of Education
Taif University
College of Computers & Information Technology

Computer Architecture Project


Course Code: 503323-3
8-bit Arithmetic Logic Unit (ALU) Design

Student Name: Your Name


Student ID: Your ID
Taif University - Computer Architecture Project: 8-bit ALU Design

Contents
1 Introduction 2

2 Project Objective 2

3 Design Stages 2
3.1 Requirement Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.2 Functional Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.3 High-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.4 Detailed Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.4.1 Arithmetic Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.4.2 Logic Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.4.3 Shift Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.4.4 Output Multiplexer . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Implementation 5

5 Testing 6

6 Conclusion 6

Page 1 of 6
Taif University - Computer Architecture Project: 8-bit ALU Design

1 Introduction
This project presents the design and implementation of an 8-bit Arithmetic Logic Unit
(ALU) for the Computer Architecture course (503323-3) at Taif University. The ALU
is a critical component of a CPU, capable of performing arithmetic, logic, and shift op-
erations. The design is organized into stages, including requirement analysis, functional
specification, high-level and detailed design, implementation in Verilog HDL, and test-
ing. The solution adheres to the project requirements, ensuring all 14 operations are
implemented and documented.

2 Project Objective
The objective is to design an 8-bit ALU that performs:

• Arithmetic Operations: Addition, Addition with carry, Subtraction, Subtraction


with borrow, Decrement, Increment, Transfer.

• Logic Operations: AND, OR, XOR, NOT.

• Shift Operations: Logical Shift Right, Logical Shift Left.

The operations are selected using five control inputs (S3 , S2 , S1 , S0 , Cin ), as specified in
the function table.

3 Design Stages
3.1 Requirement Analysis
• Inputs:

– Two 8-bit operands (A[7 : 0], B[7 : 0]).


– Five control signals (S3 , S2 , S1 , S0 , Cin ).

• Outputs: 8-bit result (F [7 : 0]).

• Operations: 14 operations (8 arithmetic, 4 logic, 2 shift).

• Constraints: Modular, combinational design, implementable in hardware.

3.2 Functional Specification


The ALU performs operations based on the following function table:

3.3 High-Level Design


The ALU comprises three units:

• Arithmetic Unit: Handles arithmetic operations using an 8-bit adder.

• Logic Unit: Performs bitwise logic operations.

Page 2 of 6
Taif University - Computer Architecture Project: 8-bit ALU Design

Table 1: ALU Function Table


S3 S2 S1 S0 Cin Result Operation
0 0 0 0 0 A+B Addition
0 0 0 0 1 A+B+1 Addition with carry
0 0 0 1 0 A+B Subtraction with borrow
0 0 0 1 1 A+B+1 Subtraction
0 0 1 0 0 A−1 Decrement
0 0 1 0 1 A Transfer
0 0 1 1 0 A Transfer
0 0 1 1 1 A+1 Increment
0 1 0 0 X A·B AND
0 1 0 1 X A+B OR
0 1 1 0 X A⊕B XOR
0 1 1 1 X A NOT
1 0 0 X X LSR A Logical Shift Right
1 0 1 X X LSL A Logical Shift Left

• Shift Unit: Executes left and right shifts.

A multiplexer selects the output based on S3 , S2 . The block diagram is as follows:

3.4 Detailed Design


3.4.1 Arithmetic Unit
• Core Component: 8-bit adder supporting twos complement.

Page 3 of 6
Taif University - Computer Architecture Project: 8-bit ALU Design

• Operations:

– Addition: F = A + B.
– Addition with carry: F = A + B + Cin .
– Subtraction: F = A + B + 1.
– Subtraction with borrow: F = A + B.
– Increment: F = A + 1.
– Decrement: F = A − 1.
– Transfer: F = A.

• Control Logic:

Table 2: Arithmetic Unit Control Logic


Operation S1 S0 Cin Binput Cin to Adder
Addition 000 B 0
Add + carry 0001 B 1
Sub w/ borrow 0010 B 0
Subtraction 0011 B 1
Decrement 0100 11111111 0
Transfer 0101 00000000 1
Transfer 0110 00000000 1
Increment 0111 00000000 1

3.4.2 Logic Unit


• Operations:

– AND: F = A ∧ B.
– OR: F = A ∨ B.
– XOR: F = A ⊕ B.
– NOT: F = A.

• Implementation: Bitwise logic gates with a 4-to-1 multiplexer controlled by S1 S0 .

3.4.3 Shift Unit


• Operations:

– Logical Shift Right: F = A >> 1 (LSB = 0).


– Logical Shift Left: F = A << 1 (MSB = 0).

• Implementation: Simple wiring for 1-bit shifts, selected by S1 .

Page 4 of 6
Taif University - Computer Architecture Project: 8-bit ALU Design

3.4.4 Output Multiplexer


Selects output based on S3 S2 :

• S3 S2 = 00: Arithmetic unit.

• S3 S2 = 01: Logic unit.

• S3 S2 = 10: Shift unit.

4 Implementation
The ALU is implemented in Verilog HDL. The code is provided below:
1 module alu_8bit (
2 input [7:0] A , B , // 8 - bit operands
3 input [3:0] S , // Selection inputs S3 , S2 , S1 , S0
4 input Cin , // Carry - in
5 output reg [7:0] F // 8 - bit result
6 );
7 wire [7:0] arith_out , logic_out , shift_out ;
8 wire [7:0] B_mod ;
9 wire Cin_mod ;
10

11 // Arithmetic Unit
12 assign B_mod = ( S [1:0] == 2 ’ b01 ) ? ~ B : //
Subtraction : NOT B
13 ( S [1:0] == 2 ’ b10 && ! Cin ) ? 8 ’ hFF : //
Decrement : -1
14 8 ’ h00 ; //
Increment / Transfer : 0
15 assign Cin_mod = ( S [1:0] == 2 ’ b00 ) ? Cin : //
Addition : use Cin
16 ( S [1:0] == 2 ’ b01 ) ? ~ Cin : //
Subtraction : invert Cin
17 ( S [1:0] == 2 ’ b10 && Cin ) ? 1 : //
Transfer : Cin =1
18 ( S [1:0] == 2 ’ b11 ) ? 1 : //
Increment : +1
19 0; //
Decrement : -1
20 assign arith_out = A + B_mod + Cin_mod ;
21

22 // Logic Unit
23 wire [7:0] and_out = A & B ;
24 wire [7:0] or_out = A | B ;
25 wire [7:0] xor_out = A ^ B ;
26 wire [7:0] not_out = ~ A ;
27 assign logic_out = ( S [1:0] == 2 ’ b00 ) ? and_out :
28 ( S [1:0] == 2 ’ b01 ) ? or_out :
29 ( S [1:0] == 2 ’ b10 ) ? xor_out :
30 not_out ;

Page 5 of 6
Taif University - Computer Architecture Project: 8-bit ALU Design

31

32 // Shift Unit
33 assign shift_out = ( S [1] == 0) ? {1 ’ b0 , A [7:1]} : // Shift
Right
34 { A [6:0] , 1 ’ b0 }; // Shift
Left
35

36 // Output Multiplexer
37 always @ (*) begin
38 case ( S [3:2])
39 2 ’ b00 : F = arith_out ; // Arithmetic operations
40 2 ’ b01 : F = logic_out ; // Logic operations
41 2 ’ b10 : F = shift_out ; // Shift operations
42 default : F = 8 ’ h00 ; // Undefined
43 endcase
44 end
45 endmodule

5 Testing
The ALU design is verified through simulation with the following test cases:

• Addition: A = 00001111, B = 00000001, S = 0000, Cin = 0 → F = 00010000.

• Subtraction: A = 00001111, B = 00000001, S = 0001, Cin = 1 → F = 00001110.

• AND: A = 10101010, B = 11001100, S = 0100 → F = 10001000.

• Shift Left: A = 10101010, S = 1010 → F = 01010100.

Simulation tools like ModelSim or Vivado can be used. A Verilog testbench can automate
testing of all operations.

6 Conclusion
The 8-bit ALU design successfully implements all 14 required operations using a modular
architecture with arithmetic, logic, and shift units. The Verilog implementation is efficient
and verifiable. The design meets the project requirements and is presented in a well-
organizeddocument.

Page 6 of 6

You might also like