Professional Documents
Culture Documents
Program- 1
Aim: To write the verilog code for an Inverter and the Test bench for Verification, Observe the waveform
and synthesize the code
module Inv_tb_v;
// Inputs
reg A;
// Outputs
wire F;
initial begin
// Initialize Inputs
A = 0;
end
endmodule
Waveforms
Program- 2
Aim: To write the verilog code for an Buffer and the Test bench for Verification, Observe the waveform and
synthesize the code
input A;
output B;
reg B;
always @ (A)
begin
B <= A;
end
endmodule
module BUFFER_tb_v;
// Inputs
reg A;
// Outputs
wire B;
BUFFER uut (
.A(A),
.B(B)
);
initial begin
// Initialize Inputs
A = 0;
endmodule
Waveforms
Program- 3
Aim: To write the verilog code for an Transmission Gate and the Test bench for Verification, Observe the
waveform and synthesize the code
buf U2(out1,in);
not U3(out2,in);
endmodule
module TG_tb_v;
// Inputs
reg data_enable_low;
reg in;
// Outputs
wire data_bus;
wire out1;
wire out2;
// Instantiate the Unit Under Test (UUT)
TG uut (
.data_enable_low(data_enable_low),
.in(in),
.data_bus(data_bus),
.out1(out1),
.out2(out2)
);
initial begin
// Initialize Inputs
data_enable_low = 0;
in = 0;
// Wait 100 ns for global reset to finish
#10;
// Add stimulus here
end
initial begin
$monitor(
"@%g in=%b data_enable_low=%b out1=%b out2= b data_bus=%b",
$time, in, data_enable_low, out1, out2, data_bus);
data_enable_low = 0;
in = 0;
#4 data_enable_low = 1;
#8 $finish;
end
always #2 in = ~in;
endmodule
Waveforms
Program- 4
Aim: To write the verilog code for an Basic/Universal Gate and the Test bench for Verification, Observe the
waveform and synthesize the code
A) AND Gate
input A;
input B;
output Y;
reg Y;
always @ (A or B)
begin
Y <= A & B;
end
endmodule
module AND1_tb_v;
// Inputs
reg A;
reg B;
// Outputs
wire Y;
initial begin
// Initialize Inputs
A = 0;
B = 1;
A = 1;
B = 1;
end
endmodule
Waveforms
B) OR Gate
module Orgate_tb_v;
// Inputs
reg a;
reg b;
// Outputs
wire y;
initial begin
// Initialize Inputs
a = 0;
b = 0;
a = 1;
b = 1;
end
endmodule
Waveforms
C) NAND Gate
Y= A NAND B =~ (A. B)
module Testbench;
initial
begin
//case 0
A_t <= 0; B_t <= 0;
#1 $display("Y _t = %b", Y _t);
//case 1
A_t <= 0; B_t <= 1;
#1 $display("Y _t = %b", Y _t);
//case 2
A_t <= 1; B_t <= 0;
//case 3
A_t <= 1; B_t <= 1;
#1 $display("Y _t = %b", Y_t);
end
endmodule
Waveforms
D) NOR Gate
Truth table Logic diagram
Y= A NOR B
=~(A+ B)
Verilog code for NOR gate
input A;
input B;
output Y;
reg Y;
always @ (A or B)
begin
endmodule
module NOR2gate_tb_v;
// Inputs
reg A;
reg B;
// Outputs
wire Y;
initial begin
// Initialize Inputs
A = 0;
B = 0;
A = 1;
B = 1;
end
endmodule
Waveforms
Program- 5
Aim: To write the verilog code for an Flip Flops ( RS,D,JK,MS.T) and the Test bench for Verification,
Observe the waveform and synthesize the code
Flip-flop: Flip-flop is a sequential logic circuit, which is ‘One ‘-bit memory element. OR It is a basic memory
element in digital systems (same as the bi-stable multivibrator) It has two stable state logic ‘1’ and logic ‘0’.
In a memory device set and Reset is often required for synchronization of the device in such case S-R
Flip-flop is need & this is refereed as clocked set-reset.
S R Q+ Action
0 0 Q No
Change
0 1 0 Reset
1 0 1 Set
1 1 - Illegal
Waveforms
b) D- FF (Delay Flip-flop)
In D-Flip-flop the transfer of data from the input to the Output is delayed and hence the name delay
D-Flip-flop. The D-Type Flip-flop is either used as a delay device or as a latch to store ‘1’ bit of
binary information.
D input transferred to Q output when clock asserted
module DFF_tb_v;
// Inputs
reg d;
reg clk;
// Outputs
wire q;
wire q_bar;
// Instantiate the Unit Under Test (UUT)
d_ff uut (
.d(d),
.clk(clk),
.q(q),
.q_bar(q_bar)
);
initial begin
// Initialize Inputs
d = 0;
clk = 0;
// Wait 100 ns for global reset to finish
#10;
// Add stimulus here
d = 1;
clk = 1;
end
endmodule
Waveforms
c) J.K Flip-flop:
input clk;
input rst;
input j;
input k;
output q;
output qn;
reg ff;
assign q=ff;
assign qn=~ff;
begin
if (rst==0)
ff=1'b0;
else
case({j,k})
2'b01:ff=1'b0;
2'b10:ff=1'b1;
2'b01:ff=~ff;
default:ff=ff;
endcase
end
endmodule
The race conditions in S-R Flip-flop can be eliminated by converting it in to J.K, the data inputs
S=J. ~Q
R=K.Q
JK-MS-F/F Truth table JK-MS-F/F Truth table
J K Q+ Action
0 0 Q No
0 1 0 Change
Reset
1 0 1 Set
1 1 Q Toggle
input j,k,clk;
inout q,qb;
//reg q,qb;
wire a, b, c, d;
wire y, yb;
wire cbar;
wire q1,qb1;
nand (a,j,qb,clk);
nand (b, k, q, clk);
nand ( y, a, yb);
nand ( yb, b, y);
//q==q1; qb == qb1;
nand (q, c, qb);
nand (qb, d, q);
endmodule
module JKMS_tb_v;
// Inputs
reg j;
reg k;
reg clk;
// Bidirs
wire q;
wire qb;
// Instantiate the Unit Under Test (UUT)
JKff uut (
.q(q),
.qb(qb),
.j(j),
.k(k),
.clk(clk)
);
initial begin
// Initialize Inputs
j = 0;
k = 0;
clk = 1;
// Wait 100 ns for global reset to finish
#10;
// Add stimulus here
j = 1;
k = 1;
clk = 1;
j = 0;
k = 1;
clk = 1;
end
Waveforms
e) T-Flip-flop (Toggle Flip-flop): On every change in clock pulse the output ‘Q’ changes its state
(Toggle). A Flip-flop with one data input which changes state for every clock pulse.
Q+
T Action
0 Q No Change
1 Q Toggle
module tff_tb_v;
// Inputs
reg data;
reg clk;
reg reset;
// Outputs
wire q;
// Instantiate the Unit Under Test (UUT)
tff_async_reset uut (
.data(data),
.clk(clk),
.reset(reset),
.q(q)
initial begin
// Initialize Inputs
data = 0;
clk = 0;
reset = 0;
end
initial
begin
$monitor ("data =%b, clk =%b, q =%b, reset =%b", data, clk,q, reset);
reset = 0;
clk =1;
data = 1;
#5 reset= ~reset;
#10 $finish;
end
always
begin
#5 clk= ~clk;
end
endmodule
Waveforms
Program- 6
Aim: To write the verilog code for Serial & Parallel Adder and the Test bench for Verification, Observe the
waveform and synthesize the code
a) Serial Adder
Logic Diagram
Truth Table
module sradd(a,b,start,clock,ready,result);
input a,b,start,clock;
output ready;
output [7:0] result;
reg [7:0] result;
reg sum,carry,ready;
integer count;
initial count = 8;
always @(negedge clock)
begin
if (start)
begin
count =0;carry = 0; result = 0;
end
else
begin
if (count <8)
begin
count = count + 1;
sum = a ^ b ^ carry ;
carry = (a&b)|(a & carry)|(b& carry);
result ={sum,result[7:1]};
end
end
if(count == 8)
ready = 1;
else
ready = 0;
end
endmodule
Waveforms
b) Parallel Adder:
Logic Diagram
Truth Table
input [3:0] A;
input [3:0] B;
input C0;
output [4:0] S;
reg [4:0] S;
// Inputs
reg [3:0] A;
reg [3:0] B;
reg C0;
// Outputs
wire [4:0] S;
// Instantiate the Unit Under Test (UUT)
addsub uut (
.A(A),
.B(B),
.C0(C0),
.S(S)
);
initial begin
// Initialize Inputs
A = 0;
B = 0;
C0 = 0;
// Wait 100 ns for global reset to finish
#10;
end
initial
begin
$monitor($time,
"A=%b,B=%b, c_in=%b, sum = %b\n",A,B,C0,S);
end
// These statements conduct the actual circuit test
initial
begin
A = 4'd0; B = 4'd0; C0 = 1'b0;
#50 A = 4'd3; B = 4'd4;
#50 A = 4'b0001; B = 4'b0010;
#50 A = 4'hc; B=4'h2;
end
endmodule
Waveforms
Program- 7
Aim: To write the verilog code for. 4-bit counter [Synchronous and Asynchronous counter]and the Test
bench for Verification, Observe the waveform and synthesize the code
A) Synchronous counter
Logic Diagram
module countr (
clock ,
reset ,
enable ,
counter_out
);
input clock ;
input reset ;
input enable ;
endmodule
Waveforms
B) Asynchronous counter
Logic Diagram
module acounter_tb_v;
// Inputs
reg clk;
// Outputs
wire [3:0] count;
initial begin
// Initialize Inputs
clk = 0;
end
initial
begin
clk = 0;
#100 $finish;
end
always
begin
#2 clk = ~clk;
end
always @( posedge clk)
$display("Count = %b", count );
endmodule
Waveforms
Program- 1
Aim: To Draw the schematic & Layout of Inverter and verify the a) DC Analysis ,b) Transient Analysis, and
to draw the Layout of Inverter & verify the DRC & ERC.
Layout of Inverter
Waveforms:
Program- 2
Aim: To Draw the schematic and verify the a) DC Analysis ,b) AC Analysis c)Transient Analysis,
and to draw the Layout & verify DRC & ERC . Extract RC and back annotate the same and verify the
following Design.
I. A Single Stage differential amplifier
II. Common source and Common Drain amplifier
.
I. Schematic design of A Single Stage differential amplifier
Waveforms:
Waveforms:
Waveforms:
Program- 3
Aim: To Draw the schematic of OP-AMP using given differential amplifier Common source and
Common Drain amplifier in library and verify the a) DC Analysis ,b) AC Analysis c)Transient Analysis, and
to draw the Layout & verify DRC & ERC . Extract RC and back annotate the same and verify the Design.
OP-AMP Symbol
Waveforms:
Program- 4
Aim: To Draw the schematic of 4 bit R-2R based DAC for the given specification and completing the
design flow mentioned using given op-amp in the library and verify the a) DC Analysis ,b) AC Analysis
c)Transient Analysis, and to draw the Layout & verify DRC & ERC . Extract RC and back annotate the
same and verify the Design.
Waveforms :
Program- 5
Aim: To Draw5 the SAR based ADC mentioned in the figure below draw the mixed signal schematic and
verify the functionality by completing ASIC Design FLOW
Waveforms: