0% found this document useful (0 votes)
24 views92 pages

21EC71-MQP-SOLUTIONS

Uploaded by

Vaishnavi B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views92 pages

21EC71-MQP-SOLUTIONS

Uploaded by

Vaishnavi B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 92

AVLSI

MODULE 1
1. Differenciate between Full Custom, Semi-Custom and Programmable
ASICs. Explain their applications.

ud
Full Custom Semi-Custom Programmable ASIC
Feature
ASIC ASIC (FPGA/Structured)

Fully customized, Some predefined


Design Fully programmable
no predefined blocks, partial
Flexibility post-manufacturing
blocks customization

Very high, requires


Design Moderate, quicker Low to moderate,
extensive design
Complexity lo design cycle easier to modify
effort

Long due to Faster than full


Time-to- Very fast, can be done
extensive design custom, but still
Market after manufacturing
and validation significant

Very high due to Relatively low,


Moderate, lower
uC
Cost design and especially for
than full custom
manufacturing prototypes

Maximum Balanced
Performance Lower than custom, but
optimization for optimization, less
Optimization can be tuned
power, speed, area than full custom

Low, once Moderate, can


High, design can be
Flexibility designed, cannot adapt to some
altered anytime
Vt

be changed changes

i. Full Custom ASICs (Application-Specific Integrated Circuits)


Applications:
• High-performance systems: Used in applications where the utmost
optimization for performance, power consumption, and area (PPA) is
required, such as in supercomputers, high-frequency trading systems,
and communication equipment.
• Consumer electronics: Found in devices like smartphones, tablets, and
gaming consoles (e.g., custom chips designed for gaming performance).
• Automotive systems: Used in self-driving cars or advanced driver-
assistance systems (ADAS) for real-time processing of sensor data.
• Military and aerospace: In areas where reliability, speed, and low power
consumption are critical.

ud
ii. Semi-Custom ASICs
Applications:
• Consumer electronics: Used in products like set-top boxes, smart TVs,
and home appliances where specialized functionality is needed but
complete customization would be too costly and time-consuming.
• Networking: Found in networking equipment like routers and switches,
where certain functions are common but other parts need optimization for


lo
specific tasks (e.g., high-speed packet switching).
Automotive: Used in vehicles for functions like infotainment systems or
sensor management, where components can be shared across different
models but with some custom tuning for specific needs.
• Low to mid-range consumer electronics: Devices that need more
customization but not at the full expense of a full custom design, such as
uC
personal audio systems and wearables.
iii. Programmable ASICs (FPGAs or Structured ASICs)
Applications:
• Prototyping and Development: FPGAs are widely used for prototyping
new designs before committing to a full custom ASIC design, as they
offer flexibility and reconfigurability.
Vt

• Telecommunications: Used in base stations and other communication


infrastructure where algorithms or protocols may need to be updated
frequently.
• Data Centers: Programmable ASICs are used in data acceleration tasks,
including AI and machine learning workloads, where specific algorithms
can benefit from customized hardware implementations.
• Aerospace and Defense: In mission-critical applications where the
hardware may need to be updated or reprogrammed to meet changing
needs during a system's lifecycle.
• Industrial Automation: Used in systems that require highly adaptable
control systems, such as robotic systems or factory automation.

ud
2. Explain Standard-Cell Based and Gate-Array Based ASICs
i. Standard-Cell Based ASICs

lo
• A cell-based ASIC (cell-based IC, or CBIC pronounced sea-bick) uses
predesigned logic cells (AND gates, OR gates, multiplexers, and flip-flops, for
example) known as standard cells.
• One can apply the term CBIC to any IC that uses cells, but it is generally
uC
accepted that a cellbased ASIC or CBIC means a standard-cell based ASIC.
• The standard-cell areas (also called flexible blocks) in a CBIC are built of
rows of standard cells like a wall built of bricks. The standard-cell areas may be
used in combination with microcontrollers or even microprocessors, known as
mega cells. Mega cells are also called mega functions, full-custom blocks,
system-level macros (SLMs), fixed blocks, cores, or Functional Standard
Blocks (FSBs).
Vt

• A cell-based ASIC (CBIC) die with a single standard-cell area (a flexible


block) together with four fixed blocks.
• The ASIC designer defines only the placement of the standard cells and the
interconnect in a CBIC. However, the standard cells can be placed anywhere on
the silicon; this means that all the mask layers of a CBIC are customized and are
unique to a particular customer.
• The advantage of CBICs is that designers save time, money, and reduce risk
by using a predesigned, pretested, and pre characterized standard-cell library.
• In addition, each standard cell can be optimized individually. During the
design of the cell library each and every transistor in every standard cell can be
chosen to maximize speed or minimize area.
• The disadvantages are the time or expense of designing or buying the
standard-cell library and the time needed to fabricate all layers of the ASIC for
each new design.

ud
ii. Gate-Array Based ASICs
• In a gate array (sometimes abbreviated GA) or gate-array based ASIC the
transistors are predefined on the silicon wafer.
• The predefined pattern of transistors on a gate array is the base array, and the
smallest element that is replicated to make the base array is the base cell
(sometimes called a primitive cell ).
lo
• Only the top few layers of metal, which define the interconnect between
transistors, are defined by the designer using custom masks. To distinguish this
type of gate array from other types of gate array, it is often called a masked gate
array (MGA).
• The designer chooses from a gate-array library of predesigned and pre-
characterized logic cells.
uC
• The logic cells in a gate-array library are often called macros. The reason for
this is that the base-cell layout is the same for each logic cell, and only the
interconnect (inside cells and between cells) is customized, which is similar to a
software macro.
• Types of MGA or Gate-array based ASICs
There are three types of Gate Array based ASICs.
Vt

➢ Channeled gate arrays.


➢ Channelless gate arrays.
➢ Structured gate arrays.

a. Channeled gate arrays


• The channeled gate array was the first to be developed. In a channeled gate
array space is left between the rows of transistors for wiring.
ud
• A channeled gate array is similar to a CBIC. Both use the rows of cells
separated by channels used for interconnect. One difference is that the space for
interconnect between rows of cells are fixed in height in a channeled gate array,
whereas the space between rows of cells may be adjusted in a CBIC.
b. Channel less Gate

lo
uC
• This channel less gate-array architecture is now more widely used. The routing
on a channelless gate array uses rows of unused transistors.
• The key difference between a channel less gate array and channeled gate array
is that there are no predefined areas set aside for routing between cells on a
channel less gate array. Instead, we route over the top of the gate-array devices.
We can do this because we customize the contact layer that defines the
connections between metal 1, the first layer of metal, and the transistors.
• The basic difference between a channel less gate array and channeled gate
Vt

array is that there are no predefined areas set aside for routing between cells on
a channel less gate array. Instead, we route over the top of the gate-array
devices.
• It is done like this because we customize the contact layer that defines the
connections between metal1, the first layer of metal, and the transistors. When
we use an area of transistors for routing in a channel less array, we do not make
any contacts to the devices lying underneath; we simply leave the transistors
unused.
c.Structured Gate Array

ud
• This design combines some of the features of CBICs and MGAs. It is also
known as an embedded gate array or structured gate array (also called as master
slice or master image).
• One of the limitations of the MGA is the fixed gate-array base cell. This makes
the implementation of memory, difficult and inefficient.
• In an embedded gate array some of the IC area is set aside and dedicate it to a
lo
specific function. This embedded area either can contain a different base cell
that is more suitable for building memory cells, or it can contain a complete
circuit block, such as a microcontroller.

3. Explain the Design Flow of ASIC.


uC
Vt
The sequence of steps to design an ASIC is known as the Design flow . The
various steps involved in ASIC design flow are given below.
1. Design entry: Design entry is a stage where the micro architecture is
implemented in a Hardware Description language like VHDL, Verilog, System
Verilog etc. In early days, a schematic editor was used for design entry where
designers instantiated gates. Increased complexity in the current designs require
the use of HDLs to gain productivity Another advantage is that HDLs are

ud
independent of process technology and hence can be re-used over time.
2. Logic synthesis: Use an HDL (VHDL or Verilog) and a logic synthesis tool
to produce a net list a description of the logic cells and their connections.
3. System partitioning: Divide a large system into ASIC-sized pieces.
4. Pre-layout simulation: Check to see if the design functions correctly.
5. Floor planning: Arrange the blocks of the netlist on the chip.
lo
6. Placement: Decide the locations of cells in a block.
7. Routing: Make the connections between cells and blocks.
Steps 1–4 are part of logical design, and steps 5–9 are part of physical design.
There is some overlap. For example, system partitioning might be considered as
either logical or physical design. To put it another way, when we are performing
system partitioning, we have to consider both logical and physical factors.
uC
4. Discuss the importance of Data Path Logic Cells in CMOS design.
Importance of Data Path Logic Cells in CMOS Design
1. High-Speed Performance:
o Optimized for fast data processing (e.g., adders, multipliers).
Vt

o Enable pipelining to increase throughput and reduce delay in


complex tasks.
2. Power Efficiency:
o CMOS technology allows low power consumption during
operation.
o Essential for battery-powered devices (e.g., mobile devices, IoT)
by reducing dynamic and static power.
3. Area Efficiency:
o Compact design, allowing for high integration of logic operations
in limited space.
o Critical for ASICs and FPGAs, maximizing the functionality of a
small chip area.
4. Scalability and Flexibility:

ud
o CMOS designs can scale from low-power to high-performance
systems.
o Customization of logic cells allows optimization for specific tasks,
such as arithmetic operations.
5. Reduced Noise and Improved Signal Integrity:
o High noise immunity ensures stable operation in
electromagnetically noisy environments.
lo
o Low switching noise ensures reliable signal transmission in high-
speed circuits.
6. Cost-Effectiveness:
o CMOS is cost-effective for high-volume manufacturing.
uC
o Integrated logic cells reduce the need for additional components,
lowering fabrication costs.

5. Define Data Path and explain any 8 Data Path elements with neat
diagram.
A Data Path in digital design refers to the collection of functional units,
registers, buses, and logic elements through which data flows and gets
Vt

processed within a system, such as a processor or an ASIC. The Data Path is


responsible for performing the computational operations (like arithmetic, logic,
shifting, etc.), and storing intermediate results that are used by the control unit.
The following are the common data path elements, which work together to
perform arithmetic and logical operations, store data, and transfer results:
1. Registers:
• Function: Registers store data temporarily during computation. They are
the smallest storage elements in a CPU.
• Example: General-purpose registers like R0, R1, R2 in a microprocessor.
• Usage: Hold intermediate values, instructions, or data for quick access
during processing.
2. Multiplexer (MUX):
• Function: A MUX selects one of several input signals based on a control
signal. It allows multiple data sources to be routed to a single output.

ud
• Example: A 2:1 multiplexer selects between two inputs based on a
single control signal.
• Usage: Selects data inputs based on conditions in control logic (e.g.,
selecting between operands for an ALU).
3. Arithmetic Logic Unit (ALU):
• Function: The ALU performs arithmetic (addition, subtraction, etc.) and
logical (AND, OR, NOT, etc.) operations.
lo
• Example: Performs calculations in operations like A + B, A - B, or
logical operations like A AND B.
• Usage: The heart of computation, used to execute operations on data from
registers or memory.
4. Shifter:
uC
• Function: A Shifter shifts the bits of a data word left or right by a
specified number of positions.
• Example: A left shift operation on a number moves all its bits to the left,
effectively multiplying by 2.
• Usage: Used for operations like multiplying/dividing by powers of 2, or
bitwise operations in data encoding/decoding.
Vt

5. Bus:
• Function: A Bus is a collection of wires used to transmit data between
different components in a system, like registers, ALUs, and memory.
• Example: A data bus might carry a 32-bit value between a register and
the ALU.
• Usage: Carries data between different data path elements (e.g., between
registers and the ALU).
6. Control Unit (CU):
• Function: The Control Unit generates control signals to direct the
operation of the data path elements. It tells components like the ALU,
multiplexers, and registers what to do.
• Example: Generates signals to control whether the ALU adds or
subtracts, or whether a register should load or store data.

ud
• Usage: Coordinates the operations of all elements in the data path based
on the current instruction.
7. Program Counter (PC):
• Function: The PC holds the address of the next instruction to be
executed in a program.
• Example: After each instruction, the PC increments to point to the next
instruction in sequence.

lo
Usage: Tracks the execution flow by determining the next instruction's
address during instruction fetching.
8. Memory (Data Memory and Instruction Memory):
• Function: Memory stores instructions and data that are used by the
processor. It can be divided into instruction memory (for program code)
uC
and data memory (for data storage).
• Example: RAM for storing variables and ROM for storing code.
• Usage: Memory elements store and retrieve data or instructions based on
addresses generated by the Program Counter or other control
mechanisms.
Vt
6. Working of Carry-skip, Carry-select, Carry-save and Carry-bypass
adders.
Carry Skip / Bypass adders:
The problem with an RCA is that every stage has to wait to make its carry
decision, C[ i ], until the previous stage has calculated C[ i – 1]. If we examine
the propagate signals we can bypass this critical path. Thus, for example, to
bypass the carries for bits 4–7 (stages 5–8) of an adder we can compute

ud
BYPASS = P[4].P[5].P[6].P[7] and then use a MUX as follows:

C[7] = (G[7] + P[7] · C[6]) · BYPASS' + C[3] · BYPASS

Adders based on this principle are called carry-bypass adders (CBA). Large,
custom adders employ Manchester-carry chains to compute the carries and the
bypass operation using TGs or just pass transistors. These types of carry chains
may be part of a predesigned ASIC adder cell, but are not used by ASIC
designers. lo
Instead of checking the propagate signals we can check the inputs. For example
we can compute
SKIP = (A[ i – 1] ⊕ B[ i – 1]) + (A[ i] ⊕ B[ i ] )and then use a 2:1 MUX to select C[ i ].
Thus, CSKIP[ i ] = (G[ i ] + P[ i ] · C[ i – 1]) · SKIP' + C[ i – 2] · SKIP
This is a carry-skip adder. Carry-bypass and carry-skip adders may include
uC
redundant logic (since the carry is computed in two different ways—we just
take the first signal to arrive). We must be careful that the redundant logic is not
optimized away during logic synthesis.

Carry Select adder:


In Carry-select adder duplicates two small adders(4 bit or 8 bit ) for the cases
CIN='0' and CIN='1' and then uses a MUX to select the case that we add MUX
Vt

