VLSI Lab Manual - 2022-1
VLSI Lab Manual - 2022-1
1. Design a 4 Bit Adder using HDL. Simulate it using Xilinx/Altera Software and implement
by Xilinx/Altera FPGA
2. Design a 4 Bit Multiplier using HDL. Simulate it using Xilinx/Altera Software and
Implement by Xilinx/Altera FPGA
3. Design a Counter using HDL. Simulate it using Xilinx/Altera Software and implement by
Xilinx/Altera FPGA
4. Design a Register -SISO, SIPO, PISO, PIPO and USR using HDL. Simulate it using
Xilinx/Altera Software and implement by Xilinx/Altera FPGA
5. Design an ALU using HDL. Simulate it using Xilinx/Altera Software and implement by
Xilinx/Altera FPGA
6. Design Memories using HDL. Simulate it using Xilinx/Altera Software and implement by
Xilinx/Altera FPGA Compare pre-synthesis and post synthesis simulation for experiments 1 to 5.
TOTAL: 45 PERIODS
Cadence/Synopsis/ Mentor
3 10 User License
Graphics/Tanner/equivalent EDA Tools
4 Personal Computer 30 no
LIST OF EXPERIMENTS
To study the simulation and implementation procedures of Xilinx tool and FPGA
STEP1:
STEP2:
File ->New project and type the project name and check the top level source type as HDL
STEP5:
STEP6:
STEP8: Select user constraints->assign package pins,setport numbers and save it then select IO
Bus delimiter as XST default<>->clickok
STEP9:
Result:
Thus the simulation and implementation procedure of Xilinx and FPGA is studied
Design & FPGA Implementation of 4-bit ripple carry adder
Ex.No.1
AIM:
To write a verilog program
a) To simulate a ripple carry adder and verify the code using test bench.
b) To synthesis a ripple carry adder and verify the code
c) To implement a ripple carry adder and verify the code
APPARATUS REQUIRED:
PC with WindowsXP.
XILINX9.2i
FPGA-SPARTAN-3KIT
PARALLEL TO JTAGCABLE
PROGRAM
adder_8bit.v
Simulation Results:
Synthesis Results:
RESULT:
Thus the verilog program is written to simulate and synthesis an 4 bit adder circuits and
implementation of a ripple carry adder was also obtained.
Design & FPGA Implementation of 4-bit Multiplier
Ex.No.2
AIM:
To write a verilog program
a) To simulate a 4-bit multiplier.
b) To Synthesis
c) To implement
APPARATUS REQUIRED:
PC with WindowsXP.
XILINX9.2i
FPGA-SPARTAN-3KIT
PARALLEL TO JTAGCABLE
Block Diagram
Program
module HA(sout,cout,a,b);
output sout,cout;
input a,b;
assign sout=a^b;
assign cout=(a&b);
endmodule
module FA(sout,cout,a,b,cin);
output sout,cout;
input a,b,cin;
assign sout=(a^b^cin);
assign cout=((a&b)|(a&cin)|(b&cin));
endmodule
module multiply4bits(product,inp1,inp2);
output [7:0]product;
input [3:0]inp1;
input [3:0]inp2;
assign product[0]=(inp1[0]&inp2[0]);
wire x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17;
HA HA1(product[1],x1,(inp1[1]&inp2[0]),(inp1[0]&inp2[1]));
FA FA1(x2,x3,inp1[1]&inp2[1],(inp1[0]&inp2[2]),x1);
FA FA2(x4,x5,(inp1[1]&inp2[2]),(inp1[0]&inp2[3]),x3);
HA HA2(x6,x7,(inp1[1]&inp2[3]),x5);
HA HA3(product[2],x15,x2,(inp1[2]&inp2[0]));
FA FA5(x14,x16,x4,(inp1[2]&inp2[1]),x15);
FA FA4(x13,x17,x6,(inp1[2]&inp2[2]),x16);
FA FA3(x9,x8,x7,(inp1[2]&inp2[3]),x17);
HA HA4(product[3],x12,x14,(inp1[3]&inp2[0]));
FA FA8(product[4],x11,x13,(inp1[3]&inp2[1]),x12);
FA FA7(product[5],x10,x9,(inp1[3]&inp2[2]),x11);
FA FA6(product[6],product[7],x8,(inp1[3]&inp2[3]),x10);
endmodule
Simulation results:
Synthesis results:
Implementation results:
RESULT:
Thus the verilog program is written to implement, synthesis a 4-bit multiplier and implementation
was obtained, and also the code was verified using test bench.
Design & FPGA Implementation of COUNTER
Ex.No : 3
AIM:
To write a verilog program to implement an Up, Down & UP-Down counter.
APPARATUS REQUIRED:
PC with WindowsXP.
XILINX9.2i
FPGA-SPARTAN-3KIT
PARALLEL TO JTAGCABLE
PROGRAM
UP-Counter
endmodule
Test bench for up counter
module test_upcounter;
reg clk, reset,enable ;
wire [7:0] out;
UP-Down -Counter
begin
if (reset) begin
out <= 8'b0 ;
end else if (ud) begin
out <= out + 1;
end else begin
out <= out -1;
end
end
endmodule
RESULT:
Thus the verilog program is written and simulation, synthesis and implementation of counter is obtained.
Design & FPGA Implementation of REGISTER
Ex.No : 4
AIM:
To write a verilog program to implement SISO, SIPO, PISO, PIPO & USR
APPARATUS REQUIRED:
PC with WindowsXP.
XILINX9.2i
FPGA-SPARTAN-3KIT
PARALLEL TO JTAGCABLE
PROGRAM
SISO
PROGRAM
module dff(d,clk,q);
input d,clk;
output q;
reg q=0;
always @ (posedge clk)
begin
q<=d;
end
endmodule
module testbench()
reg d,clk;
wire q;
siso a(d, clk, q);
initial
begin
$monitor($time,"d=%b,clk=%b,q=%b",d,clk,q);
end
initial
begin
clk=1'b0;
forever #5 clk=~clk;
end
initial
begin
d=1;
#10 d=0;
#10 d=1;
#10 d=1;
#40 $finish;
end
endmodule
Simulation Results of SISO
PROGRAM:
module ShiftRegister_SIPO(C, SI, PO);
input C,SI;
output [7:0] PO;
reg [7:0] tmp;
always @(posedge C)
begin
tmp = {tmp[6:0], SI};
end
assign PO = tmp;
endmodule
Simulation results of SIPO
PROGRAM
module piso(clk,rst,a,q);
input clk,rst;
input [3:0]a;
output q;
reg q;
reg [3:0]temp;
always@(posedge clk,posedge rst)
begin
if(rst==1'b1)
begin
q<=1'b0;
temp<=a;
end
else
begin
q<=temp[0];
temp <= temp>>1'b1;
end
end
endmodule
TESTBENCH:
initial
clk=1'b1;
always #10 clk=~clk;
initial begin
rst=1'b1; a=4'b1101;
#300 rst=1'b0;
#200 rst=1'b1;
#200 rst=1'b0;
end
initial
#1000 $stop;
endmodule
PROGRAM
module pipomod(clk,clear, pi, po);
input clk,clear;
input [3:0] pi;
output [3:0] po;
wire [3:0] pi;
reg [3:0] po;
always @(posedge clk)
begin
if (clear)
po<= 4’b0000;
else
po <= pi;
end
endmodule
TEST BENCH
module pipot_v;
reg clk;
reg clear;
reg [3:0] pi;
wire [3:0] po;
pipomoduut(.clk(clk),.clear(clear),.pi(pi),.po(po) );
initial begin
clk = 0;
clear = 0;
pi = 0;
#5 clear=1’b1;
#5 clear=1’b0;
#10 pi=4’b1001;
#10 pi=4’b1010;
#10 pi=4’b1011;
#10 pi=4’b1110;
#10 pi=4’b1111;
#10 pi=4’b0000;
end
always #5 clk = ~clk;
initial #150 $stop;
endmodule
Simulation Results of PIPO
Synthesis Results
RESULT:
Thus the verilog program is written to simulate register, synthesis and implementation also
obtained.
Design & FPGA Implementation of ALU
Ex.No : 5
AIM:
To write a verilog program to simulate ALU, synthesis RTL Schematic , and implement .
APPARATUS REQUIRED:
PC with WindowsXP.
XILINX9.2i
FPGA-SPARTAN-3KIT
PARALLEL TO JTAGCABLE
Program
modulealu(
input [7:0] A,B, // ALU 8-bit Inputs
input [3:0] ALU_Sel,// ALU Selection
output [7:0] ALU_Out, // ALU 8-bit Output
outputCarryOut // Carry Out Flag
);
reg [7:0] ALU_Result;
wire [8:0] tmp;
assignALU_Out = ALU_Result; // ALU out
assigntmp = {1'b0,A} + {1'b0,B};
assignCarryOut = tmp[8]; // Carryout flag
always@(*)
begin
case(ALU_Sel)
4'b0000: // Addition
ALU_Result = A + B ;
4'b0001: // Subtraction
ALU_Result = A - B ;
4'b0010: // Multiplication
ALU_Result = A * B;
4'b0011: // Division
ALU_Result = A/B;
4'b0100: // Logical shift left
ALU_Result = A<<1;
4'b0101: // Logical shift right
ALU_Result = A>>1;
4'b0110: // Rotate left
ALU_Result = {A[6:0],A[7]};
4'b0111: // Rotate right
ALU_Result = {A[0],A[7:1]};
4'b1000: // Logical and
ALU_Result = A&B;
4'b1001: // Logical or
ALU_Result = A | B;
4'b1010: // Logicalxor
ALU_Result = A ^ B;
4'b1011: // Logical nor
ALU_Result = ~(A | B);
4'b1100: // Logical nand
ALU_Result = ~(A&B);
4'b1101: // Logical xnor
ALU_Result = ~(A ^ B);
4'b1110: // Greater comparison
ALU_Result = (A>B)?8'd1:8'd0 ;
4'b1111: // Equal comparison
ALU_Result = (A==B)?8'd1:8'd0 ;
default: ALU_Result = A + B ;
endcase
end
endmodule
A = 8'hF6;
B = 8'h0A;
end
endmodule
Simulation result:
RESULT:
Thus the verilog program is written to simulate, synthesis ALU and implementation also obtained.
Design & FPGA Implementation of Memories
Ex.No:6
Aim: To compile and to simulate the Verilog code for the successive approximation
register.
APPARATUS REQUIRED:
PC with WindowsXP.
XILINX9.2i
FPGA-SPARTAN-3KIT
PARALLEL TO JTAGCABLE
PROGRAM
module mem_ram_sync(
clk,
rst,
read_rq,
write_rq,
rw_address,
write_data,
read_data
);
input clk;
input rst;
input read_rq;
input write_rq;
input[5:0] rw_address;
input[7:0] write_data;
output[7:0] read_data;
reg[7:0] read_data;
integer i;
always @(*)
begin
for (i=0;i<64; i=i+1)
memory_ram_d[i] = memory_ram_q[i];
if (write_rq&& !read_rq)
memory_ram_d[rw_address] = write_data;
if (!write_rq&&read_rq)
read_data = memory_ram_q[rw_address];
end
endmodule
RESULT:
Thus the verilog program is written to simulate, synthesis Memories and implementation also obtained.
PART-II
Ex.No. 7
DESIGN OF CMOS INVERTER USING TANNER
AIM
To design a CMOS inverter using the Schematic entry tool, Tanner
and verify itsfunctioning.
Apparatus Required
1. Tannertool
2. PC
THEORY
Algorithm
1. Draw the schematic of CMOS Inverter usingS-edit.
CMOS Inverter
]
WAVEFORM
Transient Analysis
Dc analysis
OUTPUT
Including "C:\Tanner\TSpice70\models\
Current sources
- 0 VCCS -0
CCCS -0
I- control switch -0
- 0 Subcircuit instances - 0
Boundary nodes - 3
0.04seconds
-----------------------------------------
RESULTS
Thus the design & simulation of a CMOS inverter has been carried out using S-Edit of
Tanner EDA Tools.
Ex.no :8 DESIGN OF CMOS NAND GATE AND NOR GATE USING TANNER
AIM
To design a CMOS NAND and NOR gates using the Schematic entry tool,
Tannerand verify itsfunctioning.
Apparatus Required
1. Tannertool
2. PC
Theory
NAND and NOR gates are known as universal gates as anyfunction can be implemented
withthem
Algorithm
CMOS NAND
CMOS NOR
WAVEFORM NAND
OUTPUT - NAND
Version7.10
Parsing "F:\tanner\TSpice70\Module0.sp"
Including "F:\tanner\S-Edit\models\
ml2_125.md"
0.03seconds
-----------------------------------------
Total 0.04 seconds
CMOS NOR Circuit
OUTPUT – NOR
Warning T-SPICE : The vrange voltage range limit (5.5) for diode tables has been exceeded.
Warning T-SPICE : The vrange voltage range limit (5.5) for MOSFET tables has been
exceeded.
Warning T-SPICE : The vrange voltage range limit should be set to at least 7.11984 for best
accuracy and performance.
0.06seconds
-----------------------------------------
Total 0.07 seconds
Results
Thus the design &simulation of a CMOS NAND and NOR gates have been carried
out using S-Edit of Tanner EDATools
Page
50
DIFFERENTIAL AMPLIFIER
Ex.No.9
AIM:
To calculate the gain, bandwidth and CMRR of a differential amplifier through schematic entry.
APPARATUS REQUIRED:
S-Edit using Tanner Tool.
Theory :
A differential amplifier is a type of electronic amplifier that multiplies the difference between two inputs by
some constant factor (the differential gain).
Many electronic devices use differential amplifiers internally. The output of an ideal differential amplifier is
given by:
Where and are the input voltages and Ad is the differential gain.
In practice, however, the gain is not quite equal for the two inputs. This means that if and are equal,
the output will not be zero, as it would be in the ideal case. A more realistic expression for the output of a
differential amplifier thus includes a second term.
PROCEDURE
1. Draw the schematic of differential amplifier using S-edit and generate the symbol
2. Draw the schematic of differential amplifier circuit using the generated symbol.
3. Perform AC Analysis of the differential amplifier.
4. Obtain the frequency response from W-edit.
5. Obtain the spice code using T-edit.
Page
51
RESULT:
The gain, bandwidth of the differential amplifier was obtained using AC analysis.
Page
52
CONTENT BEYOND SYLLABUS
KOGGE STONE ADDER
Ex.No.10
AIM:
To write a verilog program to optimize the results of Kogge Stone Adder.
APPARATUS REQUIRED:
Xilinx ISE Design Suite
Block Diagram:
Inputs
a7 b7 a6 b6 a5 b5 a4 b4 a3 b3 a2 b2 a1 b1 a0 b0 cin
Pre computing
g7 p7 g6 p6 g5 p5 g4 p4 g3 p3 g2 p2 g1 p1 g0 p0
Prefix stage
c6 c5 c4 c3 c2 c1 c0
c7
Final computing
cout s7 s6 s5 s4 s3 s2 s1 s0
Program:
Module normalksa(a0,a1,a2,a3,b0,b1,b2,b3,c0,c1,c2,c3,g0,g1,g2,g3,g11,g21,g31,
g22,g32,p0,p1,p2,p3,p11,p21,p31,p22,p32);
input a0,a1,a2,a3,b0,b1,b2,b3;
output c0,c1,c2,c3,g0,g1,g2,g3,g11,g21,g31, g22,g32,p0,p1,p2,p3,p11,p21,p31,p22,p32;
assign g0=a0&b0;
assign p0=a0^b0;
Page
53
assign g1=a1&b1;
assign p1=a1^b1;
assign g2=a2&b2;
assign p2=a2^b2;
assign g3=a3&b3;
assign p3=a3^b3;
assign p11=p1&p0;
assign g11=(p1&g0)|g1;
assign p21=p1&p2;
assign g21=(p2&g1)|g2;
assign p31=p3&p2;
assign g31=(p3&g2)|g3;
assign c0=g0;
assign c1=g11;
assign p22=p21&p0;
assign g22=(p21&g0)|g21;
assign p32=p31&p11;
assign g32=(p31&g11)|g31;
assign c2=g22;
assign c3=g32;
endmodule
Output
Thus the verilog program is written to simulate, synthesis Kogge stone adder and implementation also
obtained.
Page
54