Digital System Design: Implementation of Arithmetic Logic Unit
Digital System Design: Implementation of Arithmetic Logic Unit
OBJECTIVES
INTRODUCTION
The arithmetic logic unit (ALU) carries out the logic operations (such as comparisons) and
arithmetic operations (such as add or subtract) required during the program execution.
Generally
an ALU has two data inputs and one data output. Operations performed in the ALU often
affect bits in the status register (bits are set to indicate actions such as whether an overflow
has occurred). The ALU knows which operations to perform because it is controlled by
signals from the control unit.
op_a; Input 4
op_b; Input 4
Func Input 2
alu_out Output 4
Page | 72
Digital System Design Lab 9
begin
case(func)
endcase
end
endmodule
Page | 73
Digital System Design Lab 9
Task1
Create a project in Xilinx ISE .Add this file to the project .Now simulate this file using ISE
Simulator. Next synthesize this file using XST.
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Draw results from Test bench for ALU? Indicate Input & Output signals?
Page | 74
Digital System Design Lab 9
Task2
op_a; Input 4
op_b; Input 4
Func Input 3
alu_out Output 4
Objective of this task is to write a Verilog module for a complex ALU which can add,
subtract, compare and shift and rotate operands.
Before writing module for complex ALU first answer following questions
Write statements in Verilog HDL that can compare two operands each of 4 bits?
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Page | 75
Digital System Design Lab 9
Read verilog module for complex ALU called alu_cmplx .Explain its operation
without using Xilinx ISE?
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
Without using synthesizer tool draw hardware diagram for complex ALU from
module given below?
Page | 76
Digital System Design Lab 9
module alu_cmplx(op_a, op_b, func, alu_out);
begin
casex({func, op_b})
//Logic operations:
//Aritmetic operations:
//Comparator
//alu_out[3] = 0, alu_out[2] = G;
//alu_out[1] = E, alu_out[0] = L;
7'b110_xxxx: begin
alu_out = 4'b0100;
if (op_a == op_b)
alu_out = 4'b0010;
Page | 77
Digital System Design Lab 9
alu_out = 4'b0001;
end
//Shifter Rotator
endcase
end
endmodule
Page | 78
Digital System Design Lab 9
Draw results from Test bench for ALU? Indicate Input & Output signals? Verify
that each function of ALU is being performed.
Page | 79
Observations/Comments/Explanation of Results