to select these.Using Mux makes it faster. A carry select adder is used as faster
adder in a datapath because its layout is regular.
Carry select,carry -bypass and carry skip architecture are used to split 12-bit
adder.Spilt into 3 blocks.The delay of the adder partly depends on the delays of
the MUX between each block.Suppose the delay of the 1st adder is equal to the
MUX of the delay,in this case to make 3,4,5 blocks of the adder can be made
faster instead of making equal delays.
Delays in to the final MUX are equal-3bit delays plus 2MUX delays for the
carry from bits from0-6 and 5 bit delays for the carry from bits 7-11.
Adjusting the block size reduces the delay of large adders (more than 16
bits).Carry select adders can extended to an n-bit adder that generates the two
sums.

ud
lo
uC
FIGURE (2) The conditional-sum adder. (a) A 1-bit conditional adder that calculates the sum and
carry out assuming the carry in is either '1' or '0'. (b) The multiplexer that selects between sums
andcarries. (c) A 4-bit conditional-sum adder with carry input, C[0].

Carry Save adder:


A carry-save adder (CSA) cell CSA(A1[ i ], A2[ i ], A3[ i ], CIN, S1[ i ], S2[ i ],
COUT) has three outputs:
Vt

S1[ i ] = CIN
S2[ i ] = A1[ i ] ⊕ A2[ i ] ⊕A3[ i ] = PARITY(A1[ i ], A2[ i ], A3[ i ])
COUT = A1[ i ] · A2[ i ] + [(A1[ i ] + A2[ i ]) · A3[ i ]] = MAJ(A1[ i ], A2[ i ], A3[ i ])

The inputs, A1, A2, and A3; and outputs, S1 and S2, are buses. The input, CIN,
is the carry from stage (i-1). The carry in, CIN, is connected directly to the
output bus S1 indicated by the schematic symbol (Figure 2a). We connect
CIN[0] to VSS. The output, COUT, is the carry out to stage (i + 1).
A 4-bit CSA is shown in Figure 3(b). The arithmetic overflow signal for ones
complement or twos complement arithmetic, OV, is XOR(COUT[MSB],
COUT[MS1]) as shown in Figure 3(c). In a CSA the carries are saved at each
stage and shifted left onto the bus S1. There is no carry propagation and the
delay of a CSA is constant. At the output of a CSA we still need to add the S1
bus (all the saved carries) and the S2 bus (all the sums) to get an n -bit result
using a final stage that is not shown in Figure 3(c). We might regard the n -bit
sum as being encoded in the two buses, S1 and S2, in the form of the parity and

ud
majority functions.
We can use a CSA to add multiple inputs as an example, an adder with four 4-
bit input is shown in Figure 3(d). The last stage sums two input buses using a
carry-propagate adder (CPA). We have used an RCA as the CPA in Figure
3(d) and (e), but we can use any type of adder. Notice in Figure 3(e) how the
two CSA cells and the RCA cell abut together horizontally to form a bit slice (or
slice) and then the slices are stacked vertically to form the datapath.
lo
uC

Fig (3) The carry-save adder (CSA). (a) A CSA cell. (b) A 4-bit CSA. (c) Symbol for a CSA. (d) A
fourinput CSA. (e) The datapath for a four-input, 4-bit adder using CSAs with a ripple-carry adder
(RCA) as the final stage. (f) pipelined adder. (g) The datapath for the pipelined version showing the
Vt

pipeline registers as well as the clock control lines that use m2.

We can register the CSA stages by adding vectors of flip-flops as shown in


Figure 2.23(f). This reduces the adder delay to that of the slowest adder stage,
usually the CPA. By using registers between stages of combinational logic we
use pipelining to increase the speed and pay a price of increased area (for the
registers) and introduce latency.
7. Explain Booth Multiplier encoding considering unsigned number as
example.
Booth's Multiplication Algorithm:
Booth's algorithm is a binary multiplication technique that efficiently handles
both positive and negative integers. It reduces the number of operations needed
for multiplication compared to conventional methods. The key idea is to encode
the multiplier in a form that allows for efficient shifting and addition.

ud
Booth's Multiplication Algorithm (Steps):
1. Start with Initialization:
o Register A= 0 (all bits set to zero).
o Register Q holds the multiplier.
o Register Q−1 is initialized to 0.

o
lo
2. Check the pair of bits Q0 and Q−1 apply the corresponding operation:
If Q0Q−1 =00, perform no addition or subtraction, just shift.
If Q0Q−1 =01, subtract the multiplicand from A.
o If Q0Q−1=10, add the multiplicand to A.
o If Q0Q−1=11, perform no addition or subtraction, just shift.
uC
3. Shift left the combination of A, Q, and Q−1. The shift is performed as
follows:
o Combine A, Q, and Q−1 into a 2N-bit value (since we’re
multiplying two N-bit numbers).
o Shift left by one bit (from left to right), where the sign bit of A is
propagated, Q0 becomes Q1, and the old Q−1 moves to the leftmost
bit.
Vt

4. Repeat the process for N cycles (where N is the bit length of the
numbers). After N cycles, you’ll have the product in registers A and
Q.

Example of Booth's Algorithm for Unsigned Numbers:


Let’s illustrate this with an example using 4-bit unsigned numbers.
• Multiplicand M=3 (binary 0011)
• Multiplier Q=6 (binary 0110)
• A=0000 (initially set to zero)
• Q−1=0 (initially set to zero)

Cycle 1:
Q0Q−1=00, so we do nothing (no addition/subtraction).

ud

• Perform a left shift of the concatenated value A, Q, Q−1.


o New value of A, Q, Q−1=0000, 0110, 0→0001, 1100,0.
Cycle 2:
• Q0Q−1=00, so we do nothing again.
• Perform a left shift.

Cycle 3:

o
lo
New value of A, Q, Q−1=0001,1100,0→0011, 1000, 0.

Q0Q−1=00, so we do nothing once more.


• Perform a left shift.
uC
o New value of A, Q, Q−1=0011, 1000, 0→0111, 0000, 0.
Cycle 4:
• Q0Q−1=00, so we do nothing again.
• Perform a left shift.
o New value of A, Q, Q−1=0111, 0000, 0→1110, 0000, 0.
Vt

Final Product:
• After 4 cycles, the value in registers A and Q together would give the
result of 1818 in binary (110010).
This method saves computational steps by checking pairs of bits in the
multiplier instead of using traditional repetitive addition methods.
8. Explain I/O cells with neat diagram (or) Explain I/O cells with example.
I/O Cells Explanation
In digital design, I/O cells (Input/Output cells) are essential components that
facilitate communication between a digital circuit and the external world. These
cells are used for connecting the internal logic of a chip to the outside world,
enabling data to be input into the chip or output from the chip.

ud
I/O cells are designed to handle various types of electrical characteristics, such
as voltage levels, noise tolerance, and signal integrity, ensuring proper
communication between the chip and external devices. They often include
buffers, drivers, and sometimes protection circuits to manage these connections
efficiently.

lo
uC
FIGURE 2.32 A three-state bidirectional output buffer. When the output enable, OE, is '1' the
output section is enabled and drives the I/O pad. When OE is '0' the output buffer is placed in
a high-impedance state.

Basic Functions of I/O Cells


1. Input Functionality:
Vt

o When a signal is provided from an external source to the chip, the


I/O cell's input section captures the signal and passes it to the
internal logic.
o The input section typically includes a buffer to provide proper
voltage levels to match the internal circuit's requirements.
2. Output Functionality:
o When data needs to be sent from the chip to external components,
the I/O cell's output section drives the signal out of the chip.
o The output section includes drivers that provide the necessary
current to drive the external load (e.g., another chip, peripheral, or
device).
3. Bidirectional I/O (Tri-State):
o In some cases, I/O cells can be bidirectional (both input and
output), which is useful in communication protocols or data buses.
The bidirectional pins are often tri-stated when not in use,

ud
ensuring they do not interfere with other signals.
I/O Cell Example:
1. Input Example:
Consider a scenario where a signal from an external sensor is being input into a
microcontroller. The I/O cell at the microcontroller input will have the
following functionality:


lo
The external sensor’s voltage (which may range from 0V to 5V) is fed
into the I/O cell.
The input buffer inside the I/O cell processes this voltage and ensures
that it is within a safe range (e.g., 0V to 3.3V for a 3.3V system).
• The signal is then passed to the internal microcontroller circuit for further
processing.
uC
2. Output Example:
Now, consider that the microcontroller needs to send a signal to an LED.
• The microcontroller generates a logic signal (e.g., HIGH or LOW) on the
output pin.
• The I/O cell’s output driver amplifies the signal, ensuring it is strong
enough to drive the LED.
Vt

• The driver ensures that the correct voltage and current levels are applied
to the LED, causing it to light up.
3. Bidirectional Example:
In a communication system, a data bus might use a bidirectional I/O pin. The
I/O cell at this pin will:
• Input Data when the system is receiving data from another device.
• Output Data when the system is transmitting data to another device.
• The I/O cell will ensure that the data is correctly transmitted or received,
using a tri-state driver to avoid interference when the pin is not in use.

MODULE 2
1. Goals and Objectives of Floor Planning.
Goals of Floor Planning:

ud
1. Arrange the blocks on the chip: Place different functional parts of the chip
in an efficient way to reduce wiring and improve performance.
2. Decide the location of the I/O pads: Place input/output pads at strategic
locations for easy communication with external devices.
3. Decide the location and number of power pads: Ensure proper placement
of power pads to evenly distribute power across the chip.
lo
4. Decide the type of power distribution: Design an efficient power grid to
supply consistent voltage and minimize losses across the chip.
5. Decide the location and type of clock distribution: Plan how the clock
signal is distributed to all parts of the chip, ensuring synchronization and
reducing delay.
uC
Objectives of Floor Planning:
1. Minimize chip area: Reduce the chip's physical size to cut costs and increase
chip yield from the wafer.
2. Minimize delay: Reduce the time it takes for signals to travel across the chip,
improving performance.
3. Area vs. delay: Balance the trade-off between reducing the chip's area and
Vt

minimizing delays for optimal design.

2. Explain the Measurement of Delay in Floorplanning.


In the ASIC design process we need to predict the performance of the final
layout. In floorplanning we wish to predict the interconnect delay before we
complete any routing.
To predict delay we need to know the parasitics associated with interconnect:
the interconnect capacitance (wiring capacitance or routing capacitance) as well
as the interconnect resistance. At the Floor planning stage, we know only the
fanout (FO) of a net (the number of gates driven by a net) and the size of the
block that the net belongs to. We cannot predict the resistance of the various
pieces of the interconnect path since we do not yet know the shape of the
interconnect for a net.However, we can estimate the total length of the
interconnect and thus estimate the total capacitance. We estimate interconnect

ud
length by collecting statistics from previously routed chips and analyzing the
results. From these statistics we create tables that predict the interconnect
capacitance as a function of net fanout and block size. A Floor planning tool can
then use these predicted-capacitance tables (also known as interconnect-load
tables or wire-load tables).

lo
Figure shows that both interconnect delay and gate delay decrease as we scale down feature
sizes but at different rates. This is because interconnect capacitance tends to a limit of about 2
pFcm1for a minimum-width wire while gate delay continues to decrease.
uC
Vt

(a) Interconnect lengths as a function of fanout (FO) and circuit-block size. (b) Wire-load
table. There is only one capacitance value for each fanout (typically the average value).
(c) The wire-load table predicts the capacitance and delay of a net. Net A and net B both have
a fanout of 1, both have the same predicted net delay, but net B in fact has a much greater
delay than net A in the actual layout.
• Typically between 60 and 70 percent of nets have a FO = 1.
• The distribution for a FO = 1 has a very long tail, stretching to
interconnects that run from corner to corner of the chip.
• The distribution for a FO = 1 often has two peaks, corresponding to a
distribution for close neighbors in subgroups within a block,
superimposed on a distribution corresponding to routing between
subgroups.
• A twin-peaked distribution at the chip level also, corresponding to

ud
separate distributions for interblock routing (inside blocks) and intrablock
routing (between blocks).
• The distributions for FO > 1 are more symmetrical and flatter than for
FO=1
• The wire-load tables can only contain one number, for example the
average net capacitance, for any one distribution. Many tools take a
worst-case approach and use the 80- or 90-percentile point instead of the
average. Thus a tool may use a predicted capacitance for which we know
lo
90 percent of the nets will have less than the estimated capacitance.
• We need to repeat the statistical analysis for blocks with different sizes.
For example, a net with a FO = 1 in a 25 k-gate block will have a
different (larger) average length than if the net were in a 5 k-gate block.
• The statistics depend on the shape (aspect ratio) of the block (usually the
statistics are only calculated for square blocks).
uC
• The statistics will also depend on the type of netlist. For example, the
distributions will be different for a netlist generated by setting a
constraint for minimum logic delay during synthesis which tends to
generate large numbers of two-input NAND gates than for netlists
generated using minimum-area constraints.
Vt
4. Explain Channel Definition process in Floor planning and its
importance.

Channel Definition Process in Floor Planning:


The channel definition process in floor planning refers to determining the
regions between the placed blocks where interconnects (wires) will be
routed. These channels are essential spaces for routing the electrical

ud
connections between various functional blocks on the chip.

lo
Figure shows a floorplan of a chip containing several blocks. Suppose we cut along the
block boundaries slicing the chip into two pieces a). Then suppose we can slice each of
these pieces into two. If we can continue in this fashion until all the blocks are separated,
then we have a slicing floorplan b). Figure (c) shows how the sequence we use to slice the
uC
chip defines a hierarchy of the blocks. Reversing the slicing order ensures that we route
the stems of all the channel T-junctions first.

(INCLUDE OTHER NECESSARY DIAGRAMS)


The channel definition involves:
1. Determining Space for Routing:
o After placing the functional blocks on the chip, the remaining area
between them is defined as the "channel" where wires can be
Vt

routed.
o Channels must be wide enough to accommodate all the necessary
interconnections, including signal, power, and ground lines.
2. Adjusting Channel Size:
o The width of the channels can be adjusted during floor planning to
ensure there is enough room for the required interconnects without
causing congestion or excessive delays.
o The channel size is often influenced by factors such as block size,
routing requirements, and technology limitations.
3. Identifying Routing Layers:
o Channels are typically used for routing on multiple layers of metal
(in modern IC designs), with different layers dedicated to
horizontal or vertical routing.

