Vlsi Part A Manual
Vlsi Part A Manual
EXPERIMENT NO.1
INVERTER SIMULATION AND SYNTHESIS
Aim: To Design an inverter using Verilog and simulate the design using Verilog test bench
and observe functionality of the inverter in Linux environment.
0 1
1 0
Program
module inverter( input_i, output_o);
inputinput_i;
outputoutput_o;
regoutput_o;
always@(input_i)
begin
if(input_i)
output_o=1'b0;
else
output_o=1'b1;
endendm
odule
Test Bench
moduleinverter_tb;
reginput_i;
wireoutput_o;
initial
input_i=1'b0;
always #5 input_i= ~ input_i;
initial
begin
$monitor( $time, " input_i=%b and output_o=%b ", input_i,output_o);
endend
module
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result :
EXPERIMENT NO.2
BUFFER SIMULATION AND SYNTHESIS
Aim:To Design a buffer using Verilog and simulate the design using Verilog test bench
and observe functionality of the buffer in Linux environment.
0 0
1 1
Program
always @(input_i)
begin
if(input_i)
output_o=1'b1;
else
output_o=1'b0;
end
endmodule
Test Bench
module buffer_tb;
reg input_i;
wire output_o;
initial
input_i=1'b;
always #5 input_i=~ input_i;
initial
begin
$monitor( $time, " input_i=%b and output_o=%b ", input_i,output_o);
end
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result :
EXPERIMENT NO.3
TRANSMISSION GATE SIMULATION AND SYNTHESIS
Aim: To Design a Transmission Gate using Verilog and simulate the design using Verilog
testbench and observe the functionality of the Transmission Gate in Linux environment.
Program
always @ (in)
begin
if(control)
out=in;
else
out=1'b0;
end
endmodule
Test Bench
module transmission_gate_tb;
reg in, control;
wire out;
transmission_gate dut(in, control, out);
initial in=1'b1;
always #5 in=~in;
initial
begin
#20 control=1'b1;
#20 control=1'b0;
end
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result :
EXPERIMENT NO.4
BASIC GATES SIMULATION AND SYNTHESIS
Aim: Design and simulate all basic and universal gates in one of the following modeling
styles(Behavioral, Data flow or Structural) using Verilog.
Logic Diagram
Program
assign c=~a;
assign d=a&b;
assign e=a|b;
assign f=~(a&b);
assign g=~(a|b);
assign h=a^b;
endmodule
Test Bench
module basic_gates_tb; reg
a, b;
wire c, d, e, f, g, h;
initial
begin
a=1'b0;b=1'b0;
#20a=1'b1; b=1'b0;
#20 a=1'b0; b=1'b1;
#20 a=1'b1; b=1'b1;
end
initial
begin
end
endmodule
Expected Waveforms
Actual Waveforms:
Synthesis Output:
Result :
EXPERIMENT NO.5
FLIP FLOPS SIMULATION AND SYNTHESIS
Aim: Design and simulate SR Flip Flop in one of the following modeling styles
Program
Test Bench
modulers_ff_tb;
reg [1:0] rs;
reg clock;
wire q, qb;
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result:
Program
assign qb=~q;
endmodule
Test Bench
module dff_tb;
reg clock, reset, d;
wire q, qb;
#20 d =1'b1;
#20 d =1'b0;
#30 d =1'b1;
#30 d =1'b0;
end
initial
begin
$monitor ($time, "reset=%b clock=%b d=%b q=%b qb=%b", reset, clock, d,
q, qb);
end
endmodule
Expected Waveforms:
Dept. of ECE, AMCEC Page 13
VLSI Lab Manual
Actual Waveforms:
Synthesis Output:
Result:
Aim: Design and simulate T FLIP FLOP in one of the following modelingstyles (Behavioral,
Data flow or Structural) using Verilog.
Clk T q qb
0 Hold
1 Toggle
Program
endcase
qb =~ q;
end
endmodule
Test Bench
module T_ff_tb;
reg T;
reg clock;
wire q, qb;
T=1'b0; #20;
T=1'b1; #20;
T=1'b0; #20;
T=1'b1; #20;
end
initial
$monitor ($time, "T=%b q=%b qb=%b ", T, q, qb);
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result:
Aim: Design and simulate JK Flip Flop in one of the following modelingstyles (Behavioral,
Data flow or Structural) using Verilog.
Program:
2'b00 : q = q;
2'b01 : q = 1'b0;
2'b10 : q = 1'b1;
2'b11 : q =~ q;
endcase
qb =~ q;
end
endmodule
Test Bench
moduleJK_ff_tb;
reg [1:0] JK;
reg clock;
wire q, qb;
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result:
Aim: Design and simulate MS-JK Flip Flop in one of the following modelingstyles
(Behavioral,Data flow or Structural) using Verilog.
Block Diagram
Program
assignqb=~q;
endmodule
wire q;
wire qb;
wire w1,w2;
d_ff master(.reset(reset), .clock(clock), .d(d), .q(w1), .qb(w2));
d_ff slave (.reset(reset), .clock(~clock),.d(w1),.q(q), .qb(qb));
endmodule
Test Bench
module ms_ff_tb;
regreset,clock,d;
wire q,qb;
msflipflop dut(reset,clock,d,q,qb);
initial
clock=1'b1;
always #5 clock=~clock;
initial
begin
reset=1'b1; d=1'b0; #40;
reset=1'b1; d=1'b1; #40;
reset=1'b0; d=1'b0; #40;
reset=1'b0; d=1'b1; #40;
reset=1'b0; d=0'b0; #40;
reset=1'b0; d=1'b1; #40;
end
initial
$monitor($time,"reset=%b d=%b q=%b qb=%b", reset, d, q, qb);
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result:
EXPERIMENT NO.6
ADDER DESIGN AND SIMULATION
i) Parallel Adder
Aim:Design a Ripple carry adder with full adder in one of the following modeling
styles (Behavioral, Data flow or Structural) using Verilog.
Block Diagram
a b a b a b a b
Program
(i) full_adder
(ii) 4bit_serial_full_adder
module fa_parallel_4bit (a, b, cin, sum,carry);
input [3:0] a,b;
input cin;
output [3:0] sum;
output carry;
wire [3:1] w;
full_adder fa0(.a(a[0]),.b(b[0]),.cin(cin),.sum(sum[0]),.carry(w[1]));
full_adder fa1(.a(a[1]),.b(b[1]),.cin(w[1]),.sum(sum[1]),.carry(w[2]));
full_adder fa2(.a(a[2]),.b(b[2]),.cin(w[2]),.sum(sum[2]),.carry(w[3]));
full_adder fa3(.a(a[3]),.b(b[3]),.cin(w[3]),.sum(sum[3]),.carry(carry));
endmodule
Test Bench
module fa_parallel_4bit_tb;
reg [3:0] a,b;
reg cin;
wire [3:0] sum;
wire carry;
initial
begin
a=4'b0111; b=4'b0100; cin=1'b0;#10;
a=4'b1011; b=4'b0110; cin=1'b1;
end
initial
$monitor ($time, "a=%b b=%b cin=%b sum=%b carry=%b",
a, b, cin, sum, carry);
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result:
Block diagram
Carry Generator
Cout
Program
assign cout= g[2] | (p[2] & g[1]) | (p[2] & p[1] & g[0]) | (p[2] & p[1] & p[0] &cin);
assign sum[0]= x[0] ^ y[0] ^ cin;
assign sum[1]= x[1] ^ y[1] ^ (g[0] | (p[0] &cin));
assign sum[2]= x[2] ^ y[2] ^ (g[1] | (p[1] & g[1]) | (p[1] & p[0] &cin));
endmodule
Test Bench
module paraller_adder_tb;
reg [2:0] x,y;
reg cin;
wire [2:0] sum;
wire cout;
initial begin
x=3'b111; y=3'b100; cin=1'b0;
#10; x=3'b101; y=3'b110; cin=1'b1;
end
initial
$monitor ($time, " x=%b y=%b cin=%b sum=%b cout=%b" , x, y, cin, sum,
cout);
endmodule
Expected Waveforms:
Actual Waveforms:
Synthesis Output:
Result :
ii Serial Adder
Aim:Design a Serial adder in one of the following modelingstyles (Behavioral, Data flow or
Structural) using Verilog.
Block Diagram
module shift_reg(data,load,E,w,clock,q);
parameter n=8;
input [n-1:0] data;
inputload,E,w,clock;
output [n-1:0] q;
reg [n-1:0] q;
integer k;
reg s,y,Y;
wire [7:0] qa, qb, sum;
wire run;
//adder fsm
//output and next state combinational circuit
always @(qa or qb or y)
case (y)
G: begin
s = qa[0]^qb[0];
if (qa[0] &qb[0])
Y = H;
else
Y = G;
end
H: begin
s = qa[0] ~^qb[0];
if (~qa[0] & ~qb[0])
Y =G;
else
Y = H;
end
default : Y = G;
endcase
//sequential block
always @(posedge clock) if
(reset)
y <= G;
else
y <= Y;
assign cout=y;
Test Bench
module serial_adder_tb ;
reg [7:0] A,B;
reg reset,clock;
wire [7:0] sum ;
wire cout;
initial
clock = 1'b1;
always #5 clock =~clock;
initial
begin
reset = 1'b0;A = 8'b10101010; B = 8'b11111111;
#20 reset = 1'b1;
#20 reset = 1'b0;
#80 $finish;
end
initial
$monitor ($time, " SUM = %d cout=%b", sum, cout);
endmodule
Expected Waveform
Actual Waveforms:
Synthesis Output:
Result :
EXPERIMENT NO.7
COUNTER DESIGN AND SIMULATION
i.Synchronous Counter
Aim: Design and Simulate synchronous counter in the following modelingstyles
(Behavioral) using Verilog.
Block Diagram
Program
else
count=count;
endendm
odule
Test Bench
module counter_tb;
reg clock, reset, up, down;
wire [3:0]count;
initial
clock=1'b0;
always #5 clock=~clock;
initial
begin
reset=1'b1; up=1'b0; down=1'b1;#50;
reset=1'b0;
up=1'b1; down=1'b0; #500;
up=1'b0; down=1'b1; #500;
up=1'b1; down=1'b1; #50;
end
initial
$monitor( $time, " reset=%b up=%b down=%b count=%b" ,reset, up, down, count);
endmodule
Expected Waveform
Actual Waveforms:
Synthesis Output:
Result:
Block Diagram
Program
q<=~q;
else
q<=q;
end
endmodule
(ii) 4bit-counter
Test Bench
module asyn_counter_tb;
reg clock, reset;
wire [3:0] count;
asyn_counter dut(clock, reset, count);
initial clock=1'b0;
always #10 clock=~clock;
initial
begin
#20; reset=1'b1;
#20; reset=1'b0;
end
initial
$monitor( $time, " reset=%b count = %b" ,reset, count);
endmodule
Expected Waveforms
Actual Waveforms:
Synthesis Output:
Result:
EXPERIMENT NO.8
SUCCESSIVE APPROXIMATION REGISTER [SAR] DESIGN AND
SIMULATION
Aim: Design Successive Approximation Register in the behavioral modeling stylesusing
Verilog.
Flow chart
Shifting Operation
Program
parameter n=8;
input [n-1:0] data;
Test Bench
module sar_tb;
sar dut(.data(data),.load(load),.E(E),.w(w),.clock(clock),.q(q));
initial
clock=1'b1;
always #5 clock = ~clock;
initial
begin
load = 1'b1;
w = 1'b0;
E = 1'b0;
#5 data = 8'b11110000;
#10 load = 1'b0;
E = 1'b1;
w = 1'b0;
#10 w = 1'b0;
#10 w = 1'b0;
#10 w = 1'b0;
#10 w = 1'b1;
#10 w = 1'b1;
#10 w = 1'b1;
#10 w = 1'b1;
end
endmodule
Expected Waveforms
Actual Waveforms:
Synthesis Output:
Result:
Checking Security...
News :
* Enter "help" to get an overview of all commands
* Enter <command> -help to get usage of each command
*******************************************************
*******************************************************
Number of ports : 3
Number of nets : 3
Number of instances : 1
Number of references to this view : 0
LEONARDO{6}: report_delay
NO wire table is found
Critical Path Report
21 | P a g e
Dept.of
ECE,AMCEC
Page 46
VLSI Lab Manual