Vlsi Lab Manual
Vlsi Lab Manual
Lab Manual
Prepared by:
Dr. Manikandan Veerappan, Assistant Professor-ECE
Dr. Jothi Mariappan, Assistant Professor-ECE
VLSI Design Laboratory (Course Code: 21ECC311L)
Table of Contents
page no.
Course Overview:
The VLSI Design Laboratory (Course Code: 21ECC311L) is a practical, hands-on course
designed to provide students with in-depth knowledge and skills in designing, simulating, and
implementing digital circuits using Very Large Scale Integration (VLSI) techniques. The lab
focuses on the application of Hardware Description Languages (HDLs), specifically Verilog
HDL, and simulation tools like QuestaSim, Xilinx Vivado, HSPICE, and LTSPICE to model,
analyze, and synthesize combinational and sequential circuits, VLSI subsystems, and
transistor-level designs. The curriculum aligns with modern digital design practices, emphasizing
behavioral, structural, and switch-level modeling for FPGA and ASIC implementations. This lab
equips students with practical skills for careers in VLSI design, digital circuit engineering, and
embedded systems. It bridges theoretical concepts with industry-relevant tools and techniques,
preparing students for roles in semiconductor design, FPGA development, and ASIC
prototyping.
Objectives:
● To develop proficiency in designing combinational and sequential logic circuits using
Verilog HDL.
● To understand and implement VLSI subsystems such as adders, multipliers, memory
units, and ALUs.
● To gain expertise in transistor-level design and analysis using CMOS and other logic
styles.
● To learn FPGA deployment processes, including synthesis, mapping, and bitstream
generation.
● To explore advanced VLSI concepts through challenging experiments like barrel shifters,
FSMs, and processor datapaths.
Course Learning Rationale (CLR): The purpose of learning this course is to: Program Outcomes (PO) Program
Specific
CLR-1: learn Hardware Descriptive Language (Verilog/VHDL) 1 2 3 4 5 6 7 8 9 10 11 12 Outcomes
Design/development of
Communication
CLR-4: hands on design experience with professional design (EDA) platforms
Environment &
Sustainability
CLR-5: understand the concept of transistors are built, and the physical implementation of circuits
solutions
society
PSO-1
PSO-2
PSO-3
Ethics
Course Outcomes (CO): At the end of this course, learners will be able to:
CO-1: design and implement digital circuits using Verilog HDL to simulate and verify the designs 3 2 - - 1 - - - - - - - 1 - -
design general VLSI system components, adder cells and multipliers to address the design of data path
CO-2: 3 2 - - 1 - - - - - - - 1 - -
subsystem
CO-3: examine the characteristics of MOS transistors 3 2 - - 1 - - - - - - - 1 - -
CO-4: analyze CMOS inverter and other complex logic gates designed using different logic styles 3 2 - - 1 - - - - - - - 1 - -
use HSPICE computer analysis program and Verilog HDL for simulation, analysis of MOS circuits and
CO-5: 3 2 - - 1 - - - - - - - 1 - -
building blocks
Learning 1. Verilog HDL- A Guide to Digtial Design and Synthesis, Sameer Palnitkar, 2. Xilinx vivado 2020 Version
Resources Pearson publication. 3. Questasim - powered by Siemens
32
B.Tech / M.Tech (Integrated) Programmes-Regulations 2021-Volume-14-ECE-Higher Semester Syllabi-Control Copy
Learning Assessment
Continuous Learning Assessment (CLA)
CLA-1 Average of first cycle CLA-2 Average of second Practical Examination Final Examination
Bloom’s
experiments cycle experiments (40% weightage (0% weightage)
Level of Thinking
(30%) (30%)
Theory Practice Theory Practice Theory Practice Theory Practice
Level 1 Remember - 20% - 20% - 20% - -
Level 2 Understand - 20% - 20% - 20% - -
Level 3 Apply - 30% - 30% - 30% - -
Level 4 Analyze - 30% - 30% - 30% - -
Level 5 Evaluate - - - - - - - -
Level 6 Create - - - - - - - -
Total 100 % 100 % 100% -
Course Designers
Experts from Industry Experts from Higher Technical Institutions Internal Experts
1. Mr. Leela Krishna Thota, Sr. Solution Engineer II, SRG, 1. Dr. Meenakshi, Professor of ECE, CEG, Anna University, 1 Dr. J. Selvakumar, SRMIST
Synopsys India Pvt. Ltd [email protected]
2. Dr. Venkatesan, Sr. Scientist, NIOT, Chennai,
[email protected]
33
B.Tech / M.Tech (Integrated) Programmes-Regulations 2021-Volume-14-ECE-Higher Semester Syllabi-Control Copy
Safety rules for VLSI laboratory
• Follow Instructions: Always follow the instructions provided by the instructor, lab manual,
or safety guidelines.
• Emergency Preparedness: Familiarize yourself with the location and operation of
emergency power cut-off switches, fire extinguishers, and first aid kits.
• Accident Reporting: Report any injury, accident, or equipment damage to the lab
supervisor immediately.
• Behavior: Maintain discipline, avoid horseplay, and respect lab property at all times.
• ESD Protection: Avoid synthetic clothing that generates static charge, and touch a
grounded object before handling components.
• Hardware Handling: Hold ICs, PCBs, and boards by the edges. Do not touch pins, pads, or
connectors directly. Power down all equipment before making or breaking connections to
avoid damage to devices and risk of electric shock.
• Workstation Safety: Ensure that all cables are neatly routed and do not obstruct walkways.
Avoid daisy-chaining power strips and overloading sockets.
• Environment: Keep all liquids, including water bottles, away from the equipment. Moisture
can cause short circuits and permanent damage.
• General Conduct: Follow software license agreements and institution guidelines when
using proprietary EDA tools. Report any malfunctioning equipment to the lab-in-charge
without delay.
VLSI Design Laboratory (Course Code: 21ECC311L)
List of Experiments
1. Basic: Design of Basic Logic Gates using Verilog HDL (Gate-Level Modeling)
2. Basic: Design of a 2-to-1 Multiplexer using Verilog HDL (Behavioral Modeling)
3. Basic: Design of a D Flip-Flop using Verilog HDL (Behavioral Modeling)
4. Realization of Combinational Logic Circuit using Verilog HDL (Behavioral Modeling)
5. Realization of Sequential Logic Circuit using Verilog HDL (Behavioral Modeling)
6. Design and Implementation of Ripple Carry Adder (Structural Modeling)
7. Design and Implementation of Carry Save Adder (Structural Modeling)
8. Design and Implementation of Carry Select Adder (Structural Modeling)
9. Design and Implementation of Braun Multiplier (Structural Modeling)
10.Design and Implementation of Booth Multiplier (Structural Modeling)
11.Design and Implementation of Wallace Tree Multiplier (Structural Modeling)
12.Design of 1K x 8 RAM (Behavioral Modeling)
13.Design of 1K x 8 ROM (Behavioral Modeling)
14.Design of 4K x 16 RAM (Behavioral Modeling)
15.Design of 4K x 16 ROM (Behavioral Modeling)
16.Design of 4-bit ALU (Behavioral Modeling)
17.Design and Analysis of CMOS Inverter using HSPICE (Switch-Level Modeling)
18.Design and Analysis of AND/NAND Gate using LTSPICE (Switch-Level Modeling)
19.Design and Analysis of 4-input Dynamic NAND Gate using HSPICE (Switch-Level
Modeling)
20.Design of Sequential Circuit using FSM and ASM Charts (Behavioral Modeling)
21.Challenging: Design of a 4-bit Barrel Shifter (Behavioral Modeling)
22.Challenging: Implementation of a Finite State Machine for Traffic Light Controller
(Behavioral Modeling)
23.Challenging: Design of a 16-bit Vedic Multiplier (Structural Modeling)
24.Challenging: Implementation of a Simple Processor Datapath (Structural Modeling)
25.Challenging: Design of a 4-bit Binary to Gray Code Converter (Behavioral Modeling)
26.Challenging: Implementation of a Priority Encoder (Behavioral Modeling)
Aim: To design and implement basic logic gates (AND, OR, NOT, NAND, NOR, XOR) using
Verilog HDL and verify their functionality.
Apparatus Required:
Theory:
Logic gates are the fundamental building blocks of digital circuits. Each gate performs a specific
Boolean operation:
module logic_gates (
input a, b,
output and_out, or_out, not_out, nand_out, nor_out, xor_out
);
and (and_out, a, b);
or (or_out, a, b);
not (not_out, a);
nand (nand_out, a, b);
nor (nor_out, a, b);
xor (xor_out, a, b);
endmodule
Expected Output:
1. Write and simulate the Verilog code in QuestaSim to verify gate functionality.
2. Synthesize the design using Xilinx Vivado.
3. Assign input/output pins in the constraints file (.xdc).
4. Generate the bitstream and program the FPGA.
5. Test outputs using switches and LEDs on the FPGA board.
Result:
Apparatus Required:
Theory:
A multiplexer (MUX) selects one of several input signals and forwards it to a single output,
based on a select signal. A 2-to-1 MUX has two data inputs (D0, D1), one select input (S), and
one output (Y). When S = 0, Y = D0; when S = 1, Y = D1. Behavioral modeling in Verilog
describes the functionality using high-level constructs like always blocks, abstracting the
gate-level details and focusing on input-output behavior.
module mux_2to1 (
input d0, d1, s,
output reg y
);
always @(*) begin
y = s ? d1 : d0;
end
endmodule
Expected Output:
Result:
Apparatus Required:
Theory:
A D Flip-Flop (DFF) is a sequential circuit that stores a single bit of data. It captures the value of
the D input at the rising edge of the clock and holds it until the next clock edge. It is widely used
in registers and memory elements. Behavioral modeling describes the DFF’s functionality using
always blocks triggered by clock edges, abstracting the underlying gate structure.
module d_flip_flop (
input clk, rst, d,
output reg q
);
always @(posedge clk or posedge rst) begin
if (rst)
q <= 0;
else
q <= d;
end
endmodule
Model Graph/Table:
Expected Output:
Result:
Aim: To design and implement a combinational logic circuit (4-bit Full Adder) using Verilog
HDL.
Apparatus Required:
Theory:
Combinational circuits produce outputs based solely on current inputs, with no memory
elements. A 4-bit full adder adds two 4-bit binary numbers and a carry-in, producing a 4-bit sum
and a carry-out. Each bit is processed by a 1-bit full adder, with carries propagated between
stages. Behavioral modeling in Verilog uses high-level constructs like arithmetic operators to
describe the adder’s functionality, making it easier to design and simulate compared to gate-level
modeling.
module full_adder_4bit (
input [3:0] A, B,
input Cin,
output [3:0] Sum,
output Cout
);
assign {Cout, Sum} = A + B + Cin;
endmodule
Expected Output:
Result:
Apparatus Required:
Theory:
Sequential circuits have memory, with outputs depending on current inputs and past states. A
4-bit counter increments its value on each clock cycle, resetting to zero when reset is asserted. It
uses flip-flops to store the state, with combinational logic for incrementing. Behavioral modeling
simplifies the design by using high-level constructs like always blocks and arithmetic operations,
abstracting the flip-flop and gate-level details.
module counter_4bit (
input clk, rst,
output reg [3:0] count
);
always @(posedge clk or posedge rst) begin
if (rst)
count <= 4'b0000;
else
count <= count + 1;
end
endmodule
Expected Output:
Result:
Apparatus Required:
Theory:
A ripple carry adder (RCA) adds two n-bit binary numbers by propagating the carry through
each bit position. Each bit is processed by a 1-bit full adder, with the carry-out of one stage
feeding the carry-in of the next. This results in a propagation delay proportional to the number of
bits, making RCAs simple but slower for large numbers. Structural modeling in Verilog
explicitly instantiates lower-level modules (e.g., full adders), reflecting the hierarchical hardware
structure.
module ripple_carry_adder (
input [3:0] A, B,
input Cin,
output [3:0] Sum,
output Cout
);
wire [2:0] carry;
full_adder fa0 (A[0], B[0], Cin, Sum[0], carry[0]);
full_adder fa1 (A[1], B[1], carry[0], Sum[1], carry[1]);
full_adder fa2 (A[2], B[2], carry[1], Sum[2], carry[2]);
full_adder fa3 (A[3], B[3], carry[2], Sum[3], Cout);
module full_adder (
input A, B, Cin,
output Sum, Cout
);
assign Sum = A ^ B ^ Cin;
assign Cout = (A & B) | (B & Cin) | (A & Cin);
endmodule
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
Theory:
A carry save adder (CSA) adds three or more numbers by generating partial sum and carry
vectors, which are summed later. Unlike RCAs, CSAs avoid carry propagation within each stage,
reducing delay. They are used in high-speed arithmetic circuits like multipliers. Structural
modeling instantiates full adders to form the CSA, explicitly defining the hardware hierarchy.
module carry_save_adder (
input [3:0] A, B, C,
output [4:0] Sum
);
wire [3:0] carry, sum_temp;
full_adder fa0 (A[0], B[0], C[0], sum_temp[0], carry[0]);
full_adder fa1 (A[1], B[1], C[1], sum_temp[1], carry[1]);
full_adder fa2 (A[2], B[2], C[2], sum_temp[2], carry[2]);
full_adder fa3 (A[3], B[3], C[3], sum_temp[3], carry[3]);
assign Sum = {carry[3], sum_temp};
endmodule
Expected Output:
Result:
Apparatus Required:
Theory:
A carry select adder (CSLA) reduces delay by computing sums for both carry-in values (0 and 1)
in parallel for each block, using a multiplexer to select the correct output based on the actual
carry-in. This approach balances speed and area compared to RCAs and carry look-ahead adders.
Structural modeling explicitly instantiates RCAs and multiplexers.
module carry_select_adder (
input [3:0] A, B,
input Cin,
output [3:0] Sum,
output Cout
);
wire [3:0] sum0, sum1;
wire c0, c1;
ripple_carry_adder rca0 (A[1:0], B[1:0], 0, sum0[1:0], c0);
ripple_carry_adder rca1 (A[1:0], B[1:0], 1, sum1[1:0], c1);
assign Sum[1:0] = Cin ? sum1[1:0] : sum0[1:0];
assign Cout = Cin ? c1 : c0;
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
Theory:
A Braun multiplier computes the product of two unsigned numbers using an array of AND gates
to generate partial products, followed by an adder tree to sum them. It is area-efficient for
smaller bit widths but has higher latency than advanced multipliers like Wallace tree. Structural
modeling instantiates AND gates and adders explicitly.
module braun_multiplier (
input [3:0] A, B,
output [7:0] Product
);
wire [15:0] partial_products;
genvar i, j;
generate
for (i = 0; i < 4; i = i + 1) begin
for (j = 0; j < 4; j = j + 1) begin
assign partial_products[i*4+j] = A[i] & B[j];
end
end
endgenerate
assign Product = partial_products[0] + (partial_products[1] << 1) + (partial_products[2] << 2)
+ (partial_products[3] << 3);
endmodule
Model Graph:
Expected Output:
Result:
Aim: To design and implement a 4x4 Booth multiplier using Verilog HDL and verify its
functionality on an FPGA.
Apparatus Required:
Theory:
Booth's multiplication algorithm is an efficient method for multiplying signed binary numbers,
reducing the number of partial products compared to traditional multipliers. It processes the
multiplier in pairs of bits, generating partial products based on three operations: add the
multiplicand, subtract the multiplicand, or add zero. For a 4x4 Booth multiplier, the multiplicand
and multiplier are 4-bit signed numbers, producing an 8-bit product. The algorithm uses a
recoding scheme to determine whether to add, subtract, or skip the multiplicand for each pair of
bits, followed by shifting and addition. Structural modeling in Verilog instantiates components
like adders and shifters to construct the multiplier, reflecting the hardware hierarchy.
module booth_multiplier (
input signed [3:0] A, B, // Multiplicand and Multiplier
output signed [7:0] Product
);
wire signed [7:0] pp0, pp1, pp2, pp3;
reg [4:0] recoded [0:2];
Model Graph:
Expected Output:
1. Write and simulate the Verilog code in QuestaSim to verify functionality.
2. Synthesize the design using Xilinx Vivado.
3. Assign input/output pins in the constraints file (.xdc).
4. Generate the bitstream and program the FPGA.
5. Test the multiplier using FPGA switches and LEDs for input/output verification.
Result:
Apparatus Required:
Theory:
A Wallace tree multiplier reduces partial products using a tree of carry save adders, minimizing
delay by performing additions in parallel. It is faster than Braun multipliers for larger bit widths
but requires more complex wiring. Structural modeling explicitly defines the CSA hierarchy.
module wallace_tree_multiplier (
input [3:0] A, B,
output [7:0] Product
);
wire [3:0] pp[3:0];
genvar i, j;
generate
for (i = 0; i < 4; i = i + 1) begin
for (j = 0; j < 4; j = j + 1) begin
assign pp[i][j] = A[i] & B[j];
end
end
endgenerate
wire [7:0] sum1, sum2;
carry_save_adder csa1 (pp[0], pp[1] << 1, pp[2] << 2, sum1);
carry_save_adder csa2 (sum1, pp[3] << 3, 0, Product);
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
Theory:
Random Access Memory (RAM) stores data in a 2D array, accessed via an address. A 1K x 8
RAM has 1024 locations, each 8 bits wide, requiring a 10-bit address. It supports read and write
operations, controlled by a write-enable signal. Behavioral modeling describes the memory’s
functionality using arrays and always blocks, abstracting the address decoder and storage
elements.
module ram_1kx8 (
input clk, we,
input [9:0] addr,
input [7:0] data_in,
output reg [7:0] data_out
);
reg [7:0] mem [0:1023];
always @(posedge clk) begin
if (we)
mem[addr] <= data_in;
data_out <= mem[addr];
end
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
Theory:
Read-Only Memory (ROM) is a non-volatile memory that stores fixed data, accessed via an
address. A 1K x 8 ROM has 1024 (2^10) locations, each storing an 8-bit word, addressed by a
10-bit address line. Unlike RAM, ROM data is predefined and cannot be modified during
operation. Behavioral modeling in Verilog uses a memory array initialized with data (e.g., using
$readmemh) to model the ROM, abstracting the address decoder and storage elements. ROMs
are used in applications like lookup tables and firmware storage.
module rom_1kx8 (
input clk,
input [9:0] addr,
output reg [7:0] data_out
);
reg [7:0] mem [0:1023];
Model Graph:
● Waveform showing address input and corresponding data output on clock edges.
Expected Output:
1. Prepare a .hex file with ROM data or initialize manually in the code.
2. Simulate the design in QuestaSim to verify read operations.
3. Synthesize using Vivado, ensuring ROM is mapped to FPGA block memory.
4. Assign address and output pins in the constraints file.
5. Generate bitstream, program FPGA, and verify outputs using LEDs or a display.
Result:
Apparatus Required:
Theory:
Random Access Memory (RAM) is a volatile memory that supports read and write operations. A
4K x 16 RAM has 4096 (2^12) locations, each storing a 16-bit word, addressed by a 12-bit
address line. A write-enable (we) signal controls whether data is written to the addressed location
or read from it. Behavioral modeling in Verilog uses a memory array and always blocks to
describe read/write operations, abstracting the address decoder and storage cells. RAM is critical
in systems requiring temporary data storage, such as processor registers and buffers.
module ram_4kx16 (
input clk, we,
input [11:0] addr,
input [15:0] data_in,
output reg [15:0] data_out
);
reg [15:0] mem [0:4095];
Model Graph:
● Waveform showing write operation (we = 1) storing data and read operation (we = 0)
retrieving data.
Expected Output:
● Write 16'hABCD to addr = 0x000 (we = 1), then read from addr = 0x000 (we = 0):
data_out = 16'hABCD
Result:
Apparatus Required:
Theory:
A 4K x 16 ROM stores 4096 (2^12) 16-bit words, accessed via a 12-bit address line. Unlike
RAM, ROM contains fixed data, typically initialized at design time for applications like lookup
tables or instruction memory. Behavioral modeling in Verilog uses a memory array initialized
with data (e.g., via $readmemh) to model the ROM, simplifying the design by abstracting the
address decoder and storage. ROMs are synthesized as block memory in FPGAs, leveraging
dedicated resources for efficiency.
module rom_4kx16 (
input clk,
input [11:0] addr,
output reg [15:0] data_out
);
reg [15:0] mem [0:4095];
Model Graph:
● Waveform showing address input and corresponding 16-bit data output on clock edges.
Expected Output:
Result:
Apparatus Required:
Theory:
An Arithmetic Logic Unit (ALU) performs arithmetic (e.g., addition, subtraction) and logical
(e.g., AND, OR) operations, selected by an operation code. A 4-bit ALU processes 4-bit
operands, producing a 4-bit result. Behavioral modeling uses a case statement to select
operations, simplifying the design compared to structural modeling.
module alu_4bit (
input [3:0] A, B,
input [2:0] op,
output reg [3:0] result
);
always @(*) begin
case (op)
3'b000: result = A + B; // Add
3'b001: result = A - B; // Subtract
3'b010: result = A & B; // AND
3'b011: result = A | B; // OR
default: result = 0;
endcase
end
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
● HSPICE Simulator
● Computer with text editor
Theory:
A CMOS inverter consists of a PMOS and NMOS transistor connected between Vdd and
ground. When the input is low, the PMOS conducts, pulling the output high; when the input is
high, the NMOS conducts, pulling the output low. This design minimizes static power
consumption due to complementary switching. Switch-level modeling in HSPICE simulates
transistor behavior, analyzing voltage and timing characteristics.
* CMOS Inverter
.include '45nm_cmos.lib'
M1 out in Vdd Vdd pmos L=45n W=120n
M2 out in 0 0 nmos L=45n W=120n
Vdd Vdd 0 1.0
Vin in 0 PULSE(0 1 0 1n 1n 10n 20n)
.tran 0.1n 50n
.plot v(in) v(out)
.end
Model Graph:
Expected Output:
Result:
Apparatus Required:
● LTSPICE Simulator
● Computer with text editor
Theory:
A NAND gate outputs 0 only when all inputs are 1, implemented using two PMOS transistors in
parallel and two NMOS transistors in series. An AND gate can be derived by inverting the
NAND output. Switch-level modeling in LTSPICE simulates transistor-level behavior, analyzing
timing and power characteristics.
* NAND Gate
.include '45nm_cmos.lib'
M1 out a Vdd Vdd pmos L=45n W=120n
M2 out b Vdd Vdd pmos L=45n W=120n
M3 out a n1 0 nmos L=45n W=120n
M4 n1 b 0 0 nmos L=45n W=120n
Vdd Vdd 0 1.0
Va a 0 PULSE(0 1 0 1n 1n 10n 20n)
Vb b 0 PULSE(0 1 5n 1n 1n 10n 20n)
.tran 0.1n 50n
.plot v(a) v(b) v(out)
.end
Model Graph:
Expected Output:
Result:
Experiment 19: Design and Analysis of 4-input Dynamic NAND Gate using HSPICE
Aim: To design and analyze a 4-input dynamic NAND gate using HSPICE.
Apparatus Required:
● HSPICE Simulator
● Computer with text editor
Theory:
A dynamic NAND gate uses a precharge phase (clock low, PMOS charges output) and an
evaluation phase (clock high, NMOS evaluates inputs). If all inputs are 1, the output discharges;
otherwise, it remains high. Dynamic logic reduces transistor count and increases speed but
requires careful clock management. Switch-level modeling analyzes transistor dynamics.
Model Graph:
Expected Output:
Result:
Experiment 20: Design of Sequential Circuit using FSM and ASM Charts
Aim: To design a sequential circuit using Finite State Machine (FSM) and Algorithmic State
Machine (ASM) charts, implemented in Verilog HDL, and deploy it on an FPGA.
Apparatus Required:
Theory:
A Finite State Machine (FSM) is a model for sequential circuits with a finite number of states,
transitioning based on inputs and a clock. An Algorithmic State Machine (ASM) chart is a
graphical representation of an FSM, showing states, transitions, and outputs in a flowchart-like
format. For this experiment, a simple sequence detector (e.g., detecting "101") is designed. The
FSM has states to track the input sequence, with transitions based on the input bit. ASM charts
provide a structured way to visualize state transitions, conditions, and outputs, aiding in Verilog
implementation. Behavioral modeling uses always blocks to describe the state machine,
abstracting the underlying flip-flops and combinational logic.
module sequence_detector (
input clk, rst, in,
output reg out
);
reg [1:0] state, next_state;
parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10, S3 = 2'b11;
// State transition
always @(posedge clk or posedge rst) begin
if (rst)
state <= S0;
else
state <= next_state;
end
case (state)
S0: begin
next_state = in ? S1 : S0;
end
S1: begin
next_state = in ? S1 : S2;
end
S2: begin
next_state = in ? S3 : S0;
end
S3: begin
out = in ? 0 : 1; // Detect "101"
next_state = in ? S1 : S0;
end
default: next_state = S0;
endcase
end
endmodule
Model Graph:
● Waveform showing state transitions and output for input sequence "101".
Expected Output:
1. Draw the FSM and ASM chart for the sequence detector.
2. Simulate the Verilog code in QuestaSim to verify sequence detection.
3. Synthesize using Vivado, ensuring proper clock constraints.
4. Assign pins for clock, reset, input, and output in the constraints file.
5. Generate bitstream, program FPGA, and test with switch inputs and LED output.
Result:
Apparatus Required:
Theory:
A barrel shifter performs left or right shifts by a variable number of bits in a single cycle, using a
multiplexer-based structure. It is used in processors for efficient data manipulation (e.g., bit
rotation). Behavioral modeling uses a case statement to select the shifted output, abstracting the
multiplexer array and simplifying the design process.
module barrel_shifter (
input [3:0] data_in,
input [1:0] shift,
input direction, // 0 for left, 1 for right
output reg [3:0] data_out
);
always @(*) begin
case ({direction, shift})
3'b000: data_out = data_in;
3'b001: data_out = {data_in[2:0], 1'b0};
3'b010: data_out = {data_in[1:0], 2'b00};
3'b011: data_out = {data_in[0], 3'b000};
3'b100: data_out = data_in;
3'b101: data_out = {1'b0, data_in[3:1]};
3'b110: data_out = {2'b00, data_in[3:2]};
3'b111: data_out = {3'b000, data_in[3]};
default: data_out = data_in;
endcase
end
endmodule
● 4-bit input, 2-bit shift control, and direction bit feeding a multiplexer.
Model Graph:
Expected Output:
Result:
Challenging Experiment 22: Implementation of a Finite State Machine for Traffic Light
Controller
Apparatus Required:
Theory:
A Finite State Machine (FSM) models a system with discrete states, transitioning based on inputs
and a clock. A traffic light controller FSM cycles through Red, Green, and Yellow states, with
transitions controlled by a timer. Behavioral modeling uses always blocks to describe state
transitions and outputs, providing a high-level abstraction of the state machine.
module traffic_light_controller (
input clk, rst,
output reg [2:0] light // R: 100, G: 010, Y: 001
);
reg [1:0] state, next_state;
reg [3:0] timer;
parameter RED = 2'b00, GREEN = 2'b01, YELLOW = 2'b10;
always @(posedge clk or posedge rst) begin
if (rst) begin
state <= RED;
timer <= 0;
end else begin
state <= next_state;
timer <= timer + 1;
end
end
always @(*) begin
case (state)
RED: begin
light = 3'b100;
next_state = (timer == 4'd10) ? GREEN : RED;
end
GREEN: begin
light = 3'b010;
next_state = (timer == 4'd10) ? YELLOW : GREEN;
end
YELLOW: begin
light = 3'b001;
next_state = (timer == 4'd5) ? RED : YELLOW;
end
default: next_state = RED;
endcase
end
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
Theory:
A Vedic multiplier uses the Urdhva Tiryakbhyam algorithm from Vedic mathematics, dividing
multiplication into smaller steps (e.g., 8-bit multiplications) and combining results with shifters
and adders. This approach reduces latency compared to conventional multipliers for large bit
widths. Structural modeling instantiates smaller multipliers and adders, reflecting the hierarchical
design.
module vedic_multiplier_16bit (
input [15:0] A, B,
output [31:0] Product
);
wire [15:0] p0, p1, p2, p3;
vedic_8bit v0 (A[7:0], B[7:0], p0);
vedic_8bit v1 (A[15:8], B[7:0], p1);
vedic_8bit v2 (A[7:0], B[15:8], p2);
vedic_8bit v3 (A[15:8], B[15:8], p3);
assign Product = p0 + (p1 << 8) + (p2 << 8) + (p3 << 16);
module vedic_8bit (
input [7:0] A, B,
output [15:0] Product
);
wire [7:0] pp[7:0];
genvar i, j;
generate
for (i = 0; i < 8; i = i + 1) begin
for (j = 0; j < 8; j = j + 1) begin
assign pp[i][j] = A[i] & B[j];
end
end
endgenerate
assign Product = pp[0] + (pp[1] << 1) + (pp[2] << 2) + (pp[3] << 3) +
(pp[4] << 4) + (pp[5] << 5) + (pp[6] << 6) + (pp[7] << 7);
endmodule
endmodule
Model Graph:
Expected Output:
Result:
Apparatus Required:
Theory:
A processor datapath executes instructions like ADD, SUB, and LOAD, comprising a register
file, ALU, and control logic. The register file stores data, the ALU performs operations, and
multiplexers select inputs. Structural modeling instantiates these components explicitly,
reflecting the processor’s architecture.
module processor_datapath (
input clk, rst,
input [3:0] opcode,
input [3:0] reg_addr1, reg_addr2, reg_dst,
input [7:0] immediate,
output reg [7:0] result
);
reg [7:0] reg_file [0:15];
wire [7:0] alu_out;
alu_4bit alu (reg_file[reg_addr1], reg_file[reg_addr2], opcode[2:0], alu_out);
always @(posedge clk or posedge rst) begin
if (rst) begin
for (integer i = 0; i < 16; i = i + 1)
reg_file[i] <= 0;
end else begin
case (opcode)
4'b0000: reg_file[reg_dst] <= alu_out; // ALU operation
4'b0001: reg_file[reg_dst] <= immediate; // LOAD
default: reg_file[reg_dst] <= reg_file[reg_dst];
endcase
result <= reg_file[reg_dst];
end
end
endmodule
Model Graph:
Expected Output:
Result:
Aim: To design a 4-bit binary to Gray code converter using Verilog HDL.
Apparatus Required:
Theory:
A Gray code is a binary numeral system where adjacent values differ by only one bit, useful in
error detection and rotary encoders. A 4-bit binary to Gray code converter transforms a binary
input to its Gray code equivalent using the formula: G[i] = B[i] XOR B[i+1] for i < 3, and G[3] =
B[3]. Behavioral modeling uses combinational logic to describe this transformation.
module binary_to_gray (
input [3:0] binary,
output [3:0] gray
);
assign gray[3] = binary[3];
assign gray[2] = binary[3] ^ binary[2];
assign gray[1] = binary[2] ^ binary[1];
assign gray[0] = binary[1] ^ binary[0];
endmodule
Expected Output:
Result:
Apparatus Required:
Theory:
A priority encoder outputs the index of the highest-priority active input, with higher-indexed
inputs having higher priority. For a 4-bit priority encoder, if input[3] is 1, the output is 11,
regardless of other inputs. Behavioral modeling uses conditional statements to describe the
priority logic, simplifying the design.
module priority_encoder (
input [3:0] input_data,
output reg [1:0] encoded_output,
output reg valid
);
always @(*) begin
valid = 1;
if (input_data[3])
encoded_output = 2'b11;
else if (input_data[2])
encoded_output = 2'b10;
else if (input_data[1])
encoded_output = 2'b01;
else if (input_data[0])
encoded_output = 2'b00;
else begin
encoded_output = 2'b00;
valid = 0;
end
end
endmodule
Model Graph:
Expected Output:
Result:
Basic Experiments
1. Design of Basic Logic Gates using Verilog HDL (Gate-Level Modeling)
○ Use Case: Building blocks for digital circuits, enabling logic operations like
AND, OR, NOT for data processing and control in ICs.
○ Real-Time Application: Used in industrial automation PLCs for real-time
decision-making, processing sensor inputs to control robotic arms with minimal
delay.
2. Design of a 2-to-1 Multiplexer using Verilog HDL (Behavioral Modeling)
○ Use Case: Selects one of multiple input signals for output, used in data routing
and signal switching.
○ Real-Time Application: Employed in 5G network routers for real-time data
stream selection, ensuring seamless switching between user data channels.
3. Design of a D Flip-Flop using Verilog HDL (Behavioral Modeling)
○ Use Case: Stores single-bit data for synchronization in sequential circuits, used in
registers and counters.
○ Real-Time Application: Synchronizes data in real-time Ethernet controllers,
ensuring accurate packet timing in high-speed networking equipment.
4. Realization of Combinational Logic Circuit using Verilog HDL (Behavioral
Modeling)
○ Use Case: Implements logic functions without memory, used in decoders,
encoders, and arithmetic units.
○ Real-Time Application: Processes radar signals in real-time for air traffic control
systems, decoding target data for immediate display.
5. Realization of Sequential Logic Circuit using Verilog HDL (Behavioral Modeling)
○ Use Case: Manages state-dependent operations in counters, state machines, and
registers.
○ Real-Time Application: Controls fuel injection timing in automotive ECUs,
ensuring precise sequential operations based on engine sensor data.
6. Design and Implementation of Ripple Carry Adder (Structural Modeling)
19.Design and Analysis of 4-input Dynamic NAND Gate using HSPICE (Switch-Level
Modeling)
○ Use Case: Provides high-speed, low-power logic for memory and processor
circuits.
○ Real-Time Application: Decodes memory addresses in SSD controllers for
real-time data access, minimizing latency in storage operations.
20.Design of Sequential Circuit using FSM and ASM Charts (Behavioral Modeling)
○ Use Case: Manages state transitions in control systems and communication
protocols.
○ Real-Time Application: Controls real-time data flow in SPI interfaces for
industrial sensors, ensuring accurate state-based communication.
Challenging Experiments