ud
o This process defines how signals will flow between blocks in each
layer and ensures that layers are not overly congested.
Importance of Channel Definition:
1. Efficient Routing:
o Proper channel definition ensures that interconnects can be routed
with minimal delay and congestion, leading to better signal
integrity and performance.

o
lo
2. Minimizing Chip Area:
Optimizing the size and arrangement of channels helps minimize
the chip's overall area, making the design more compact and cost-
effective.
3. Avoiding Signal Interference:
uC
o Well-defined channels prevent overlapping or tangled wires,
reducing the risk of signal interference and ensuring reliable data
transmission between blocks.
4. Facilitating Power and Ground Routing:
o Channels are also essential for power and ground routing, which
ensures that the chip receives stable power supply and grounding
connections throughout.
Vt

4. Discuss the steps involved in power planning during floor planning.


Steps Involved in Power Planning During Floor Planning:
Power planning is a crucial step during floor planning in VLSI design, as it
ensures the chip receives a stable and sufficient power supply while minimizing
power loss and ensuring reliable operation. Here are the key steps involved in
power planning:
1. Determine Power Requirements:
• Estimate the total power consumption of the chip based on the
functionality and expected activity of each block (logic, memory, etc.).
• Identify power hotspots—areas that will consume the most power, such

ud
as high-performance modules or blocks with intensive logic operations.
2. Decide the Number and Location of Power Pads:
• Power pads are the points on the chip where external power (VDD) and
ground (GND) are supplied.
• The number and location of power pads should be optimized to ensure an
even distribution of power across the chip, minimizing the voltage drop
and IR losses.
lo
• Place power pads near critical blocks to ensure short, efficient power
delivery paths.
3. Design the Power Distribution Network (PDN):
• Plan the power grid that connects all the power pads to the blocks on the
chip.
uC
• The power grid design should include horizontal and vertical metal
layers to distribute power evenly. Proper sizing of metal layers is
necessary to handle the current requirements and reduce resistance.
• Use decap cells (decoupling capacitors) strategically placed across the
chip to stabilize the power supply and smooth out voltage fluctuations.
4. Ensure Voltage Integrity:
Vt

• Voltage drop (IR drop) must be kept to a minimum to ensure each block
receives the required voltage for proper operation.
• Analyze the current density and power dissipation to identify regions
where voltage drop might occur and design the power grid accordingly.
• Use power rings or grids to provide a uniform voltage across the chip
and reduce the effect of power congestion.
5. Plan for Clock Power Distribution:
• The clock network is also an important part of power planning, as the
clock distribution consumes significant power.
• Design the clock distribution network to minimize power loss while
ensuring low skew and delay.
• Proper power routing for the clock network ensures that all blocks receive
the clock signal with minimal delay, while also reducing the overall
power consumption.

ud
6. Power-Aware Routing:
• Ensure that routing for both signal lines and power lines is done
efficiently, minimizing the power consumed by long signal paths or
unnecessary interconnects.
• Minimize wire resistance for power and ground paths by using wider
metal layers or lower-resistance materials in critical regions.


lo
7. Optimize for Power and Area:
Ensure that the power distribution network does not unnecessarily
increase the chip area. Optimize the size and placement of power pads,
decoupling capacitors, and routing to balance power delivery and chip
area.
Avoid excessive use of power-hungry features such as high-speed clocks
uC

or unoptimized logic circuits in certain areas.
8. Consider Low Power Design Techniques (Optional):
• Low-power techniques, such as power gating, clock gating, and
dynamic voltage scaling (DVS), can be considered to reduce power
consumption further, especially in idle or low-activity states.
• Implement these techniques during power planning to reduce overall
Vt

energy consumption and extend the battery life of portable devices.

5. Explain the following in ASIC floor plan in brief: i) Power planning


ii) Clock Planning.
i) Power Planning in ASIC Floor Plan:
Power planning in ASIC (Application-Specific Integrated Circuit) floor
planning is essential for ensuring the chip receives sufficient, stable, and
efficient power while minimizing power loss and optimizing performance.
1. Power Pad Placement:
o Strategically place power pads (VDD and GND) around the chip to
provide power to all blocks. The placement should minimize power
distribution paths and voltage drops.
2. Power Distribution Network (PDN):
o Design an effective power grid that connects power pads to

ud
functional blocks. This grid should use multiple metal layers to
distribute power evenly and ensure minimal voltage drop (IR drop)
and resistance.
3. Decoupling Capacitors:
o Place decap cells (capacitors) near power-sensitive blocks to filter
out noise and stabilize the power supply, improving overall voltage
integrity.

o
lo
4. Power Grid Design:
Plan the grid to balance current flow and reduce hotspots. Ensure
the metal layers are sufficiently wide to handle the required current
and minimize resistance.
5. Minimize Power Losses:
uC
o Ensure that the power distribution network does not lead to
unnecessary power losses by optimizing the routing of power and
ground lines.
Importance of Power Planning:
• Reliability: Ensures each block receives stable power, preventing voltage
fluctuations or power shortages.
• Efficiency: Reduces power consumption, helping to meet energy goals
Vt

and extend battery life in portable devices.


• Cost-Effective: Minimizes unnecessary use of power-hungry components,
optimizing chip performance while controlling manufacturing costs.

ii) Clock Planning in ASIC Floor Plan:


Clock planning in ASIC design involves organizing the distribution of the clock
signal to all parts of the chip in a way that minimizes clock skew, reduces delay,
and ensures all components are synchronized.
1. Clock Distribution Network:
o Design an effective clock network that delivers the clock signal to
all sequential elements (e.g., flip-flops, registers) while maintaining
synchronization.
2. Minimizing Clock Skew:

ud
o Ensure that the clock signal reaches all parts of the chip at the same
time to avoid clock skew, which can cause timing errors. This is
achieved by carefully routing the clock signal using balanced paths
and buffers.
3. Clock Tree Synthesis (CTS):
o Clock tree synthesis involves creating a hierarchical structure for
the clock signal's distribution. A well-designed clock tree

o
lo
minimizes delays and ensures even distribution.
4. Clock Power Management:
Optimize the clock signal's power consumption by reducing
unnecessary clock routing and using clock gating techniques to
turn off the clock in inactive regions, thus saving power.
uC
5. Clock Pin Assignment:
o Properly assign clock pins to different blocks so the clock
distribution can be routed effectively without excessive wiring or
congestion.
Importance of Clock Planning:
• Synchronization: Ensures that all components operate in sync with the
same clock signal, crucial for timing accuracy.
Vt

• Performance: Reduces delays due to inefficient clock routing, leading to


faster operation of the chip.
• Power Efficiency: Reduces unnecessary clock signal routing and employs
clock gating to save power.
(INCLUDE NECESSARY DIAGRAMS)
6. Goals and Objective of Placement
Goals of Placement:
1. Arrange Logic Cells within Flexible Blocks:
o The main goal of a placement tool is to arrange all the logic cells
within predefined or flexible blocks on the chip. This helps ensure
the design meets area constraints while facilitating efficient

ud
routing.
2. Guarantee the Router Can Complete Routing:
o The placement must allow the routing tool to complete its job by
ensuring enough space and channels for routing signals between
the placed cells. This avoids routing congestion and ensures a
feasible physical design.
3. Minimize Critical Net Delays:
o
lo
Critical nets (signal paths that determine the chip's timing
performance) should be placed to minimize their delay, ensuring
that the timing requirements for the design are met and the chip
operates at the desired speed.
4. Maximize Chip Density:
uC
o The placement should maximize the use of the available chip area.
A denser placement typically means more logic in a smaller area,
improving chip efficiency and reducing manufacturing costs.
5. Minimize Power Dissipation:
o Proper placement can help minimize power consumption by
reducing the length of power and ground connections and
optimizing the placement of high-power consuming blocks.
Vt

6. Minimize Crosstalk Between Signals:


o The placement should minimize crosstalk (unwanted interference
between adjacent signal lines) by appropriately spacing signal
wires and separating noisy nets, improving signal integrity.
Objectives of Placement:
While achieving the goals outlined above is complex, the objectives for
placement are typically more specific and achievable. The most commonly used
placement objectives include:
1. Minimize Total Estimated Interconnect Length:
o Interconnect length refers to the total distance that wires must
travel between the logic cells. Minimizing this length reduces the
power consumption of the interconnects and minimizes signal
delay, leading to faster operation.
2. Meet Timing Requirements for Critical Nets:

ud
o Placement tools aim to ensure that the critical nets (the longest
delay paths) meet the required timing constraints by positioning
the cells in such a way that the delays are minimized, allowing the
design to function within its specified time limits.
3. Minimize Interconnect Congestion:
o Congestion occurs when too many signal connections are placed
too closely, which makes routing difficult. The objective is to
minimize congestion by leaving adequate space for routing and
lo
balancing the density of the placed cells.

7. Explain the following in Placement: i) Min-cut Placement ii) Iterative


placement improvement.
i) Min-Cut Placement in VLSI Design:
uC
Min-Cut Placement is a technique used in VLSI design to optimize the
placement of logic cells by minimizing the cut-set between blocks. The idea is
to reduce the total "cost" associated with the interconnections (or cuts) between
different blocks of logic cells to minimize the wire length and interconnect
delay.
1. Objective:
Vt

o The main goal of min-cut placement is to divide the chip area into
regions (or partitions) such that the total number of
interconnections (or cuts) between these regions is minimized.
This helps to reduce routing congestion and improve the overall
layout efficiency.
2. Process:
o The placement starts by dividing the design into two groups of
cells, such that the number of nets (connections between the cells)
crossing the boundary (cut) between these two groups is
minimized.
o This is typically done by using recursive bisectioning, where the
area is divided repeatedly until an acceptable placement is
achieved.
o Each recursive step involves minimizing the number of
connections (cuts) between two blocks by shifting the cells to

ud
optimize their positions.

lo
uC
Min-cut placement algorithm (a) Divide the chip into bins using a grid. (b)
Merge all connections to the center of each bin. (c) Make a cut and swap logic
cells between bins to minimize the cost of the cut. (d) Take the cut pieces and
throw out all the edges that are not inside the piece. (e) Repeat the process with
a new cut and continue until we reach the individual bins.
3. Advantages:
Vt

o Reduces Wire Length: By minimizing the number of cuts, the


routing of interconnects is more efficient, reducing the total wire
length required for signal paths.
o Improves Performance: Shorter wire lengths help in reducing
signal delay and congestion.
4. Disadvantages:
o Min-cut placement may not always lead to optimal performance, as
it mainly focuses on the number of cuts rather than the actual wire
length or timing constraints.

ii) Iterative Placement Improvement in VLSI Design:


Iterative Placement Improvement is an optimization technique used to refine
the placement of cells through a series of repeated adjustments. The goal is to
improve the initial placement by iteratively making small changes to minimize

ud
certain design metrics like wire length, delay, and congestion.
1. Objective:
o The main aim is to refine the placement by iteratively improving
the positions of cells to achieve better wire length, reduced
congestion, or meeting timing constraints.
2. Process:
o Initially, a first-cut placement is generated using a placement
lo
algorithm (e.g., min-cut or random placement).
uC

(a) Swapping the source logic cell with a destination logic cell in pairwise
interchange. (b) Sometimes we have to swap more than two logic cells at a time
to reach an optimum placement, but this is expensive in computation time.
Vt

Limiting the search to neighborhoods reduces the search time. Logic cells
within a distance e of a logic cell form an e-neighbourhood. (c) A one-
neighbourhood. (d) A two-neighbourhood.

o The iterative process involves repeatedly adjusting the positions


of cells to improve the design. Common methods include:
▪ Cell Shifting: Move cells locally to reduce congestion or
improve timing.
▪ Cell Exchange: Swap the positions of two cells to improve
the overall layout.
▪ Legalization: Ensure that the moved cells remain within the
chip’s area and avoid overlaps.
▪ Global and Local Refinement: Perform global optimization
(involving large-scale changes) and local optimization
(focused on small, specific areas) to achieve a balance

ud
between performance and layout density.
3. Advantages:
o Improves Design Quality: Iterative improvement refines the
placement by focusing on reducing delay, wire length, and
congestion over several iterations.
o Flexibility: It allows for continuous improvements without the
need for a complete redesign.
lo
4. Disadvantages:
o Computationally Expensive: Iterative methods can be time-
consuming, especially for large designs, because many iterations
are needed to reach an optimal solution.
Local Minima: The algorithm might get stuck in a local optimum,
uC
o
not always achieving the global best solution.
(INCLUDE OTHER NECESSARY DIAGRAMS)

8. Goals and Objectives of Routing or Global Routing


Global routing is a key step in the physical design process of VLSI, where the
goal is to plan the overall path of signal interconnections (or nets) between the
Vt

placed cells. This stage provides the necessary guidance and instructions to the
detailed router, which will later perform the actual wire routing on specific
metal layers.
Goals of Routing (Global Routing):
The primary goal of global routing is to provide a comprehensive and feasible
routing plan to the detailed router, allowing it to effectively route all nets on the
chip.
Objectives of Routing (Global Routing):
o Minimize Interconnect Length: Shorter interconnects lead to
reduced delay, power consumption, and chip area.
o Maximize Routing Feasibility: Ensure that the detailed router can
complete routing without congestion or errors.
o Minimize Critical Path Delay: Optimize routing to reduce delays
on the critical path, improving the chip's speed.

ud
In essence, global routing optimizes the overall routing strategy, focusing on
minimizing interconnects, ensuring routing feasibility, and improving
performance by reducing critical path delay.

9. Explain Global Routing Methods with Example.


Two of the most important methods used in global routing are Sequential
Routing and Hierarchical Routing. These methods help in providing routing
lo
solutions that are both efficient and manageable, especially for complex and
large-scale chip designs.

1. Sequential Routing
Sequential routing involves routing the nets one by one in a particular
uC
sequence. Each net is routed independently, and the routing of one net is done in
a specific order based on the chosen strategy. The routing outcome can be
affected by the sequence in which the nets are routed.
Types of Sequential Routing:
• Order Dependent Sequential Routing: The order of routing affects the
final solution. If nets are routed in a particular sequence, it impacts the
routing of subsequent nets. The sequence is often based on the criticality
Vt

