21EC71-MQP-SOLUTIONS
21EC71-MQP-SOLUTIONS
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)
Maximum Balanced
Performance Lower than custom, but
optimization for optimization, less
Optimization can be tuned
power, speed, area than full custom
be changed changes
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
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
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
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.
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
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
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:
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.
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].
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.
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.
Cycle 1:
Q0Q−1=00, so we do nothing (no addition/subtraction).
ud
•
Cycle 3:
•
o
lo
New value of A, Q, Q−1=0001,1100,0→0011, 1000, 0.
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.
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
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.
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.
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
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
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
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
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
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.
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
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.
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)
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.
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.
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.
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.
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
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.
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
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
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
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
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
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]
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
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
• 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;
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
ud
parameter OPSIZE = 8;
typedef reg [OPSIZE-1:0] opreg_t;
opreg_t op_a, op_b; // Declares two variables of type opreg_t
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
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
ud
endtask
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
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
while (j--);
$display("Sum=%4d", sum);
end : example
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
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
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 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
Example:
typedef int fixed_arrayS[5]; // Define the array type
fixed_arrayS fS; // Declare an array variable
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
initial begin
init(fa, 5); // Pass the array by reference
foreach (fa[i])
Vt
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
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
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;
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
ud
module test (arb_if.TEST arbif); // Testbench uses the TEST modport
// Testbench logic
endmodule
// Clock generation
ud
always begin
#5 logic_if_inst.clk = ~logic_if_inst.clk; // Clock toggles every 5 time units
end
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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.
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