Академический Документы
Профессиональный Документы
Культура Документы
(EE005-3.5-3)
INDIVIDUAL ASSIGNMENT REPORT
Introduction to ALU
Arithmetic Logic Unit, which is shortly known as “ALU”, is the very important part of a
computer that performs all arithmetic and logic operations, such as addition and
multiplication, and all comparison operations as well. The ALU is one of the major
component, which is present in the CPU (central processing unit). In certain processors, the
ALU is grouped into two units, an arithmetic unit (AU) and a logic unit (LU). Some
processors might have multiple AU some for the fixed point operations and some of the
floating point operations.
Normally, the ALU has direct input and output access to the processor controller, main
memory and input/output devices. Inputs and outputs flow along an electronic path which is
called a “bus”. The input consists of an instruction word which is called a machine instruction
word that contains an operation code which is called an "op code" and one or more operands.
The operation code will tell the ALU what operation to perform and the operands are used in
the specified operation.
The arithmetic logic unit can perform integer arithmetic operations like addition subtraction,
division and multiplication. It can also perform bitwise logic operations like AND, OR, XOR
and NOR. Besides that, ALU also performs bit-shifting operations which mean shifting or
rotating a word by a required number of bits either to the left or right. These Shifts can be
seen either as multiplications and divisions by a power factor of two.
http://simple.wikipedia.org/wiki/File:ALU_symbol.svg
Introduction to VHDL
VHDL is an acronym for Very High Speed Integrated Circuits Hardware Description
Language. This programming language is used to model a digital system or mixed signal
system such as Field Programmable Gate Arrays (FGPA) and Integrated Circuits (IC).
It is used to describe the behaviour as well as structure of electronic systems, but its main
purpose is to describe the structure and behaviour of digital electronic designs, such as ASICs
and FPGAs as well as other conventional digital circuits and systems. VHDL has an
international standard, regulated by the IEEE board. Simulation and synthesis are the two
important tools which run and operate on the VHDL language. VHDL can be used to describe
hardware at the gate level as well as behavioural.
VHDL is normally used to write text models that describe a logic circuit or electronic device.
Such kind of model is processed by a synthesis program, only if it is part of the logic design.
Later part, a simulation program is used to test the logic design using simulation models to
represent the logic circuits that interface to the design. This type of simulation models is
commonly called a “test bench” program.
Main objective
The main objective of this assignment is to design and implement a 4-bit combinational
Arithmetic and Logic Unit (ALU) by using VHDL language and simulate the operations of
ALU with the help of a simulator.
Specific objectives
ALU Operations:
Operation:
The ALU Opcode determines the operation of the ALU that it should perform with the two
operands namely A and B.
Opcode (2 downto 0)
Input A (3 downto 0)
Output (3 downto 0)
Input B (3 downto 0)
Logical OR Function
The OR gate performs logical addition, more widely known as OR function. In this OR gate
two or more inputs are present. When all inputs are low (0) then only output is low (0),
otherwise the output will be high (1).
INPUTS OUTPUT
A B C
0 0 0
0 1 1
1 0 1
1 1 1
Logic Diagram :
Waveform Output :
This type of logical XOR is called inequality comparator or detector because it produces the
output only when the two inputs are different. In this design two or more inputs are used.
When number of high (1) inputs is even then the output is low (0), otherwise the output is
high(1).
A B C
0 0 0
0 1 1
1 0 1
1 1 0
Logical Design :
Waveform Output :
This is opposite function of OR gate. In this NOR gate two or more inputs are used. When all
inputs are low (0) then only output will be high (1), otherwise the output will be low (0).
A B C
0 0 1
0 1 0
1 0 0
1 1 0
Logic Design :
Waveform Output :
The typical AND gate performs the logical multiplication function, more widely known as
AND function. In this gate two or more inputs are used. When all inputs are high (1) then
only output will be high (1), otherwise the output will be low (0).
A B C
0 0 0
0 1 0
1 0 0
1 1 1
Logical Design :
Waveform Output :
Adder Function
A logic circuit that can add four bits, three bits to be added and a CARRY bit from the lower
bit order which results in a SUM and a CARRY.
INPUTS OUTPUTS
.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity FA is
port
( A,B, Cin : IN std_logic;
Sum, Cout : OUT std_logic);
End FA;
architecture Behave of FA is
signal p, q, r : bit;
Begin
Sum <= A xor B xor Cin;
Cout <= ((A xor B) and Cin) or (A and B);
End behave;
SUBTRACTOR:-
A logic circuit that can subtract four bits, one bit is to be subtracted from another and a
BORROW bit which is denoted by Bin from the previous bit order which results in a output
Difference, denoted by D and a BORROW OUT, denoted by Bout.
INPUTS OUTPUTS
A B B_IN D B_OUT
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
DESIGN:
MULTIPLEXERS
Multiplexer or more commonly known as MUX or even called as data selector is a logic
circuit that accepts multiple data inputs and allows only one of them at a time to get through
the output. In this circuit select lines are used and the output depends on it. If n is the number
of select lines then inputs are 2^n.
MULTIPLEXER 8 TO 1
TRUTH TABLE:—
INPUTS SELECT OUTPUT
A B C D E F G H S S S MUX_OUT
2 1 0
0 1 0 1 0 1 0 1 0 0 0 0
0 1 0 1 0 1 0 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 0
0 1 0 1 0 1 0 1 0 1 1 1
0 1 0 1 0 1 0 1 1 0 0 0
0 1 0 1 0 1 0 1 1 0 1 1
0 1 0 1 0 1 0 1 1 1 0 0
0 1 0 1 0 1 0 1 1 1 1 1
8 : 1 MUX Design :
--MUX Program
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity sel is
port
(Op : in std_logic_vector(2 downto 0);
M : out std_logic;
T : out std_logic_vector(3 downto 0) );
end sel;
architecture Behave of sel is
signal I: std_logic;
Signal L: std_logic_vector (3 downto 0);
begin
po: process (Op) is
begin
case Op (2 downto 0) is
when "000" =>
M <= I;
when "001" =>
M <= I;
when "010" =>
T <= L;
when "011" =>
T <= L;
when "100" =>
T <= L;
when "101" =>
T <= L;
when "110" =>
T <= L;
when "111" =>
T <= L;
when others =>
null;
end case;
end process po;
end behave;
ALU Operations:
Opcode (2 downto 0)
Input A (3 downto 0)
Output (3 downto 0)
Input B (3 downto 0)
VHDL Program For ALU
P2: Process
Begin
Opwire <= "000" after 10 ns;
Opwire <= "001" after 10 ns;
Opwire <= "010" after 10 ns;
Opwire <= "011" after 10 ns;
Opwire <= "100" after 10 ns;
Opwire <= "101" after 10 ns;
Opwire <= "110" after 10 ns;
Opwire <= "111" after 10 ns;
End process;
End TBA;