of the nets.
o Example: In a design, the most critical net (e.g., a clock signal)
would be routed first to ensure timing requirements are met, and
other nets would be routed based on available routing space after
the critical net.
• Order Independent Sequential Routing: The order of routing does not
impact the final result. Each net is routed independently without
considering the sequence in which they are processed. This approach is
more flexible and parallelizable.
o Example: In a chip design, nets can be routed in any order as long
as they do not interfere with each other, making the routing process
faster and more efficient.
Advantages of Sequential Routing:
• It provides a clear and structured approach to routing, especially when
nets have different priorities (critical vs. non-critical).

ud
• Easier to implement for small designs or designs with few critical nets.
Disadvantages of Sequential Routing:
• It can cause congestion if not managed properly, especially when routing
more complex or dense designs.
• Order-dependent routing can lead to suboptimal results, as later nets may
face routing blockages from earlier nets.
lo
2. Hierarchical Routing
Hierarchical routing breaks down the design into smaller blocks or regions,
and routing is done at different levels of abstraction. This method is especially
useful for large and complex designs, as it reduces the complexity of the routing
process by addressing smaller subproblems in a hierarchical fashion. The
uC
routing is done at the macro level first and refined at lower levels.
Types of Hierarchical Routing:
• Top-Down Hierarchical Routing: The routing starts at the highest level
of abstraction, such as the entire chip or large functional blocks. The main
interconnections between blocks are routed first, and then the routing is
progressively refined within each block.
o Example: In a large chip design, the routing of connections
Vt

between major blocks (e.g., CPU, memory) is done first. Once the
high-level routing is completed, detailed routing inside each block
(e.g., routing within a CPU block) is handled separately.
• Bottom-Up Hierarchical Routing: In this method, routing starts at the
lowest level of abstraction, such as the individual cells or gates, and
moves upward. Detailed routing is done first, and then the higher-level
interconnections between the blocks are routed.
o Example: Individual gates within a block are routed first, followed
by interconnections between different blocks (e.g., connecting CPU
and memory blocks after routing inside each block).
• Multi-Level Hierarchical Routing: This method combines both top-
down and bottom-up approaches. It routes the design at multiple levels,
starting with the highest-level connections and refining the routing
progressively through intermediate and low levels.

ud
o Example: A complex chip might be divided into various functional
blocks. First, the interconnections between these blocks are routed,
and then the detailed routing inside each block and sub-block is
done iteratively.
Advantages of Hierarchical Routing:
• It is highly scalable and effective for large and complex designs with
many cells or blocks.

lo
By treating blocks or regions as units, it simplifies routing by breaking
down the problem into smaller, more manageable parts.
Disadvantages of Hierarchical Routing:
• Can be computationally intensive, especially if multiple levels of
abstraction are involved.
uC
• The initial coarse routing may lead to suboptimal solutions if detailed
refinement is not adequately handled at lower levels.

10. Explain Global Routing b/w blocks with diagram.


Global routing is very similar for cell-based ASICs and gate arrays, but there is
a very important difference between the types of channels in these ASICs. The
Vt

size of the channels in sea-of-gates arrays, channelless gate arrays, and cell-
based ASICs can be varied to make sure there is enough space to complete the
wiring. In channeled gate-arrays and FPGAs the size, number, and location of
channels are fixed. The good news is that the global router can allocate as many
interconnects to each channel as it likes, since that space is committed anyway.
The bad news is that there is a maximum number of interconnects that each
channel can hold. If the global router needs more room, even in just one channel
on the whole chip, the designer has to repeat the placement-and-routing steps
and try again (or use a bigger chip).
ud
a) A cell-based ASIC with numbered channels. b) The channels form the edges of a graph. (c) The
channel-intersection graph. Each channel corresponds to an edge on a graph whose weight
corresponds to the channel length.

lo
Figure (a) shows an example of global routing for a net with five terminals, labelled A1 through F1,
for the cell-based ASIC. If a designer wishes to use minimum total interconnect path length as an
objective, the global router finds the minimum-length tree. (b). This tree determines the channels the
uC
interconnects will use. For example, the shortest connection from A1 to B1 uses channels 2, 1, and 5.
This is the information the global router passes to the detailed router. (c) shows that minimizing the
total path length may not correspond to minimizing the path delay between two points.

11. Back Annotation


Vt
12. Explain how partitioning and back annotation are used in floor
planning to improve timing and reduce delays.
1. Partitioning in Floor Planning
Partitioning divides the chip into smaller blocks to minimize interconnections
and optimize routing.
How Partitioning Improves Timing and Reduces Delays:

ud
• Minimizes Wire Length: Shorter interconnections between blocks
reduce signal propagation delays.
o Example: Placing logic and memory blocks close together reduces
routing delay.
• Reduces Routing Congestion: More space for routing prevents
congestion and delays.
o Example: Proper partitioning ensures sufficient space for wiring
lo
between blocks.
• Improves Power Distribution: Efficient partitioning helps in better
power grid design, reducing voltage drops and timing issues.

2. Back Annotation in Floor Planning


uC
Back annotation updates the floor plan based on timing, power, or signal
integrity feedback from simulations.
How Back Annotation Improves Timing and Reduces Delays:
• Timing Analysis Feedback: Adjusts layout based on timing violations,
optimizing critical paths.
o Example: Moving blocks closer to reduce delay in critical paths.
Vt

• Signal Integrity Adjustments: Mitigates crosstalk or noise by


repositioning signals.
o Example: Rerouting signals to avoid interference.
• Power and Thermal Considerations: Adjusts layout to address power
issues or thermal hotspots.
o Example: Moving blocks with high power consumption to cooler
regions.
MODULE 3
1. Explain the verification process of system Verilog.
• What is the goal of verification? Finding bugs, are partly correct.
• The goal of hardware design is to create a device that performs a
particular task, such as a DVD player, network router, or radar signal
processor, based on a design specification.
• The main purpose as a verification engineer is to make sure the device

ud
can accomplish that task successfully that is, the design is an accurate
representation of the specification. Bugs are what we get when there is a
discrepancy.
• The process of verification parallels the design creation process. A
designer reads the hardware specification for a block, interprets the
human language description, and creates the corresponding logic in a
machine-readable form, usually RTL code.
• To do this, he or she needs to understand the input format, the
lo
transformation function, and the format of the output.
• There is always ambiguity in this interpretation, perhaps because of
ambiguities in the original document, missing details, or conflicting
descriptions.
• As a verification engineer, you must also read the hardware specification,
create the verification plan, and then follow it to build tests showing the
uC
RTL code correctly implements the features.
• By having more than one person perform the same interpretation, you
have added redundancy to the design process.
• As the verification engineer, your job is to read the same hardware
specifications and make an independent assessment of what they mean.
Your tests then exercise the RTL to show that it matches your
interpretation.
Vt

2. Discuss the role of constrained random stimulus in design verification.


Figure 1-4 shows the coverage for constrained-random tests over the total
design space. First, notice that a random test often covers a wider space than a
directed one. This extra coverage may overlap other tests, or may explore new
areas that you did not anticipate. If these new areas find a bug, you are in luck!
If the new area is not legal, you need to write more constraints to keep random
generation from creating illegal design functionality. Lastly, you may still have
to write a few directed tests to find cases not covered by any other
constrainedrandom tests.

ud
lo
Figure 1-5 shows the paths to achieve complete coverage. Start at the upper left
with basic constrained-random tests. Run them with many different seeds. When
you look at the functional coverage reports, find the holes where there are gaps
in the coverage. Now you make minimal code changes, perhaps by using new
constraints, or by injecting errors or delays into the DUT. Spend most of your
time in this outer loop, writing directed tests for only the few features that are
uC
very unlikely to be reached by random tests.
3. Explain the factors in randomizing the stimulus to design.
4. Discuss the role of functional coverage in enhancing the verification
process.
Role of Functional Coverage in Enhancing the Verification Process
Functional coverage is vital for ensuring thorough verification by tracking
Vt

which parts of the design have been tested and identifying areas that need
further attention. Here’s how it enhances the verification process:
1. Measuring Verified Areas
Functional coverage tracks the design states that have been exercised during
simulations, ensuring all functionalities are verified. This helps confirm that
every aspect of the design is tested.
• Example: It ensures all bus transactions and control signals have been
applied.
2. Identifying Uncovered States
Some design states may remain untested with random stimulus. Functional
coverage identifies these uncovered areas, guiding the creation of new tests to
explore them.
• Example: Coverage feedback points out edge cases that haven’t been
tested.

ud
3. Feedback for Test Improvement
The feedback loop from functional coverage helps modify stimulus generation,
especially when coverage starts plateauing. This drives coverage-driven
verification, where tests evolve to target uncovered areas.
• Example: Adjusts tests to focus on error conditions if other transactions
are already covered.

lo
uC
4. Reducing Manual Effort
Functional coverage automates test creation by showing which areas have been
covered, reducing the need for manual test writing and analysis.
• Example: Instead of manually writing tests, coverage helps guide
automatic evolution of tests.
5. Adapting to Design Changes
Vt

As the design evolves, functional coverage helps adapt existing tests to ensure
all new states are tested, even if the design’s timing changes.
• Example: Adapts tests when design timing changes, covering new areas.
6. Efficient Test Creation with Dynamic Constraints
By adjusting constraints based on coverage feedback, the test becomes more
efficient, focusing on uncovered areas for faster and more thorough verification.
• Example: Once read cycles are covered, the test can focus on write cycles
or errors.

5. Explain the various test bench components.

ud
The components of the testbench are focused on the communication interfaces
that connect the Design Under Test (DUT) to the testbench. These are modeled
as Bus Functional Models (BFMs), which simulate the behavior of real-world
bus interfaces. Here’s a breakdown:
lo
Testbench Components
1. AMBA (Advanced Microcontroller Bus Architecture)
AMBA is a widely used bus standard in embedded systems, particularly
for connecting microcontrollers and peripherals. In the testbench, the
AMBA BFM will generate stimulus (such as read/write commands and
uC
data) and check the DUT’s responses.
2. USB (Universal Serial Bus)
The USB BFM is used to simulate USB communication between the
DUT and other components. It mimics the USB protocol, sending and
receiving data and commands, and verifying that the DUT processes them
correctly.
3. PCI (Peripheral Component Interconnect)
Vt

The PCI BFM simulates the PCI bus interface. It generates data
transactions (such as memory reads/writes or device communication) and
monitors the DUT’s responses to these operations.
4. SPI (Serial Peripheral Interface)
The SPI BFM is responsible for simulating the SPI bus, used for
communication between microcontrollers and peripheral devices. It sends
data commands to the DUT and verifies that the DUT responds correctly.
Role of the Components in the Testbench
These bus functional models (BFMs) represent the interfaces that the DUT
interacts with in a real system. In the testbench:
• The BFMs behave like actual bus components, but they are part of the
testbench, not the RTL design.
• These models generate appropriate stimulus for each bus (AMBA, USB,

ud
PCI, SPI) and check the DUT's response to ensure functionality.
Design Under Test (DUT):
The DUT is the actual design being tested, which could be a processor, a
microcontroller, or any complex digital system. It interacts with the bus
interfaces (AMBA, USB, PCI, SPI) through the testbench, which simulates real-
world communication.

lo
6. Write a short note on built in data types of system verilog with examples.
Built-in Data Types in SystemVerilog
SystemVerilog provides a variety of built-in data types to support both hardware
description and verification tasks. These types are more advanced than the
Verilog data types and offer greater flexibility. The built-in data types in
SystemVerilog can be broadly categorized into logic types, integer types, real
uC
types, user-defined types, enumerated types, and string types.

1. Logic Types
SystemVerilog has robust support for logic types that cater to both 2-state and 4-
state variables.
• bit: A 2-state variable (0 or 1).
Vt

bit my_bit; // 2-state variable


• logic: A 4-state variable (0, 1, X, Z). This is a general-purpose signal type
that can be used instead of reg or wire in Verilog.
logic my_logic; // 4-state variable
• byte: A specific 8-bit unsigned integer, ranging from 0 to 255.
byte my_byte = 8'hFF; // 8-bit byte
2. Integer Types
Integer types in SystemVerilog provide various widths and signed/unsigned
representations.
• int: A 32-bit signed integer.
int my_int = -10; // 32-bit signed integer
• shortint: A 16-bit signed integer.

ud
shortint my_shortint = 5; // 16-bit signed integer
• longint: A 64-bit signed integer.
longint my_longint = 10000000000; // 64-bit signed integer
• uint: A 32-bit unsigned integer.
uint my_uint = 42; // 32-bit unsigned integer

3. Real Types
lo
Real types represent floating-point numbers and are used for decimal
calculations.
• real: A 64-bit double-precision floating-point number.
uC
real my_real = 3.14159; // 64-bit floating-point number

4. User-Defined Types
SystemVerilog allows users to define new types using typedef, struct, and enum.
• typedef: This is used to create new types, including structures and
enumerations.
Vt

o struct: Used to group several related variables together into a


single data type.
typedef struct {
bit [7:0] r, g, b; // Red, Green, Blue components
} pixel_s;
pixel_s my_pixel; // Declaration of a variable of type pixel_s
o enum: Used to define an enumerated type, representing a set of
named values.
typedef enum {INIT, DECODE, IDLE} fsmstate_e;
fsmstate_e pstate, nstate; // Declare variables of type fsmstate_e

You can assign values to enum constants, and they default to integers starting
from 0.

ud
typedef enum {INIT=0, DECODE=2, IDLE} fsmtype_e;

5. Enumerated Types
Enumerated types help make code more readable and provide a set of named
constants.
• Declaring an enum: A simple way to declare an enum with values
starting from 0 by default.
lo
typedef enum {RED, BLUE, GREEN} color; // Enum declaration
• Using enums: Enumerated values can be used to represent states in state
machines, for example.
typedef enum {INIT, DECODE, IDLE} fsmstate_e;
uC
• Casting and assignment: You can cast values between enums and
integers.
typedef enum {RED, BLUE, GREEN} COLOR_E;
COLOR_E color;
integer c;
c = color; // Convert enum to integer
Vt

$cast(color, c); // Convert integer back to enum


• Functions for enums: There are built-in functions to step through enum
values (first, last, next, prev), which are useful for traversing the
enumerated values.
6. String Types
SystemVerilog provides a dynamic string type, which is flexible and supports
variable-length strings.
• string: A dynamic string type that holds a sequence of characters, and the
length can be changed during runtime.
string s = "SystemVerilog"; // String initialization
String operations: You can use various methods for string manipulation:
o getc(N): Returns the byte at position N.
o toupper(): Converts the string to uppercase.

