Professional Documents
Culture Documents
BRANCH: ECE-II
ROLL NO.: 20211502818
BATCH: P1
EXPERIMENT 8
AIM: Write a VHDL program for the following circuits, check the wave forms and hardware
generated.
a) ALU
b) Shift Register
THEORY:
ALU:
An arithmetic-logic unit (ALU) is the part of a computer processor (CPU) that carries out arithmetic
and logic operations on the operands in computer instruction words. In some processors, the ALU is
divided into two units, an arithmetic unit (AU) and a logic unit (LU).
The logic and arithmetic operations being implemented in the ALU are as follows:
1. Arithmetic Addition
ALU_Out = A + B;
2. Arithmetic Subtraction
ALU_Out = A – B;
3. Arithmetic Multiplication
ALU_Out = A * B;
4. Arithmetic Division
ALU_Out = A / B;
5. Logical Shift Left
ALU_Out = A logical shifted left by 1;
6. Logical Shift Right
ALU_Out = A logical shifted right by 1;
7. Rotate Left
ALU_Out = A rotated left by 1;
8. Rotate Right
ALU_Out = A rotated right by 1;
9. Logical AND
ALU_Out = A AND B;
10. Logical OR
ALU_Out = A OR B;
11. Logical XOR
ALU_Out = A XOR B;
12. Logical NOR
ALU_Out = A NOR B;
13. Logical NAND
ALU_Out = A NAND B;
14. Logical XNOR
ALU_Out = A XNOR B;
15. Greater comparison
ALU_Out = 1 if A > B else 0;
16. Equal comparison
ALU_Out = 1 A = B else 0;
A register capable of shifting binary information either to the right or the left is called a shift register.
SISO register accepts data serially i.e. one bit at a time on a single input line. It produced the stored
information on its single output also in serial form. Data shifted to right i.e. from high to low order bits
using shift-right register. A shift right register can also be built using D flip flop.
SERIAL IN AND PARALLEL OUT RIGHT SHIFT REGISTER:
SIPO register consists of one serial input & outputs are taken from all the flip-flops parallel. In this
register, data is shifted in serially but shifted out in parallel way. In order to shift the data out in
parallel, it is necessary to have all the data available at the outputs at the same time. Once the data is
stored, each bit appears on its respective output line & all the bits are available simultaneously, rather
than on a bit by bit basis as with the serial output.
CODE:
FOR ALU:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity alu is
port(a,b: in std_logic_vector(7 downto 0);
alu_sel: in std_logic_vector(3 downto 0);
alu_out: out std_logic_vector(7 downto 0);
carryout: out std_logic);
end alu;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity alu_tb is
end alu_tb;
library ieee;
use ieee.std_logic_1164.all;
entity dff is
port(clk,din,rst:in std_logic;
dout:out std_logic);
end dff;
entity siso is
port(clk,din,rst:in std_logic;
dout:out std_logic);
end siso;
library ieee;
use ieee.std_logic_1164.all;
entity siso_tb is
end siso_tb;
library ieee;
use ieee.std_logic_1164.all;
entity sipo is
port(clk,din,rst:in std_logic;
dout:out std_logic_vector(2 downto 0));
end sipo;
library ieee;
use ieee.std_logic_1164.all;
entity sipo_tb is
end sipo_tb;
FOR ALU:
RESULT:
We have implemented alu, serial in serial out right shift register and serial in parallel out right
shift register with test benches on VHDL simulator and observed its waveform.