VLSI Man
VLSI Man
1. Write a Verilog code for D-Latch and verify its functionality using test bench.
Synthesize the design, tabulate the area, power and timing report.
Tools required:
D-Latch: Latch is an electronic device that can be used to store one bit of information. The D
latch is used to capture, or 'latch' the logic level which is present on the Data line when the
enable input is high. If the data on the D line changes state while the enable is high, then the
output, Q, follows the input, D. When the enable input falls to logic 0, the last state of the D
input is trapped and held in the latch.
rst en d q qb
1 X X 0 1
0 0 X q qb
0 1 0 0 1
0 1 1 1 0
begin
if (rst)
q = 0;
else
if (en)
q = d;
end
assign qb = ~q;
endmodule
module dlatch_test;
reg d, en, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “d =”, d, “en =”, en, “rst =”, rst, “q =”, q, “qb =”, qb);
#160 $finish;
end
initial
begin
en = 0;
d = 0;
end
always
begin
#10 d = ~d;
#20 en = ~en;
end
initial
begin
rst = 1;
#10 rst = 0;
#90 rst = 1;
#30 rst = 0;
end
endmodule
Result:
Simulation:
Schematic:
Area report:
Power report:
Timing report:
2. Write a Verilog code for D Flip-Flop with synchronous and asynchronous reset and
verify its functionality using test bench. Synthesize the design, tabulate the area, power
and timing report.
Tools required:
D Flip-Flop: A D (or Delay) Flip Flop is a digital electronic circuit used to delay the change
of state of its output signal (Q) until the next rising edge of a clock timing input signal occurs.
The D Flip Flop acts as an electronic memory component since the output remains constant
unless deliberately changed by altering the state of the D input followed by a rising clock
signal.
rst clk d q qb
1 X 0 1
0 0 0 1
0 1 1 0
1 X 0 1
begin
if (rst)
q = 0;
else
q = d;
end
assign qb = ~q;
endmodule
module d_ff_test;
reg clk, rst, d;
wire q, qb;
d_ff d1(q, qb, d, clk, rst);
initial
begin
$monitor (“time = %0d”, $time, “ns”, “rst =”, rst, “d =”, d, “q =”, q, “qb =”, qb);
#40 $finish;
end
initial
clk = 0;
always
#5 clk = ~clk;
initial
begin
rst = 1; d = 0;
#10 rst = 0;
#10 d = 1;
#10 rst = 1;
end
endmodule
Result:
Simulation:
Schematic:
rst clk d q qb
0 X X 0 1
1 0 0 1
1 1 1 0
0 X X 0 1
begin
if (!rst)
q = 0;
else
q = d;
end
assign qb = ~q;
endmodule
module dff_test;
reg d, rst, clk;
wire q, qb;
dff d1 (q, qb, d, clk, rst);
initial
begin
$monitor ("time=%0d", $time, "ns", "rst =", rst, "d =", d, "q =", q, "qb =", qb);
#40 $finish;
end
initial
begin
d = 0;
clk = 0;
end
always
#5 clk = ~clk;
initial
begin
rst = 0;
#10 rst =1;
#10 d =1;
#10 rst = 0;
end
endmodule
Result:
Simulation:
Schematic:
3. Write a Verilog code for SR-Latch and verify its functionality using test bench.
Synthesize the design, tabulate the area, power and timing report.
Tools required:
SR-Latch: An Set and Reset Latch has two inputs S and R and two outputs q and qb. The state
of this latch is determined by the condition of q. If q is 1 the latch is said to be SET and if q is
0 the latch is said to be RESET.
rst en S r q qb
1 X X X 0 1
0 0 X X q qb
0 1 0 0 q qb
0 1 0 1 0 1
0 1 1 0 1 0
0 1 1 1 X X
begin
if (rst)
q = 0;
else
if (en)
begin
if (s == 0 && r == 0)
q = q;
else
if (s == 0 && r == 1)
q = 0;
else
if (s == 1 && r == 0)
q = 1;
else
if (s == 1 && r == 1)
q = 1’bx;
end
end
assign qb = ~q;
endmodule
module srlatch_test;
reg s, r, en, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “s =”, s, “r =”, r, “en =”, en, “rst =”, rst, “q =”, q, “qb
=”, qb);
#70 $finish;
end
initial
begin
rst = 1; en = 0; s = 1; r = 0;
#10; rst = 0;
#10; en = 1;
#10; s = 0; r = 0;
#10; s = 0; r = 1;
#10; s = 1; r = 0;
#10; s = 1; r = 1;
end
endmodule
Result:
Simulation:
Schematic:
4. Write a Verilog code for SR Flip-Flop with synchronous and asynchronous reset and
verify its functionality using test bench. Synthesize the design, tabulate the area, power
and timing report.
Tools required:
SR Flip-Flop: The SR flip flop is a 1-bit memory bistable device having two inputs, i.e., SET
and RESET. The SET input 's' set the device or produce the output 1, and the RESET input 'r'
reset the device or produce the output 0. The SET and RESET inputs are labelled as s and r,
respectively. The SR flip flop stands for "Set-Reset" flip flop. The reset input is used to get back
the flip flop to its original state from the current state with an output 'q'. This output depends
on the set and reset conditions, which is either at the logic level "0" or "1".
rst clk S r q qb
1 X X 0 1
0 0 0 q qb
0 0 1 0 1
0 1 0 1 0
0 1 1 X X
begin
if (rst)
q = 0;
else
if (s == 0 && r == 0)
q = q;
else
if (s == 0 && r == 1)
q = 0;
else
if (s == 1 && r == 0)
q = 1;
else
if (s == 1 && r == 1)
q = 1’bx;
end
assign qb = ~q;
endmodule
module sr_ff_test;
reg s, r, clk, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “s =”, s, “r =”, r, “rst =”, rst, “q =”, q, “qb =”, qb);
#80 $finish;
end
initial
clk = 1’b0;
always
#5 clk = ~clk;
initial
begin
rst = 1; s = 1; r = 0;
#10; rst = 0;
#10; s = 0; r = 0;
#10; s = 0; r = 1;
#10; s = 1; r = 0;
#10; s = 1; r = 1;
#10; s = 1; r = 0;
#10; rst = 1;
end
endmodule
Result:
Simulation:
Schematic:
rst clk S r q qb
0 X X X 0 1
1 0 0 q qb
1 0 1 0 1
1 1 0 1 0
1 1 1 X X
begin
if (!rst)
q = 0;
else
if (s == 0 && r == 0)
q = q;
else
if (s == 0 && r == 1)
q = 0;
else
if (s == 1 && r == 0)
q = 1;
else
if (s == 1 && r == 1)
q = 1’bx;
end
assign qb = ~q;
endmodule
module srff_test;
reg s, r, clk, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “s =”, s, “r =”, r, “rst =”, rst, “q =”, q, “qb =”, qb);
#80 $finish;
end
initial
clk = 1’b0;
always
#5 clk = ~clk;
initial
begin
rst = 0; s = 1; r = 0;
#10; rst = 1;
#10; s = 0; r = 0;
#10; s = 0; r = 1;
#10; s = 1; r = 0;
#10; s = 1; r = 1;
#10; s = 1; r = 0;
#10; rst = 0;
end
endmodule
Result:
Simulation:
Schematic:
5. Write a Verilog code for JK-Latch and verify its functionality using test bench.
Synthesize the design, tabulate the area, power and timing report.
Tools required:
JK-Latch: JK latch is similar to SR latch. This latch consists of 2 inputs j and k. The ambiguous
state has been eliminated here: when the inputs of JK latch are high, then output toggles.
rst en J k q qb
1 X X X 0 1
0 0 X X q qb
0 1 0 0 q qb
0 1 0 1 0 1
0 1 1 0 1 0
0 1 1 1 ~q ~qb
begin
if (rst)
q = 0;
else
if (en)
begin
if (j == 0 && k == 0)
q = q;
else
if (j == 0 && k == 1)
q = 0;
else
if (j == 1 && k == 0)
q = 1;
else
if (j == 1 && k == 1)
q = ~q;
end
end
assign qb = ~q;
endmodule
module jklatch_test;
reg j, k, en, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “j =”, j, “k =”, k, “en =”, en, “rst =”, rst, “q =”, q, “qb
=”, qb);
#70 $finish;
end
initial
begin
rst = 1; en = 0; j = 1; k = 0;
#10; rst = 0;
#10; en = 1;
#10; j = 0; k = 0;
#10; j = 0; k = 1;
#10; j = 1; k = 0;
#10; j = 1; k = 1;
end
endmodule
Result:
Simulation:
Schematic:
6. Write a Verilog code for JK Flip-Flop with synchronous and asynchronous reset and
verify its functionality using test bench. Synthesize the design, tabulate the area, power
and timing report.
Tools required:
JK Flip-Flop: The JK flip-flop is the most versatile of the basic flip flops. A JK flip-flop is used
in clocked sequential logic circuits to store one bit of data. It is almost identical in function to
an SR flip flop. The only difference is eliminating the undefined state where both S and R are
1. Due to this additional clocked input, a JK flip-flop has four possible input combinations,
such as "logic 1", "logic 0", "no change" and "toggle".
rst clk J k q qb
1 X X 0 1
0 0 0 q qb
0 0 1 0 1
0 1 0 1 0
0 1 1 ~q ~qb
begin
if (rst)
q = 0;
else
if (j == 0 && k == 0)
q = q;
else
if (j == 0 && k == 1)
q = 0;
else
if (j == 1 && k == 0)
q = 1;
else
if (j == 1 && k == 1)
q = ~q;
end
assign qb = ~q;
endmodule
module jk_ff_test;
reg j, k, clk, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “j =”, j, “k =”, k, “rst =”, rst, “q =”, q, “qb =”, qb);
#80 $finish;
end
initial
clk = 1’b0;
always
#5 clk = ~clk;
initial
begin
rst = 1; j = 1; k = 0;
#10; rst = 0;
#10; j = 0; k = 0;
#10; j = 0; k = 1;
#10; j = 1; k = 0;
#10; j = 1; k = 1;
#10; j = 1; k = 0;
#10; rst = 1;
end
endmodule
Result:
Simulation:
Schematic:
rst clk J k q qb
0 X X X 0 1
1 0 0 q qb
1 0 1 0 1
1 1 0 1 0
1 1 1 ~q ~qb
begin
if (!rst)
q = 0;
else
if (j == 0 && k == 0)
q = q;
else
if (j == 0 && k == 1)
q = 0;
else
if (j == 1 && k == 0)
q = 1;
else
if (j == 1 && k == 1)
q = ~q;
end
assign qb = ~q;
endmodule
module jkff_test;
reg j, k, clk, rst;
wire q, qb;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “j =”, j, “k =”, k, “rst =”, rst, “q =”, q, “qb =”, qb);
#80 $finish;
end
initial
clk = 1’b0;
always
#5 clk = ~clk;
initial
begin
rst = 0; j = 1; k = 0;
#10; rst = 1;
#10; j = 0; k = 0;
#10; j = 0; k = 1;
#10; j = 1; k = 0;
#10; j = 1; k = 1;
#10; j = 1; k = 0;
#10; rst = 0;
end
endmodule
Result:
Simulation:
Schematic:
7. Write verilog code for 4-bit up/down asynchronous reset counter and carry out the
following:
a. Verify the functionality using testbench
b. Synthesize the design by setting area and timing constraints. Obtain the gate level
netlist, find the critical path and maximum frequency of operation. Record the area
requirement in terms of number of cells required and properties of each cell in
terms of driving strength, power and area requirements.
c. Perform the above for 32-bit up/down counter and identify the critical path, delay
of the critical path, and maximum frequency of operation, total number of cells
required and total area.
Tools required:
4-bit up/down: An up/down counter is a digital counter which can be set to count either from
0 to maximum value or maximum value to 0. The direction of the count (mode) is selected using
a single bit input. The up/down counter has 3 inputs - clk, reset and a up or down mode input.
The output is count which is 4 bit in size. When Up mode is selected, counter counts from 0 to
15 and then again from 0 to 15. When Down mode is selected, counter counts from 15 to 0 and
then again from 15 to 0. Changing mode doesn't reset the Count value to zero. You have to
apply high value to reset, to reset the counter output.
0 1 F
0 1 E
0 1 D
1 X 0
if (reset)
count = 4'b0;
else
if (mode)
count = count + 1;
else
count = count - 1;
endmodule
module tb_cnt_updown;
reg mode;
reg clk, reset;
wire [3:0] count;
initial
begin
$monitor ("time = %0d", $time, "ns", "reset = 0x%0h", reset, " mode = 0x%0h", mode, " count
= 0x%0h", count);
#320 $finish;
end
always
#5 clk = ~clk;
initial
begin
mode = 1; clk=0; reset=1;
#10; reset = 0;
#100; mode = 0;
#50; reset = 1;
#30; reset = 0;
#100; mode = 1;
#10; reset = 1;
end
endmodule
➢ In terminal type “gedit constraints_top.sdc” to create an SDC file. (This file is common for
all programs)
➢ The SDC file must contain the following commands.
Performing Synthesize:
➢ The following are commands to perform synthesize (4-bit and 32-bit up/down asynchronous
reset counter)
genus -gui
read_lib /home/install/cad/slow.lib
read_hdl cnt_updown.v
elaborate
read_sdc constraints_top.sdc
report_power
report_gates
report_timing
report_area
report_qor -levels_of_logic -power -exclude_constant_nets
Result:
Simulation:
Area Report:
Gates Report:
Power Report:
Timing Report:
Schematic:
if (reset)
count = 32'b0;
else
if (mode)
count = count + 1;
else
count = count - 1;
endmodule
module tb_cnt_updown;
reg mode;
reg clk, reset;
wire [31:0] count;
initial
begin
$monitor ("time = %0d", $time, "ns", "reset = 0x%0h", reset, " mode = 0x%0h", mode, " count
= 0x%0h", count);
#900 $finish;
end
always
#5 clk = ~clk;
initial
begin
mode = 1; clk=0; reset=1;
#10; reset = 0;
#300; mode = 0;
#150; reset = 1;
#90; reset = 0;
#300; mode = 1;
#10; reset = 1;
end
endmodule
8. Write verilog code for 32-bit ALU supporting four logical and four arithmetic
operations, use case statement and if statement for ALU behavioral modeling.
a. Perform functional verification using test bench.
b. Synthesize the design targeting suitable library by setting area and timing
constraints.
c. For various constraints set, tabulate the area, power and delay for the synthesized
netlist.
d. Identify the critical path and set the constraints to obtain optimum gate level netlist
with suitable constraints.
Compare the synthesize results of ALU modeled using if and case statements.
Tools required:
Arithmetic Logical Unit (ALU): ALU is the fundamental building block of the processor,
which is responsible for carrying out the arithmetic and logical functions. ALU comprises of
combinational logic that implements arithmetic operations such as addition, subtraction,
multiplication, division etc.., and logical operations such as AND, OR, NAND, NOR etc.., The
ALU reads two input operands a and b. The operation to perform on these input operands is
selected using control input sel. The ALU performs the selected operation on the input
operands a and b and produces the output alu_out.
module alu_test;
reg [31:0] a, b;
reg [2:0] sel;
wire [63:0] alu_out;
initial
begin
a = 32’hFEDCBA98;
b = 32’h89ABCDEF;
sel = 3’b000;
$monitor (“a = 0x%0h b = 0x%0h sel = 0x%0h alu_out = 0x%0h”, a, b, sel, alu_out);
#80; $finish;
end
always
#10 sel = sel + 3’b001;
endmodule
Result:
Simulation:
Schematic:
module alu_test;
reg [31:0] a, b;
reg [2:0] sel;
wire [63:0] alu_out;
initial
begin
a = 32’hFEDCBA98;
b = 32’h89ABCDEF;
sel = 3’b000;
$monitor (“a = 0x%0h b = 0x%0h sel = 0x%0h alu_out = 0x%0h”, a, b, sel, alu_out);
#80; $finish;
end
always
#10 sel = sel + 3’b001;
endmodule
Result:
Simulation:
Schematic:
9. Write verilog code for 4-bit adder and verify its functionality using test bench.
Synthesize the design by setting proper constraints and obtain netlist. From the report
generated identify the critical path, and maximum delay, total number of cells, power
requirement and total area required. Change the constraints and obtain optimum
synthesis results.
Tools required:
Full-Adder: Full Adder is the adder which adds three inputs and produces two outputs. The
first two inputs are a and b and the third input is an input carry as cin. The output carry is
designated as cout and the normal output is sum.
Inputs Outputs
a b cin sum cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
4-bit Full Adder: Binary adders are implemented to add two binary numbers. So in order to
add two 4-bit binary numbers, we will need to use 4 full-adders. The 4 full-adders are
connected in cascade form. In this implementation, cout of each full-adder is connected to next
cin.
Inputs Outputs
a b cin sum cout
4’b0001 4’b1010 4’b1011 0
4’b1100 4’b1101 4’b1001 1
0
4’b0101 4’b1011 4’b0000 1
4’b1111 4’b1111 4’b1110 1
4’b0001 4’b1010 4’b1100 0
4’b1100 4’b1101 4’b1010 1
1
4’b0101 4’b1011 4’b0001 1
4’b1111 4’b1111 4’b1111 1
endmodule
endmodule
module test_adder;
reg [3:0] a, b;
reg cin;
wire [3:0] sum;
wire cout;
initial
begin
$monitor (“time = %0d”, $time, “ns”, “a = %0b”, a, “b = %0b”, b, “cin = %0b”, cin, “sum =
%0b”, sum, “cout = %0b”, cout);
#30 $finish;
end
initial
begin
a = 4’b0011; b = 4’b0011; cin = 1’b0;
#10; a = 4’b1011; b = 4’b1000; cin = 1’b1;
#10; a = 4’b1111; b = 4’b1100; cin = 1’b1;
end
endmodule
Result:
Simulation:
Schematic:
Transient Response
DC Response
Width setting MOSFET Width tphl (ps) tplh (ps) tpd (ps)
pmos 2u
Wp = Wn 188.4 445.5 316.95
nmos 2u
pmos 7.5u
Wp = 3.75 Wn 225.4 208.4 216.9
nmos 2u
pmos 13u
Wp = 6.5 Wn 260.6 115.7 188.15
nmos 2u
Transient Response
DC Response
Transient Response
DC Response
CMOS Inverter
203 304 253.5
Test Schematic
CMOS Inverter
205.6 305.7 255.65
Layout
CMOS Inverter
828.7 828.7
Layout
Analog Simulation with spectre for Two Input CMOS NAND Gate:
Transient Response
Analog Simulation with spectre for Two Input CMOS NAND Gate test schematic:
Transient Response
Analog Simulation with spectre for Two Input CMOS NAND Gate Layout:
Transient Response
Library Cell
Properties
Name Name
Transient Response
DC Response
AC Response
Transient Response
DC Response
AC Response
Library Cell
Properties
Name Name
DC Voltage = 2.5 V (Vdd)
analogLib Vdc
DC Voltage = -2.5 V (Vss)
AC Magnitude = 1 V, DC Voltage = 0 V, Offset Voltage = 0 V
analogLib Vsin Amplitude = 5u V, Frequency = 1K Hz
analogLib idc DC Current = 30u A
Transient Response
DC Response
AC Response
Transient Response
DC Response
AC Response