ud
o tolower(): Converts the string to lowercase.
o substr(start, end): Extracts a substring from start to end.
$display(s.getc(0)); // Outputs: 83 ('S')
$display(s.toupper()); // Outputs: SYSTEMVERILOG
s = {s, " 3.1b"}; // Concatenate strings
s.putc(s.len()-1, "a");
lo // Modify the last character
$display(s.substr(2, 5)); // Outputs: stem
o Formatted string: You can use $psprintf to format and pass strings
directly to functions without creating temporary variables.
my_log($psprintf("%s %5d", s, 42));
uC
7. Explain the different types of array methods used in unpacked arrays.
Unpacked Arrays
Unpacked arrays in SystemVerilog are arrays in which each element is stored
individually. These arrays differ from packed arrays, where the entire array is
treated as a single entity. Unpacked arrays are often used in SystemVerilog to
represent vectors, registers, or multi-dimensional data structures.
Vt

Methods for Unpacked Arrays (as per the content)


Here are some of the unpacked array methods referenced in your content:
1. size() Method
o Purpose: Used to return the size (or number of elements) of an
unpacked array.
o Example:
int arr[10];
initial begin
$display("Array size: %0d", arr.size()); // Returns the size
of the array
end

ud
2. len() Method
o Purpose: This method is particularly useful for dynamic arrays,
returning the number of elements in the array.
o Example:
string arr[];
initial begin
lo arr = new[5]; // Create a dynamic array with 5 elements
$display("Array length: %0d", arr.len()); // Returns the
number of elements
end
uC
3. pop_front() and pop_back() Methods
o Purpose:
▪ pop_front() removes an element from the front of the array.
▪ pop_back() removes an element from the back of the array.
o Example:
int arr[] = new[3];
Vt

arr = {1, 2, 3};


initial begin
arr.pop_front(); // Removes the first element (1)
$display("Array after pop_front: %0p", arr); // [2, 3]
arr.pop_back(); // Removes the last element (3)
$display("Array after pop_back: %0p", arr); // [2]
end
4. push_back() and push_front() Methods
o Purpose:
▪ push_back() adds an element to the back of the dynamic
array.
▪ push_front() adds an element to the front of the array.
o Example:

ud
int arr[] = new[3];
arr = {1, 2, 3};
initial begin
arr.push_back(4); // Adds 4 at the end
$display("Array after push_back: %0p", arr); // [1, 2, 3, 4]
arr.push_front(0); // Adds 0 at the front
lo$display("Array after push_front: %0p", arr); // [0, 1, 2, 3, 4]
end

5. insert() Method
o Purpose: The insert() method inserts an element at a specified
position in the array.
uC
o Example:
int arr[] = new[4];
arr = {1, 2, 3, 5};
initial begin
arr.insert(3, 4); // Inserts 4 at position 3
$display("Array after insert: %0p", arr); // [1, 2, 3, 4, 5]
Vt

end

6. delete() Method
o Purpose: The delete() method removes an element from the
dynamic array at a specific position.
o Example:
int arr[] = new[5];
arr = {1, 2, 3, 4, 5};
initial begin
arr.delete(2); // Deletes element at index 2 (3)
$display("Array after delete: %0p", arr); // [1, 2, 4, 5]
end

7. fill() Method

ud
o Purpose: The fill() method sets all elements in the array to the
specified value.
o Example:
int arr[5];
arr = {1, 2, 3, 4, 5};
initial begin

8. copy() Method
lo
end
arr.fill(0); // Sets all elements to 0
$display("Array after fill: %0p", arr); // [0, 0, 0, 0, 0]

o Purpose: The copy() method copies the contents of one dynamic


uC
array into another.
o Example:
int arr1[] = {1, 2, 3};
int arr2[];
initial begin
arr2.copy(arr1); // Copies contents of arr1 into arr2
Vt

$display("Array 2 after copy: %0p", arr2); // [1, 2, 3]


end

8. How are fixed arrays and dynamic arrays different in System Verilog?
Provide examples.
In SystemVerilog, fixed arrays and dynamic arrays are both used to store
collections of data, but they differ in how they are allocated and how their sizes
are handled.
Fixed Arrays
A fixed array in SystemVerilog is an array where the size is specified at
compile time, and it cannot be changed during simulation. This means that once
the size is declared, it is fixed for the lifetime of the array.
• Declaration: The size of the array is known and fixed at compile time.
• Memory: It uses a fixed amount of memory based on the size specified

ud
during declaration.
Example of Fixed Array:
// Fixed array declaration with size 10
int arr[10];
Here, arr is a fixed-size array with 10 elements. The size of the array is specified
during declaration, and it cannot be changed during simulation.
Dynamic Arrays lo
A dynamic array in SystemVerilog is an array whose size is determined at
runtime. The size of a dynamic array can be changed during the simulation, and
the memory for the array is allocated dynamically.
• Declaration: The size of the array is not specified at compile time.
Instead, it can be allocated during simulation using methods such as new
uC
or new[].
• Memory: The memory used for the array is allocated dynamically at
runtime, allowing it to grow or shrink as needed.
Example of Dynamic Array:
// Dynamic array declaration
int arr[];
Vt

// Allocating memory for the dynamic array


arr = new[10]; // Allocates memory for 10 elements

// Changing the size of the dynamic array at runtime


arr = new[20]; // Now the array size is 20
Here, arr is a dynamic array, and its size can be changed during runtime using
the new[] operator.
Key Differences:
• Size Determination: In a fixed array, the size is known and fixed at
compile time. In a dynamic array, the size is determined at runtime.
• Memory Allocation: Fixed arrays use a predefined amount of memory,

ud
while dynamic arrays allocate memory dynamically based on the size
assigned during simulation.
• Resizing: Fixed arrays cannot be resized after declaration, whereas
dynamic arrays can be resized during runtime using methods like new[].

9. Explain the use of associative arrays and queues in System Verilog with
examples.
Associative Arrays
lo
An associative array in SystemVerilog is an array indexed by a non-integer
value such as a string or enum. The array elements can be accessed using keys
that are non-contiguous, and the size can dynamically adjust during simulation.
Associative arrays are typically used when the index is not a simple integer or
when you don't know the size ahead of time.
uC
• Definition: Associative arrays are declared with a dynamic index type
(e.g., string or enum).
Example:
string arr[string]; // Associative array indexed by strings
arr["one"] = 10;
arr["two"] = 20;
Vt

$display(arr["one"]); // Output: 10

• Key Operations:
o You can use any type as the index (e.g., string, enum).
o New entries can be added dynamically, as shown above where the
values are indexed by strings like "one" and "two".
o You can delete entries using $delete(arr).
Queues
A queue in SystemVerilog is a dynamic, ordered collection of elements that
allows adding and removing elements from both ends. It is similar to a dynamic
array but provides specific methods for adding or removing elements from
either the front or back of the queue.
• Definition: A queue is a dynamic array with special methods to add or
remove elements.

ud
Example:
int q[]; // Declare a queue of integers

q.push_back(10); // Add 10 to the back


q.push_front(20); // Add 20 to the front
q.pop_back(); // Remove from the back
lo
q.pop_front(); // Remove from the front

• Key Operations:
o push_back(): Adds elements to the back of the queue.
o push_front(): Adds elements to the front of the queue.
uC
o pop_back(): Removes elements from the back of the queue.
o pop_front(): Removes elements from the front of the queue.
o The queue is dynamically resized as elements are added or
removed.
Both associative arrays and queues are flexible and dynamic, offering
advanced operations for efficient data management in SystemVerilog. The
associative array is particularly useful when you need to store elements indexed
Vt

by keys other than integers, while queues are ideal for managing ordered
collections of data.
10. Write and explain a System Verilog code snippet using associative
arrays.
SystemVerilog Code Example with Associative Arrays

module associative_array_example;

ud
// Declare an associative array
// In this case, we're associating integers with strings
integer arr[string];

initial begin
// Assign values to the array using string indices
lo
arr["apple"] = 10;
arr["banana"] = 20;
arr["cherry"] = 30;

// Display the values associated with each index


uC
$display("Value of apple: %0d", arr["apple"]); // Output: 10
$display("Value of banana: %0d", arr["banana"]); // Output: 20
$display("Value of cherry: %0d", arr["cherry"]); // Output: 30

// Checking if a specific key exists


if (arr.exists("banana")) begin
Vt

$display("The value for banana is: %0d", arr["banana"]); // Output: 20


end

// Delete a specific element


arr.delete("apple");

// Display after deletion


if (!arr.exists("apple")) begin
$display("The key 'apple' no longer exists.");
end
end
endmodule

ud
Explanation of Code:
1. Associative Array Declaration:
integer arr[string];
o The array arr is an associative array, where the index is of type
string (e.g., "apple", "banana", etc.), and the stored values are of
type integer.
lo
2. Assigning Values:
arr["apple"] = 10;
arr["banana"] = 20;
arr["cherry"] = 30;
Here, the array arr is assigned values where each string ("apple",
uC
o
"banana", "cherry") corresponds to an integer value.
3. Accessing Values:
$display("Value of apple: %0d", arr["apple"]);
o This statement displays the value associated with the key "apple",
which is 10.
4. Checking for Existence:
Vt

if (arr.exists("banana")) begin
$display("The value for banana is: %0d", arr["banana"]);
end
o This checks if the key "banana" exists in the array. If it exists, the
corresponding value is displayed.
5. Deleting an Entry:
arr.delete("apple");
o This removes the key-value pair associated with "apple" from the
associative array.
6. Verification After Deletion:
if (!arr.exists("apple")) begin

ud
$display("The key 'apple' no longer exists.");
end
o After deletion, the code checks again for the existence of "apple".
If it no longer exists, it displays a message confirming the deletion.
Key Methods Used:
• arr.exists(index) — Checks if the specified key (index) exists in the
lo
associative array.
• arr.delete(index) — Deletes the specified key-value pair from the array.
This approach, based on your provided content, showcases how associative
arrays work in SystemVerilog for storing values associated with non-
contiguous indices, using string indices in this case.
uC
11. Describe the purpose of typedef and user-defined structures in System
Verilog.
In SystemVerilog, the typedef and user-defined structures are essential tools
for organizing and managing complex data types.
Purpose of typedef in SystemVerilog
Vt

The typedef keyword in SystemVerilog is used to define new data types, giving
names to existing types or creating more complex types. The typedef statement
helps in simplifying the code, improving readability, and maintaining
consistency throughout the design.
1. Creating New Data Types: typedef allows you to define an alias for
existing data types, which simplifies the usage of complex or repetitive
types. It can be used to define bit-widths or even packed/unpacked types
for better organization of code.
Example:
typedef reg [7:0] byte; // Creates a new type 'byte' which is an 8-bit register
byte data; // Declares a variable of type byte

2. Parameterization: typedef can also work in conjunction with parameter


to create scalable designs that adapt to different bit-widths.
Example:

ud
parameter OPSIZE = 8;
typedef reg [OPSIZE-1:0] opreg_t;
opreg_t op_a, op_b; // Declares two variables of type opreg_t

3. Defining Unsigned 32-bit Integers: As shown in your content, typedef is


often used for creating common data types like uint (unsigned 32-bit
integers) that are frequently used in testbenches or modules.
Example: lo
typedef bit [31:0] uint; // 32-bit unsigned 2-state integer

Purpose of User-Defined Structures in SystemVerilog


User-defined structures in SystemVerilog allow you to group related variables
uC
together under a single type. This is useful for organizing data and for
combining various fields with different bit-widths into one cohesive entity. The
struct keyword is used to define structures in SystemVerilog.
1. Grouping Related Data: A structure allows you to group variables of
different types into a single unit. This is helpful when dealing with
complex data like pixels or instructions where multiple fields are
combined logically.
Vt

Example of creating a pixel structure:


struct {bit [7:0] r, g, b;} pixel; // Defines a structure with 3 fields for red, green,
and blue

2. Creating a New Type from Structure: To make it easier to use a


structure repeatedly, a typedef can be combined with struct to create a
new, reusable type. This new type can then be used to declare multiple
variables.
Example:
typedef struct {bit [7:0] r, g, b;} pixel_s;
pixel_s my_pixel; // Declares a variable 'my_pixel' of type pixel_s

3. Packed Structures: SystemVerilog also allows structures to be packed


into the smallest possible space using the packed keyword. This ensures
that there are no gaps in memory, making it more memory-efficient,
which is particularly useful when working with bit-fields.

ud
Example of a Packed Structure:
typedef struct packed {bit [7:0] r, g, b;} pixel_p_s;
pixel_p_s my_pixel; // This structure will use only 3 bytes in memory

12. Explain the constants and strings in system verilog with examples.
Constants in SystemVerilog:
lo
In SystemVerilog, constants can be defined in several ways. You can use
parameter, const, or macros for creating constants. Each has its specific use case
and scope.
1. Parameter: Parameters are often used for constant values in a module,
and they have a fixed value that is set at compile time. Parameters can be
uC
given a global scope by defining them in the $root scope.
Example:
parameter byte colon = ":"; // Declare a parameter with a constant value
initial begin
$display("Colon character is: %0s", colon);
end
Vt

2. Const: The const keyword allows you to create a variable that can only
be initialized at the time of declaration but cannot be modified during
execution. This is useful when you need to define constants in a more
general scope.
Example:
initial begin
const byte colon = ":"; // Declare a constant variable
// colon = ";"; // This will give an error, as 'colon' is a constant.
end

3. Text Macros: Though not as commonly used in SystemVerilog, you can


still use text macros for defining constants that have global scope.
However, they can cause conflicts when used inappropriately.
Strings in SystemVerilog:
Strings in SystemVerilog are dynamic and variable-length, unlike in Verilog,
where strings could not be handled directly. A string in SystemVerilog is

ud
essentially an array of byte type elements, and individual characters are stored
as byte. The language does not use a null-terminator for strings, which is
different from languages like C.
1. String Operations: SystemVerilog provides several built-in methods for
string manipulation, such as getc(), toupper(), tolower(), putc(), and
substr(), among others.
o getc(N): Returns the byte (character) at position N.
lo
o toupper(): Converts the string to uppercase.
o tolower(): Converts the string to lowercase.
o putc(M): Writes a byte at position M in the string.
o substr(start, end): Extracts a substring from start to end.
uC
Example of using strings:
string s; // Declaring a string variable

initial begin
s = "SystemVerilog"; // Assigning a string value
$display(s.getc(0)); // Displays the ASCII value of 'S' (83)
Vt

$display(s.toupper()); // Converts and displays "SYSTEMVERILOG"


s = {s, " 3.1b"}; // Concatenating another string, displays "SystemVerilog
3.1b"
s.putc(s.len()-1, "a"); // Changes last character to 'a', now "SystemVerilog
3.1a"
$display(s.substr(2, 5)); // Extracts substring from index 2 to 5, displays
"stem"
// Using formatted string
my_log($psprintf("%s %5d", s, 42));
end

task my_log(string message);


// Print a message to a log
$display("@%0d: %s", $time, message);

ud
endtask

This example demonstrates several string functions that show how


SystemVerilog handles dynamic strings and performs operations like
concatenation, case conversion, and substring extraction. The $psprintf function
is used to format the string before passing it to the my_log task.

MODULE 4 lo
1. Write a short note on procedural statements in system verilog
Procedural Statements in SystemVerilog:
SystemVerilog includes various procedural statements and operators that
enhance the capabilities of hardware design and verification. These statements
are similar to those found in C and C++, but with specific adaptations for
uC
hardware description. Some key procedural statements include initial, always,
for, while, do...while, break, continue, and forever.
1. Initial Block: The initial block is used to execute code sequentially at the
beginning of simulation. It is used to initialize values and perform initial
assignments.
Example:
Vt

initial begin
integer array[10], sum, j;
// Initialize array with values
for (int i = 0; i < 10; i++)
array[i] = i;

sum = array[9];
j = 8;
// Accumulate values using a do-while loop
do
sum += array[j];
while (j--);

ud
$display("Sum = %4d", sum);
end

2. For Loop: SystemVerilog allows declaring loop variables inside a for


statement, which limits the scope of the variable to the loop itself. This
reduces the chances of bugs and improves code clarity.
Example:
for (int i = 0; i < 10; i++)
lo
array[i] = i;

3. Do...While Loop: The do...while loop is used to execute the block of


code at least once before checking the condition at the end.
Example:
uC
do
sum += array[j];
while (j--);

4. Break and Continue:


o Break: This statement is used to exit a loop immediately when a
certain condition is met.
Continue: This statement is used to skip the current iteration and
Vt

o
continue to the next iteration of the loop.
Example:
initial begin
bit [127:0] cmd;
int file, c;
file = $fopen("commands.txt", "r");
while (!$feof(file)) begin
c = $fscanf(file, "%s", cmd);
case (cmd)
"": continue; // Skip blank lines
"done": break; // Exit loop when "done" is encountered
… // Process other commands

ud
endcase
end
$fclose(file);
end

5. Labels: SystemVerilog allows you to label blocks such as begin/end,


fork/join, and others. This is useful for readability and matching the start
and end of blocks more easily.
lo
Example:
initial
begin : example
integer array[10], sum, j;
uC
for (int i = 0; i < 10; i++)
array[i] = i;
sum = array[9];
j = 8;
do
sum += array[j];
Vt

while (j--);
$display("Sum=%4d", sum);
end : example

2. Explain tasks and void functions with examples


From the content you provided, here's the explanation of tasks and void
functions in SystemVerilog:
Tasks in SystemVerilog
A task in SystemVerilog can consume time, meaning it can include delays,
event triggers, or wait statements. A task can have input, output, or inout
arguments but does not return a value. This is useful for processes that require
time-based actions or events.
• Key points about tasks:

ud
o A task can consume time (e.g., delay or wait for events).
o It can call other tasks and functions.
o A task does not return a value, but it can modify its arguments.
Example of a task:
task print_state;
input [7:0] state;

endtask
lo
$display("Current state: %h", state);

In the above example, the task print_state takes an input argument state and
simply displays its value. This task does not return any value.
Another task example which consumes time:
uC
task wait_for_event;
input event e;
wait (e); // Wait for the event to occur
$display("Event occurred at time %0t", $time);
endtask
Vt

Here, the wait_for_event task waits for an event e to be triggered before


displaying the time.
Void Functions in SystemVerilog
A void function in SystemVerilog does not return a value and cannot consume
time (i.e., it does not include any delays or wait statements). A void function is
typically used when you need to perform a function but don’t need to return a
value.
• Key points about void functions:
o Cannot consume time (no delays, events, or waits).
o Cannot return a value.
o Can be called from any task or function, making it flexible.
Example of a void function:
function void print_message;
input string message;

ud
$display("Message: %s", message);
endfunction
In this example, the print_message function takes a string input message and
simply displays it. It does not return any value.
Void Functions for Debugging
In SystemVerilog, void functions are commonly used for debugging purposes.
lo
These functions perform actions like printing debug information but don’t
return any value.
Example of a void function for debugging:
function void print_state;
uC
input string state_name;
$display("State is: %s at time %0t", state_name, $time);
endfunction
Here, the print_state function takes an input string state_name and prints it
along with the current simulation time. This is a typical debugging function.
Ignoring Function's Return Value
Vt

If you call a function and do not need its return value, you can cast the return
value to void. This tells the simulator to ignore the return value.
Example of ignoring a function's return value:
void' ($fscanf(file, "%d", i)); // Ignore the return value
In this example, the return value of the $fscanf function (which reads from a
file) is ignored by casting it to void.
Summary
• Tasks are used for time-consuming operations and do not return a value.
They are useful for processes that require delays or waiting for events.
• Void functions do not return values and do not consume time. They can
be used for operations such as printing debug messages or performing
quick tasks that don't need any output.

ud
3. Differentiate between tasks and functions in System Verilog. Provide
suitable examples.
Key Differences Between Tasks and Functions:
• Tasks:
o A task in SystemVerilog can consume time, i.e., it can include
delays (#100), events (@(posedge clock)), or even wait for
conditions (wait(ready)).
o

o
lo
Tasks can call other tasks and functions.
Tasks do not need to return a value but can have input, output, or
inout arguments.
Example:
task print_state;
uC
$display("Current state: %s", state.name());
endtask

• Functions:
o A function cannot consume time. This means no delays, events, or
wait statements are allowed.
o A function must return a value, which must be used in the calling
Vt

code (e.g., in an assignment statement).


o A function in SystemVerilog can call a task, but only if the task is
executed in a separate thread (e.g., via fork...join_none).
Example:
function int add(int a, int b);
return a + b;
endfunction
4. Explain the routine arguments with necessary examples
Routine Arguments in SystemVerilog
SystemVerilog introduces several improvements for routine argument handling,
making them cleaner and more efficient.
1. C-Style Routine Arguments

ud
SystemVerilog allows a cleaner, C-style syntax for declaring arguments,
reducing repetition.
Example
task mytask1 (output logic [31:0] x, input logic y);
endtask

This avoids the verbose declaration style of Verilog-1995.


2. Argument Direction
lo
In SystemVerilog, argument direction defaults to input logic, simplifying
declaration. However, it's best practice to explicitly specify direction and type.
Example:
task T3(a, b, output bit [15:0] u, v); // Implicit input type for a, b
uC
3. Advanced Argument Types
Using the ref keyword, arguments like arrays can be passed by reference,
improving performance by avoiding copies. const ref ensures the array isn’t
modified inside the function.
Example:
function void print_checksum(const ref bit [31:0] a[]);
Vt

The ref type allows modifications of arguments to reflect immediately in the


calling scope.
4. Default Argument Values
SystemVerilog allows default values for arguments, making routines flexible
without breaking existing calls.
Example:
function void print_checksum(ref bit [31:0] a[], input bit [31:0] low, input int high = -1);

This function can be called with or without the high argument, using -1 as the
default.
5. Passing Arguments by Name
You can pass arguments by name, which is helpful for routines with many

ud
arguments, allowing you to specify only a few while using default values for
others.
Example:
task many(input int a = 1, b = 2, c = 3, d = 4);
$display("%0d %0d %0d %0d", a, b, c, d);
endtask

This allows flexible calls, such as many(.c(5)) to only specify c.


lo
5. Explain the 1. Returning of array from a function 2. Passing an array to
a function in system verilog
1. Returning an Array from a Function in SystemVerilog
uC
In SystemVerilog, returning an array from a function is more straightforward
than in Verilog, which only allowed returning simple types like bits or integers.
SystemVerilog provides different methods to handle array return values:
Method 1: Using a typedef for the array
You can define an array type using typedef, and then use that type in the
function's declaration to return an array. This is an efficient way to handle arrays
in functions.
Vt

Example:
typedef int fixed_arrayS[5]; // Define the array type
fixed_arrayS fS; // Declare an array variable

function fixed_arrayS init(int start);


foreach (fS[i])
fS[i] = i + start; // Initialize the array elements
endfunction

initial begin
fS = init(5); // Call function and return the array
foreach (fS[i])
$display("fS[%0d] = %0d", i, fS[i]); // Display array values

ud
end

In this example, the function init returns an array of type fixed_arrayS. The
array is initialized and then returned to the variable fS.
Method 2: Passing by reference
Instead of returning a copy of the array, you can pass the array by reference
using the ref keyword. This eliminates the performance overhead of copying
large arrays. lo
Example:
function void init(ref int f[5], input int start);
foreach (f[i])
f[i] = i + start; // Initialize the array elements
uC
endfunction

int fa[5]; // Declare an array

initial begin
init(fa, 5); // Pass the array by reference
foreach (fa[i])
Vt

$display("fa[%0d] = %0d", i, fa[i]); // Display array values


end

In this example, the init function initializes the fa array directly by passing it as
a reference.
2. Passing an Array to a Function in SystemVerilog
SystemVerilog allows arrays to be passed to functions in several ways:
Passing an array by reference (using ref)
The most common and efficient way to pass an array to a function is by using
the ref keyword. This avoids copying the array and allows the function to
modify the original array directly.
Example:
function void modify_array(ref int arr[], input int increment);

ud
foreach (arr[i])
arr[i] = arr[i] + increment; // Modify the array elements
endfunction

int arr[5] = '{1, 2, 3, 4, 5}; // Declare and initialize the array

initial begin lo
modify_array(arr, 2); // Pass the array by reference
foreach (arr[i])
$display("arr[%0d] = %0d", i, arr[i]); // Display modified array values
end
uC
In this example, the modify_array function takes an array by reference and
modifies its values. The original array (arr) is changed directly without creating
a copy.
Passing arrays with const ref
If you don't want the function to modify the array, you can use const ref. This
ensures that the array is passed by reference, but its contents cannot be changed
within the function.
Vt

Example:
function void print_array(const ref int arr[]);
foreach (arr[i])
$display("arr[%0d] = %0d", i, arr[i]); // Print array elements
endfunction

int arr[3] = '{10, 20, 30}; // Declare and initialize the array
initial begin
print_array(arr); // Pass the array by reference without modifying it
end

In this example, the print_array function prints the values of the array without
modifying it, thanks to the const ref type.

ud
6. Explain the concept of separating the test bench and design in system
verilog with an example (or) Describe the significance of separating the
testbench and design in verification.
Significance of Separating the Testbench and Design in Verification
In hardware verification, separating the testbench and design is crucial for
several reasons: lo
1. Independent Development and Focus:
o Design Team: Focuses on creating the RTL (Register Transfer
Level) code to meet the design specification. Their goal is to
implement functional logic, ensuring the design works as expected.
o Verification Team: Develops the testbench to create test scenarios,
uC
check for potential bugs, and ensure that the design behaves
according to the specification under all conditions. Their job is to
find issues where the design doesn't match the expected behavior.
2. Cleaner and More Maintainable Code:
o Modularity: By separating the testbench from the design, it
becomes easier to maintain each part of the code independently.
Changes to the design do not immediately affect the testbench, and
Vt

vice versa.
o Reuse: A well-separated testbench can be reused across multiple
designs without needing modification. This saves time and ensures
consistency in testing.
3. Avoiding Timing Issues:
o In traditional Verilog, placing the testbench within the same
module as the design often leads to timing and synchronization
issues, especially when driving and sampling signals.
SystemVerilog introduces the program block, which separates the
testbench logically and temporally from the design, reducing these
issues.
4. Error Reduction:
o As designs grow in complexity, the connections between different
blocks increase, which can lead to errors in wiring and signal
connections. By using interfaces in SystemVerilog, you can bundle

ud
signals with synchronization logic and functional code, simplifying
the connection process and reducing errors. The connect-by-name
syntax further aids in this, preventing mismatches in signal
connections and making the design easier to manage.
5. Clear Communication Between Testbench and DUT (Design Under
Test):
o In a well-separated setup, the communication between the
lo
testbench and the DUT is clearly defined, often using ports and
interfaces. This separation allows the testbench to send inputs (like
requests) to the DUT, while receiving outputs (like grants) for
validation.
Example: Separating the Testbench and Design
Here’s a simple example to illustrate the separation between the testbench and
uC
design:
Arbiter Design (DUT)
module arbiter (output logic [1:0] grant,
input logic [1:0] request,
input logic rst,
input logic clk);
Vt

always @(posedge clk or posedge rst) begin


if (rst)
grant <= 2'b00;
else
grant <= request; // Simple logic
end
endmodule

Testbench Code (Separate from Design)


module test (input logic [1:0] grant,
output logic [1:0] request,
output logic rst,

ud
input logic clk);

initial begin
@(posedge clk) request <= 2'b01;
$display("@%0t: Drove req = 2'b01", $time);
repeat (2) @(posedge clk);
if (grant != 2'b01)
lo
$display("@%0t: Error: grant != 2'b01", $time);
$finish;
end
endmodule
uC
Top-level Netlist (Combining Testbench and DUT)
module top;

logic [1:0] grant, request;


bit clk, rst;
Vt

always #5 clk = ~clk; // Clock generator

arbiter a1 (grant, request, rst, clk); // Connect DUT


test t1 (grant, request, rst, clk); // Connect Testbench

endmodule
7. Explain the purpose and structure of interface constructs in System
Verilog.
Purpose of Interface Constructs
1. Simplification of Connections: Interfaces allow multiple signals to be
grouped together as a single entity, reducing the need to declare and
connect each signal individually across different modules. This
simplification makes the design cleaner, more manageable, and less prone

ud
to mistakes.
2. Reducing Wiring Errors: When using interfaces, adding a new signal
only requires modifying the interface, rather than multiple places in the
design. This greatly reduces the chance of making errors during the
wiring process, especially in large, complex designs.
3. Communication Between Blocks: Interfaces model the communication
between blocks, such as between the testbench and the DUT. They make
lo
the connection between these blocks more intuitive and provide a
centralized way of managing related signals.
4. Reusability and Modularity: Interfaces make it easier to reuse design
components because the signals are grouped in a modular way. For
example, if you have a standard protocol (e.g., a bus), you can reuse the
same interface across different designs, reducing the need for duplicating
uC
code.
Structure:
1. Signals: Interfaces contain the signals needed for communication
between blocks.
2. Modports: These define signal directions (input, output) for different
roles (e.g., DUT, testbench, monitor).
Vt

3. Functions/Tasks: Interfaces can include functionality like


synchronization.
Example of Interface:
interface arb_if(input bit clk);
logic [1:0] grant, request;
logic rst;
modport DUT(input request, rst, clk, output grant);
modport TEST(output request, rst, input grant, clk);
endinterface

The interface is used in both the DUT and testbench:


module arb (arb_if.DUT arbif); // DUT uses the DUT modport
// DUT logic
endmodule

ud
module test (arb_if.TEST arbif); // Testbench uses the TEST modport
// Testbench logic
endmodule

8. Write and explain a SystemVerilog code that integrates an interface with


assertions to validate a basic logic circuit.
lo
SystemVerilog Code with Interface and Assertions:
// Define an interface for the logic circuit (AND gate in this case)
interface logic_if(input logic clk);
logic a, b, y; // Inputs and output of the AND gate
endinterface
uC
// Basic AND gate module
module and_gate(input logic a, b, output logic y);
assign y = a & b; // AND gate logic
endmodule
Vt

// Testbench using interface with assertions


module testbench;
// Declare the interface instance
logic_if logic_if_inst(clk);

// Instantiate the AND gate


and_gate uut (
.a(logic_if_inst.a),
.b(logic_if_inst.b),
.y(logic_if_inst.y)
);

// Clock generation

ud
always begin
#5 logic_if_inst.clk = ~logic_if_inst.clk; // Clock toggles every 5 time units
end

// Define a property for checking AND gate behavior


property and_gate_check;
lo
@(posedge clk) disable iff (logic_if_inst.a === 1'bz || logic_if_inst.b === 1'bz)
(logic_if_inst.y == (logic_if_inst.a & logic_if_inst.b)); // Check AND logic
endproperty

// Assertion to check the AND gate logic


uC
assert and_gate_check else $fatal("AND gate logic assertion failed!");

// Initial block to apply test vectors


initial begin
logic_if_inst.clk = 0; // Initialize clock
logic_if_inst.a = 0; // Initialize input a
Vt

logic_if_inst.b = 0; // Initialize input b

// Apply test vectors


#10 logic_if_inst.a = 1; logic_if_inst.b = 1; // Test case 1: a=1, b=1
#10 logic_if_inst.a = 0; logic_if_inst.b = 1; // Test case 2: a=0, b=1
#10 logic_if_inst.a = 1; logic_if_inst.b = 0; // Test case 3: a=1, b=0
#10 logic_if_inst.a = 0; logic_if_inst.b = 0; // Test case 4: a=0, b=0
#10 $finish; // End simulation
end
endmodule

Explanation:
1. Interface Definition (logic_if):

ud
o The interface logic_if includes the signals for the inputs a and b,
and the output y (which represents the output of the AND gate). It
also includes the clock clk to synchronize the operation.
2. AND Gate Module (and_gate):
o The and_gate module performs the AND operation on inputs a and
b, and drives the output y with the result of a & b.
3. Testbench (testbench):
lo
o The testbench instantiates the interface (logic_if_inst) and the
and_gate module (uut).
o It generates a clock signal (clk) with a period of 10 time units
(toggling every 5 units).
uC
o Assertion (and_gate_check): This assertion checks that, on each
positive edge of the clock, the output y of the AND gate matches
the logical AND of inputs a and b. If a or b is in high-impedance
(z) state, the assertion is disabled using disable iff.
4. Testbench Operation:
o The initial block applies a sequence of test vectors to a and b,
ensuring different combinations of a and b are tested.
Vt

o The simulation will check if the AND gate behaves as expected,


and the assertion ensures this by comparing the output y to a & b.
If the assertion fails, the simulation will print a fatal error message
and stop.
9. Discuss stimulus timing and its importance in System Verilog
testbenches.
In SystemVerilog testbenches, stimulus timing is crucial for ensuring that the
testbench and the design under test (DUT) interact in a synchronized and
predictable manner. The timing between the design and the testbench must be
managed carefully to avoid race conditions, ensure correct sampling of signals,
and avoid mismatches between design and testbench events.

ud
1. Synchronizing with the Clock:
o The testbench must drive signals at the correct time (after the clock
edge) and sample outputs just before the next clock edge.
Misaligned timing can lead to incorrect results.
o Clocking blocks ensure signals are driven and sampled
synchronously with the clock, avoiding timing mismatches and
race conditions.

o
lo
2. Race Conditions:
Race conditions occur if the testbench and design drive or sample
signals at the same time. Nonblocking assignments in
SystemVerilog help mitigate these issues, ensuring the last driven
value is sampled correctly.
uC
3. Clocking Block for Synchronization:
o A clocking block defines the timing for synchronous signals,
ensuring proper interaction between the testbench and design. It
also supports clock skew, adjusting signal timing without causing
mismatches.
4. Program Blocks and Simulation Regions:
o Program blocks separate testbench events from design events. The
Vt

Reactive region handles testbench execution, while the Postponed


region samples design outputs after the design has completed,
avoiding premature sampling and race conditions.
5. Avoiding Non-determinism:
o Using delays like #0 or #1 can lead to unpredictable results. Proper
use of clocking and program blocks ensures stable, deterministic
behavior by clearly defining timing between testbench and design
events.
10. Explain with examples the various system verilog assertions. (or)
Discuss the role of assertions in SystemVerilog. Provide examples of
immediate and concurrent assertions.
SystemVerilog assertions are used to verify the behavior of a design over time,
checking conditions on signals and variables within the design or testbench.

ud
Assertions in SystemVerilog play a critical role in verifying the correctness of
designs and simplifying the verification process. Here are their key roles:
1. Behavior Verification: Assertions check if signals meet expected
conditions at specific times, ensuring the design behaves as required.
2. Simplifying Testbenches: Assertions provide a concise, declarative way
to specify conditions, reducing the need for complex procedural code like
if statements.
lo
3. Immediate Assertions: These verify conditions at a specific moment,
ensuring correct signal values or relationships at that point.
4. Concurrent Assertions: They continuously monitor conditions over
time, useful for checking signal sequences or timing constraints across
multiple cycles.
5. Error Detection: Assertions automatically detect errors during
uC
simulation, reporting failures with details like offending signals and
failure times.
6. Functional Coverage: Assertions help gather coverage data by tracking
which conditions pass or fail, ensuring comprehensive verification.
7. Protocol Checking: Assertions can be embedded in interfaces to check
protocol compliance between modules, ensuring correct signal
interactions.
Vt

8. Improved Readability: Assertions enhance the readability and


maintainability of verification code, making it easier for teams to
understand and maintain.
Overall, assertions automate verification, improve design reliability, and help
detect issues early in the simulation.
There are two main types of assertions: immediate assertions and concurrent
assertions. Both types help ensure correctness, but they are used in different
contexts.
1. Immediate Assertions
Immediate assertions are executed at the exact point where they are
encountered, typically during a specific time step in the simulation. They check
for conditions on signals and take actions immediately if the condition is not
met.
Example:

ud
// Assert that the 'grant' signal equals 2'b01 after 2 cycles of the clock
bus.cb.request <= 1;
repeat (2) @bus.cb; // Wait for 2 cycles
a1: assert (bus.cb.grant == 2'b01); // Immediate assertion
If the condition is not met, an error is displayed:
Error: "test.sv", 7: top.t1.a1: failed at 55ns
lo
Offending expression: (bus.cb.grant == 2'b01)
Customizing Assertion Actions:
You can add then and else clauses to customize the response when an assertion
passes or fails:
a1: assert (bus.cb.grant == 2'b01)
uC
else $error("Grant not asserted");
This generates a custom error message if the assertion fails:
Error: "test.sv", 7: top.t1.a1: at time 55 ns
Grant not asserted
2. Concurrent Assertions
Vt

Concurrent assertions are used to continuously monitor the design's signals over
time. They check conditions at specific times (e.g., on the rising edge of a
clock) throughout the simulation.
Example:
interface arb_if (input bit clk);
logic [1:0] grant, request;
logic rst;
// Property to check for X/Z values in the request signal
property request_2state;
@(posedge clk) disable iff (rst)
$isunknown(request) == 0; // Ensure no X or Z values in request
endproperty

ud
// Assert the property
assert_request_2state: assert property (request_2state);
endinterface
In this example, the assertion checks that the request signal never has X or Z
values unless the reset (rst) signal is active.
lo
MODULE 5
1. What is randomization in SystemVerilog?
Randomization in SystemVerilog is a process used to generate random stimuli
uC
for testing designs, especially when combined with Object-Oriented
Programming (OOP). It involves creating classes to hold groups of related
variables, which can then be randomized using SystemVerilog's randomization
features.

2. List the various random number functions and explain them in brief.
Vt

Random Number Functions in SystemVerilog


SystemVerilog provides several built-in functions to generate random numbers,
which are useful for creating randomized test scenarios in simulations. Here is a
list of the various random number functions, along with brief explanations:
1. $random:
o Generates a random signed 32-bit number with a flat distribution.
o It produces values from the full signed range of 32 bits.
2. $urandom:
o Generates a random unsigned 32-bit number with a flat
distribution.
o The range of values is from 0 to 2^32 - 1.
3. $urandom_range:
o Returns a random unsigned value within a specified range.

ud
o You can specify a low and high value for the random number, and
it will pick a value between these two bounds.
o Example: $urandom_range(3, 10) will return a value between 3
and 10.
4. $dist_exponential:
o Generates a random number following an exponential decay

o
lo
distribution.
This is useful when modeling behaviors such as time decay.
5. $dist_normal:
o Generates a random number following a normal (Gaussian)
distribution.
uC
o This is a bell-shaped distribution centered around a mean value.
6. $dist_poisson:
o Generates random numbers following a Poisson distribution.
o This is often used in scenarios where events occur at a constant rate
over time, such as packet arrival in networking simulations.
7. $dist_uniform:
Vt

o Generates a random number with a flat uniform distribution.


o The values are equally distributed across the specified range,
making it suitable for simulations where no bias is desired.

3. Write about the common randomization problems in system verilog.


Randomization in SystemVerilog can present several challenges. Below are
some common issues you may encounter when creating random stimulus:
1. Use Signed Variables with Care
When using signed variables (like int or byte) in random constraints, be
cautious. Signed variables may produce unexpected values, especially in
constraints. For instance, if you define two signed random variables
(pkt1_len and pkt2_len) to sum to 64, you could end up with negative
values like (-63, 127) due to the signed nature of the variables.
o Solution: Use unsigned variables to avoid negative values and

ud
unexpected results. Alternatively, make the variables as narrow as
possible, like using 8-bit unsigned types instead of 32-bit.
Example:
class Vars32;
rand bit [31:0] pkt1_len, pkt2_len;
constraint total_len { pkt1_len + pkt2_len == 64; }
endclass lo
This could still cause overflow, so it’s better to use narrower variable widths.
2. Solver Performance Tips
The randomization solver can be slow if you have complex constraints.
Avoid using expensive operators such as division, multiplication, or
modulus (%) in constraints. These operations are computationally
uC
intensive and can slow down the randomization process.
o Solution: Use shift operators (left or right) instead of
multiplication or division by powers of 2. Also, replace modulus
with bitwise AND operations when working with powers of 2.
Example of replacing modulus:
// Instead of using modulus operator
value % 8;
Vt

// Use bitwise AND


value & 7;

By understanding and avoiding these common issues, you can effectively use
randomization in your SystemVerilog testbenches and improve simulation
performance.
4. Explain how random number generators can be used for generating
constrained inputs.
In SystemVerilog, random number generators (RNGs) can be used to create
constrained inputs for testing, but it is essential to ensure that the generated
values comply with the specific conditions or constraints you define. Here's how
they can be used:
1. Signed Variables and Constrained Randomization

ud
When using random number generators with signed variables, be cautious
because they may generate unexpected results due to the sign bit. For
instance, randomizing signed variables like int or byte can produce
negative values, which may not be intended in certain scenarios. To avoid
this, it's advisable to use unsigned random variables.
o Example Problem: If the constraint is to make the sum of two
variables equal to 64, using signed variables could give invalid
results (e.g., negative lengths).
lo
o Solution: Use unsigned types like bit[31:0] instead of signed types,
and ensure constraints are applied correctly.
Example:
class Vars32;
uC
rand bit [31:0] pkt1_len, pkt2_len;
constraint total_len { pkt1_len + pkt2_len == 64; }
endclass

2. Width of Variables and Overflow


Another common issue arises when using large-width variables for
constraints that require smaller ranges. For example, using a 32-bit
variable for constraints that deal with values that do not require the full
Vt

32-bit width can lead to overflow or wrapping around.


o Solution: Minimize the width of variables according to the
requirement. If the sum of two variables must equal 64, it’s better
to use smaller bit-width variables like 8-bit instead of 32-bit.
Example:
class Vars8;
rand bit [7:0] pkt1_len, pkt2_len;
constraint total_len { pkt1_len + pkt2_len == 9'd64; }
endclass

3. Solver Performance Tips


The constraint solver in SystemVerilog can be slow, especially when
dealing with complex constraints involving large variables or expensive
operations like multiplication, division, or modulus. To improve
performance:
o Avoid using expensive operators (e.g., division or multiplication).

ud
o For powers of 2, use shift operators (left or right) rather than
multiplication or division.
o Replace modulus operations with bitwise AND operations for
power-of-2 values.
Example:
// Instead of using modulus operator
lo
value % 8;
// Use bitwise AND for faster performance
value & 7;

4. Array Constraints
When randomizing arrays, the foreach constraint and array functions
uC
can be used to control the distribution of array elements. However, be
aware that nested foreach constraints can significantly slow down the
simulation, especially with large arrays. Limiting array size or using
randc variables instead of nested foreach constraints can help.
o Example: To randomize an array with a constrained size, use the
size() function to specify the lower and upper bounds for the array
size.
Example:
Vt

class dyn_size;
rand logic [31:0] d[];
constraint d_size { d.size() inside {[1:10]}; }
endclass
5. Explain about the various random number generators in system verilog.
Various Random Number Generators in SystemVerilog
SystemVerilog provides a robust framework for random number generation,
which is essential for creating unpredictable input stimuli in testbenches. Here's
an overview of the different random number generators used in SystemVerilog:
1. Pseudorandom Number Generators (PRNGs)

ud
SystemVerilog uses pseudorandom number generators (PRNGs) to produce
random values, which are deterministic but appear random. These generators
are initialized with a seed value and can generate a series of random numbers
that are repeatable when the same seed is provided.
• Basic PRNG Structure: The basic SystemVerilog PRNG follows a
method where the internal state is squared to produce a 64-bit value, the
middle 32 bits are extracted, and the original state is added back.

lo
Example of PRNG Algorithm:
reg [31:0] state = 32'h12345678;
function logic [31:0] my_random;
logic [63:0] s64;
s64 = state * state; // Square the state
uC
state = (s64 >> 16) + state; // Update state with shifted bits
my_random = state; // Return the new random value
endfunction

This simple algorithm generates random numbers, and by reusing the seed, the
random sequence can be reproduced.
2. Multiple Generators
Vt

When you have multiple stimulus generators running in parallel within a


testbench, the use of a single PRNG for all generators can lead to issues. In a
scenario where multiple generators share the same PRNG, one generator might
consume more random values, affecting the randomness of the other generators.
This issue arises when there is a change in the number of random values
required by different objects.
• Example Problem: If one generator uses more random values due to
class changes, it could shift the sequence, affecting the other generators.
• Solution: In SystemVerilog, each object and thread is assigned its own
PRNG, ensuring that changes in one generator do not interfere with
others.
class Gen1;
Transaction tr1, tr2;
forever @(intl.cb) begin

ud
tr1.randomize();
tr2.randomize();
end
endclass

class Gen2;
Transaction tr1, tr2;
lo
forever @(int2.cb) begin
tr1.randomize();
tr2.randomize();
end
uC
endclass

This way, each generator (Gen1 and Gen2) gets its own random sequence.
3. Hierarchical Seeding
SystemVerilog introduces hierarchical seeding, where every object or thread
has its own PRNG that is seeded from its parent’s PRNG. This ensures that
different parts of the testbench can generate random values independently,
maintaining random stability across multiple threads or objects.
Vt

• Example of Hierarchical Seeding: The seed of the parent PRNG is


passed down to child PRNGs, allowing each object or thread to generate
its own unique sequence of random values based on the parent's seed.
• Issue with Debugging: If you modify the testbench (such as adding or
removing threads or objects), it might cause a change in the random
stimulus. To maintain the same random sequence during debugging, it's
essential to construct new objects or threads after existing ones,
preserving the consistency of the random streams as much as possible.
function void build();
pci_gen gen0, gen1;
gen0 = new();
gen1 = new();
fork
gen0.run();

ud
gen1.run();
join
endfunction

In this code, both gen0 and gen1 share the same hierarchical seeding, ensuring
they produce independent random values.
function void build();
lo
pci_gen gen0, gen1;
atm_gen agen;
gen0 = new();
gen1 = new();
agen = new(); // New generator after the previous ones
uC
fork
gen0.run();
gen1.run();
agen.run();
join
endfunction
Vt

By creating new objects (agen in this case) after the existing objects (gen0 and
gen1), the random sequences for the new generator are less likely to be affected
by previous changes in the testbench.
5. Explain coverage types with necessary example.
Coverage Types in SystemVerilog
Coverage is crucial for measuring the thoroughness of a verification process. It
helps ensure that the design has been adequately tested and that there are no
untested paths or conditions. SystemVerilog supports several types of coverage,
each focusing on different aspects of design verification.

ud
1. Code Coverage
Code coverage measures how thoroughly the design's implementation has been
exercised during simulation. It tracks which lines of code, paths, expressions,
toggle states, and FSM (Finite State Machine) states have been executed. While
code coverage gives an indication of how much of the code has been tested, it
does not ensure that all functional requirements are met.
• Types of Code Coverage:
o

o
lo
Line Coverage: Measures how many lines of code have been
executed.
Path Coverage: Tracks the different paths through the code.
Toggle Coverage: Measures how many times each bit in a variable
has toggled between 0 and 1.
uC
o FSM Coverage: Tracks which states and transitions in a state
machine have been visited.
Example: In the following D-flip flop model, a reset path is missing. While
code coverage might show that all lines are executed, it will miss this functional
issue:
module dff(output logic q, reset);
input logic clk, d;
Vt

always @(posedge clk or negedge reset) begin


q <= d;
// Missing reset logic
end
endmodule
2. Functional Coverage
Functional coverage focuses on ensuring that the design behaves correctly
according to its specifications. It is tied to the design intent and verifies that all
functional scenarios outlined in the specification have been tested. This type of
coverage goes beyond just the code and checks whether the design performs as
expected under various conditions.
Example: For a D-flip flop, functional coverage would check not just data

ud
storage (i.e., holding the d input), but also whether the reset functionality works
as intended. Even if the code coverage shows all lines executed, functional
coverage can catch the missing reset logic.
3. Bug Rate
The bug rate is an indirect way of measuring progress in a verification project.
It tracks how frequently new bugs are found over time. Initially, there may be
many bugs found during the inspection and early simulation phases. As the
lo
design matures, the bug rate should decrease, with fewer issues being detected
as the design nears completion.
uC

4. Assertion Coverage
Assertions are used to verify that certain conditions hold true in the design
during simulation. Assertions can be used to check relationships between design
Vt

signals, such as ensuring two signals are mutually exclusive or that a request is
followed by a grant. They can be written using SystemVerilog Assertions (SYA)
or procedural code.
Types of Assertions:
• Cover Property: Used to track whether certain signal sequences or
conditions occur during the simulation.
• Cover Group: Captures data values or transactions and tracks their
occurrence.
Example:
assert property ( @(posedge clk) req |-> ##[1:5] gnt); // Request is followed by Grant
within 1 to 5 cycles
cover property ( @(posedge clk) req && gnt); // Tracks when both req and gnt occur
together

6. Explain the strategies for improving functional coverage during

ud
simulation. (or) Which are the various functional coverage strategies?
Explain them in detail.
To improve functional coverage during simulation, it's crucial to understand key
design features, corner cases, and failure modes. The following strategies, as
derived from the content, will guide you to effectively measure and enhance
functional coverage.
1. Gather Information, Not Data
lo
• Anticipate Key Design Features: Before starting the test code, it’s
important to focus on the key design features, potential corner cases, and
failure modes in your verification plan. The plan should not only focus on
data values but should consider the information encoded in the design
itself.
uC
• Example – FIFO: When verifying a FIFO (First-In-First-Out) memory,
testing every combination of values in the read and write indices could
result in millions of combinations. Instead, you should focus on testing
key states like Full and Empty, which represent the most critical
conditions for the FIFO. By ensuring the FIFO transitions from Empty to
Full and back, you can verify its functional behavior without covering
every possible value.
• Natural Divisions in Data: If your design includes large ranges (like a
Vt

32-bit address bus), it's unnecessary to test every possible value. Instead,
divide the range into meaningful groups, such as memory space and I/O
space, and focus on significant states. Similarly, for counters, focus on
specific values or behaviors (e.g., the rollover from all 1s to 0).
2. Only Measure What You Are Going to Use
• Control Coverage Data: Collecting functional coverage data can impact
simulation performance. Therefore, only measure what is necessary for
your analysis. If you are not planning to analyze certain parts of the
coverage data, there's no need to gather that information during
simulation.
• Control Overhead: You can control which coverage data is gathered by
using tools provided by your simulation vendor. You can use conditional
compilation or switch off unnecessary coverage collection, which reduces
simulation overhead. It's also possible to suppress the gathering of data
for certain areas of the design, although this is less desirable since it

ud
makes the report harder to interpret.
3. Measuring Completeness
• Track Progress Over Time: At the beginning of a project, both code and
functional coverage are typically low. As tests are repeatedly run with
different random seeds, the functional coverage should increase. Once
you no longer see significant increases, it’s time to develop new
constraints or tests to continue exploring new areas.

lo
Regression Testing: Save test combinations and seeds that result in high
coverage so they can be used in future regression testing. This ensures
you retain high coverage points and can easily detect regressions in
subsequent tests.

7. Explain how automated bin creation in SystemVerilog enhances the


uC
efficiency and accuracy of functional coverage analysis.
Automated bin creation in SystemVerilog enhances efficiency and accuracy in
functional coverage by automatically categorizing sampled values into bins and
tracking their occurrence during simulation.
• Coverpoints track specific values or expressions, and covergroups
group related coverpoints. When a covergroup is sampled, bins are
automatically created for each value (e.g., a port with 8 possible values
Vt

creates 8 bins).
• The coverage tool counts how many times each bin is hit and tracks
coverage goals (e.g., 100% coverage for all possible values).
Efficient Coverage Reporting
• Efficiency in Coverage Measurement: With automated bin creation, the
simulation tool organizes coverage data into bins based on predefined
criteria (e.g., possible values of a port variable). This reduces the
complexity of managing coverage data manually and ensures that all
important values are tracked.
• The tool automatically identifies which values have been tested (which
bins have been hit), so you don’t have to manually track the values,
speeding up the process of coverage analysis.
• Improvement Suggestions: If certain values are not covered (e.g., tr.port
value 0 in the first 32 random transactions), the tool suggests running

ud
more simulation cycles or using different random seeds to try new
combinations. For instance, after adding the 33rd transaction, tr.port may
take the missing value of 0, achieving 100% coverage.
Improved Accuracy
• Automatic Bin Tracking: With automated bins, the tool accurately tracks
which specific values or states have been covered during the simulation.
This ensures that all required test conditions are tested, and it helps


lo
identify any areas that are still untested.
Clear Coverage Reports: As seen in the reports, the tool provides detailed
information on which bins have been covered, how many hits each bin
received, and the expected coverage for each bin. This improves the
accuracy of the functional coverage analysis, ensuring no critical states
are missed.
uC
8. Illustrate the use of a cover group with a practical example.
Practical Example: Transaction-based Coverage with a Cover Group
In this example, we will track the coverage of a transaction's port field using a
cover group in SystemVerilog.
class Transaction;
Vt

rand bit [31:0] data; // Random data


rand bit [2:0] port; // Port field
endclass

class Transactor;
Transaction tr;
mailbox mbx_in;
// Define a cover group to track port values
covergroup CovPort;
coverpoint tr.port; // Coverpoint for the 'port' field in Transaction
endgroup

ud
function new(mailbox mbx_in);
CovPort = new(); // Instantiate the cover group
this.mbx_in = mbx_in;
endfunction

task main;
forever begin
lo
tr = mbx_in.get; // Get a transaction from the mailbox
ifc.cb.port <= tr.port; // Send 'port' value to the DUT (Device Under Test)
ifc.cb.data <= tr.data; // Send 'data' value to the DUT
CovPort.sample(); // Trigger the cover group to sample the port value
uC
end
endtask
endclass

Coverage Report:
At the end of the simulation, a coverage report will be generated showing the
values that the port field took during the simulation, indicating which values
were exercised and which were missed. This helps to ensure that all possible
Vt

transaction scenarios involving the port field are tested.


Use:
The primary use of this cover group is to monitor how thoroughly the port field
of the Transaction class is exercised in the simulation, ensuring complete
functional coverage for that part of the design. If a value of port is never
sampled during the test, the coverage report will highlight it, prompting the
need for additional tests or stimulus to cover that case.
9. Explain how cross-coverage enhances the verification process.
Cross-coverage enhances the verification process by tracking and ensuring the
simultaneous occurrence of values from two or more cover points, which helps
in verifying all possible combinations of these variables. It allows for more
detailed analysis by covering interactions between different system components
or signals, ensuring that no unintended or untested scenarios are overlooked.
For example, in a transaction system, if you have cover points for transaction

ud
type and port number, cross-coverage will track all combinations of transaction
types across different ports. This guarantees that every possible interaction
between the two cover points is tested.
By measuring the interactions between multiple cover points, cross-coverage
helps in:
1. Identifying Corner Cases: It ensures combinations of variables that
might be rare or edge cases are covered.
lo
2. Thorough Testing: It enables testing of interactions between signals or
components that might otherwise be missed if only individual cover
points were tracked.
3. Improved Test Quality: By verifying all possible combinations, cross-
coverage ensures that the design behaves correctly across all scenarios,
leading to a more robust and reliable verification process.
uC
In essence, cross-coverage extends the verification coverage, making it more
comprehensive and efficient, thereby improving the quality of the verification
process.

10. Write a short note on measuring coverage statistics during simulation


Measuring Coverage Statistics During Simulation
Vt

Measuring coverage statistics during simulation is crucial for tracking the


progress of functional coverage and ensuring that the verification goals are met.
SystemVerilog provides various methods to query coverage dynamically as the
simulation progresses, allowing for better control and decision-making.
At the global level, the $get_coverage system task can be used to retrieve the
total coverage across all cover groups, returning a value between 0 and 100.
This helps in assessing the overall coverage during simulation.
For more specific analysis, you can use methods like get_coverage() and
get_inst_coverage(). The get_coverage() method gives coverage across all
instances of a cover group, while get_inst_coverage() provides coverage
statistics for a specific instance of a cover group. These functions allow for
more targeted coverage tracking, especially when monitoring long-running
simulations.
Monitoring coverage during a test is beneficial for adjusting the test strategy. If

ud
the coverage level stalls after a certain number of transactions or cycles, the test
can be stopped or modified, such as by changing the random seed or generating
different stimulus. This helps in maximizing coverage over multiple simulation
runs.
In more advanced setups, verification teams can create custom coverage
databases, feeding simulation data into tools like SQL for further analysis.
Although more complex, this provides greater flexibility and control over
coverage tracking.
lo
Overall, measuring coverage statistics during simulation helps ensure the
thoroughness of testing, optimize test strategies, and make informed decisions
based on real-time data.
uC
Vt

You might also like