SlideShare a Scribd company logo
Advances inVerification
Methodologies
Workshop at BMS college – June 2016
As part ofTEQIP
6/17/2016www.verificationexcellence.in 1
Verification with System
Verilog
Ramdas M
ExperiencedVerification Engineer, Applied Micro
17+ years experience, Author, OnlineTeacher, Blogger
6/17/2016www.verificationexcellence.in 2
Introduction - Instructor
▪ ExperiencedVerification Engineer with 17 years of experience
▪ Applied Micro, Intel, IBM, C-DOT
▪ OnlineTeacher
▪ www.verificationexcellence.in
▪ FREE online courses on SystemVerilog, Assertions, Coverage,
UVM
▪ Author
▪ Cracking Digital VLSIVerification Interviews: Interview
Success
▪ Quora Blogger
▪ 200+ answers and 5 blogs, Most viewed writer inVLSI topics
6/17/2016www.verificationexcellence.in 3
Agenda – Day 1
▪ Day 1 - Morning ( 9 - 11)
▪ Introduction to SV - 10 mins
▪ Building blocks - 30 mins
▪ Language constructs -50
mins
▪ Exercise/Quiz/Q&A - 30
mins
6/17/2016www.verificationexcellence.in 4
▪ Day 1 - Morning ( 11.15 - 1)
▪ Threads and Inter process
communication
▪ Exercises/Quiz/Q& A
▪ Day 1 – Noon (2-4)
▪ SystemVerilog Classes
▪ Exercises/Quiz/Q& A
Agenda – Day 2
▪ Day 2 - Morning ( 9 - 11)
▪ Interfaces/Virtual Interfaces
▪ Randomization and
Constraints
▪ Exercise/Quiz/Q&A
6/17/2016www.verificationexcellence.in 5
▪ Day 2 -Noon ( 2-4)
▪ Lab Exercises
Introduction to
SystemVerilog
Ramdas M
6/17/2016www.verificationexcellence.in 6
What is SystemVerilog
▪ SystemVerilog is a combined hardware description language
and hardware verification language
▪ SystemVerilog is an extensive set of enhancements to IEEE
1364Verilog-2001 standards
▪ It has features inherited fromVerilog HDL,VHDL,C,C++
6/17/2016 www.verificationexcellence.in 7
History and evolution of SV
▪ Verilog (IEEE standard 1364)
▪ Began in 1983 as a proprietary language
▪ Opened to the public in 1992
▪ Became an IEEE standard in 1995 (updated in 2001 and 2005)
▪ Between 1983 and 2005 design sizes increased dramatically!
▪ SystemVerilog (IEEE standard 1800)
▪ Originally intended to be the 2005 update toVerilog
▪ Contains hundreds of enhancements and extensions toVerilog
▪ Published in 2005 as a separate document
▪ Officially supersededVerilog in 2009
▪ Updated with more features in 2012 (IEEE 1800 2012 standard)
6/17/2016 www.verificationexcellence.in 8
SystemVerilog – UserView
▪ SVD -SystemVerilog for Design
▪ Features supporting Design
▪ SVTB – SystemVerilog forTest benches
▪ Test bench specific Features
▪ SVA – SystemVerilogAssertions
▪ Features for temporal and concurrent assertions
▪ SVDPI – SV Direct Programming Interface
▪ For better C/C++ integration
▪ SVAPI – SV Application Programming Interface
▪ For better Coverage/Assertion integration
6/17/2016 www.verificationexcellence.in
9
Verilog to SystemVerilog
6/17/2016www.verificationexcellence.in 10
What isVerification ?
▪ Process of demonstrating functional correctness of a
design.
6/17/2016 Verification with System Verilog 11
SystemVerilog forVerification
▪ Where do we really use SystemVerilog
Language inVerification ?
▪ Building Test bench components
▪ Stimulus generators, drivers
▪ Monitors, Checkers,Assertions
▪ Coverage
▪ Reference Models
▪ Test cases
6/17/2016www.verificationexcellence.in 12
A VerificationTest bench
6/17/2016www.verificationexcellence.in 13
Basic Building Blocks
Srividhya TP
6/17/2016www.verificationexcellence.in 14
Agenda
▪ What is coding for Design /Validation
▪ Delta overVerilog
▪ What should u Know in SystemVerilog
▪ UVM/System C
6/17/2016www.verificationexcellence.in 15
SystemVerilog Enhancements
▪ Goal
▪ Model More functionality in fewer lines of code
▪ Reduce redundancy
▪ Reduce risk of coding errors
6/17/2016www.verificationexcellence.in 16
How do u handle any HDL/Language
▪ U google 
▪ Design :Synthesizability
▪ What constructs are synthesizable
▪ What construct converts to what real logic?
▪ What are the diff optimized ways of coding?
▪ Coding for Performance, Power
▪ Macros that optimize place and route
▪ Latency, Different frequencies- FIFO Design, Standard library
components
▪ Coding for FPGAs, Silicon debug
▪ Documentation; Specification
▪ Project independence
6/17/2016www.verificationexcellence.in 17
Verification Mindset
▪ What is architecting forTestbench? Find Bugs known and unknown?
▪ How?
▪ Formal/ assertions
▪ Coverage
▪ How to eliminate Human dependency over generations
▪ What is a right construct?
▪ Simulation time..
▪ Hierarchy porting
▪ UVM – refer slide 9
▪ Error Scenarios
▪ Conferences
6/17/2016www.verificationexcellence.in 18
Common mistakes - Design
▪ Coding? Instead ofArchitecting -- Clarity
▪ IP based approach?
▪ Assumptions not coded?
▪ Latency unknown
▪ Scaleability
6/17/2016www.verificationexcellence.in 19
Common Mistakes -Verification
▪ Out of the Box thinking
▪ Architecting?
▪ Thinking Beyond the Spec
▪ Hard coding
▪ Scope for scalabilityTest /Testbench
▪ Human dependency
▪ EnhancingTB for feature is recoding/patching?
▪ Auto code generation
▪ TB randomness
6/17/2016www.verificationexcellence.in 20
Design/Verification Building blocks
▪ Modules
▪ Interfaces
▪ Subroutines (Tasks, Functions)
▪ Packages
▪ Configurations
▪ Hierarchy
6/17/2016www.verificationexcellence.in 21
Modules
▪ Basic building block for design/verification
▪ Ports with declarations (input, output )
▪ Data declarations – nets, variables, structures
▪ Constants, user defined types
▪ Class definitions
▪ Import from packages
▪ Sub routine definition
▪ Instantiation of other modules, interfaces,
▪ Instantiation of class objects
▪ Continuous assignments
6/17/2016www.verificationexcellence.in 22
Module example
6/17/2016www.verificationexcellence.in 23
Module Instance and Port
connections
▪ InVerilog, port connections must be named
▪ Very verbose and redundant info
▪ SV adds .name and .* shortcuts
▪ .name connects a port to a net of same name
▪ .* automatically connects all ports and nets with same name
6/17/2016www.verificationexcellence.in 24
Interfaces
▪ A named bundle of nets or variables
▪ Encapsulates communication between blocks
▪ Connectivity - Port list and signals
▪ Functionality – Functions and tasks
▪ An instantiation of interface can be used to connect
between multiple modules.
▪ A single name can replace a list of port
6/17/2016www.verificationexcellence.in 25
Interface example
▪ How do we abstract signal between two design blocks
like below?
6/17/2016www.verificationexcellence.in 26
Interface Example
▪ Advantages
▪ Simplifies complex bus definitions and interconnections
▪ Ensures consistency through out design and verification
blocks
6/17/2016www.verificationexcellence.in 27
Interface - Another Example
6/17/2016www.verificationexcellence.in 28
Interface Example
6/17/2016www.verificationexcellence.in 29
Tasks and Functions - Usage
▪ Tasks
▪ Tasks can enable other tasks and functions
▪ Tasks may execute in non-zero simulation time.
▪ Tasks may have zero or more arguments of type
input, output and inout.
6/17/2016www.verificationexcellence.in 30
Synthesizable Variable types
▪ New useful synthesizable types
▪ logic - 4 state variable, user defined size (replaces reg)
▪ reg doesn’t always infer register
▪ Use of logic makes less confusion s in code
▪ enum – variable with specified set of legal values
▪ int - 32 bit 2 state variable ( can replace integer in for loops)
▪ Avoid using 2 state variables in synthesizable code
6/17/2016www.verificationexcellence.in 31
Simplified port type rules
▪ Traditional verilog has strict and confusing port type rules
▪ Inputs must be declared wire
▪ Outputs must be
▪ reg if driven from procedural statement
▪ wire if driven by continuous statement
▪ wire if connected to module instances
▪ SystemVerilog makes it easy
▪ Declare all as logic
6/17/2016www.verificationexcellence.in 32
Tasks and Functions - Usage
▪ Functions
▪ Function can enable other functions only. Task
cannot be called from functions.
▪ Functions should execute in zero simulation time.
▪ Functions have only one return value but System
Verilog also allows functions to have input, output or
inout types.
▪
6/17/2016www.verificationexcellence.in 33
Tasks
6/17/2016www.verificationexcellence.in 34
Functions
6/17/2016www.verificationexcellence.in 35
Argument passing
▪ Pass by value
▪ Each argument is copied to the subroutine area
6/17/2016www.verificationexcellence.in 36
▪ Pass by reference
▪ A reference to the original argument is passed instead of
copying
Packages
▪ Provides a declaration space that can be shared by
building blocks
▪ Supports declaration of nets, variables, tasks,
functions, classes, parameters etc
▪ Declarations can be imported to other building blocks
by importing package
6/17/2016www.verificationexcellence.in 37
Package: Example
6/17/2016www.verificationexcellence.in 38
Package: Example
6/17/2016www.verificationexcellence.in 39
Structure of a Design or Test bench code
6/17/2016www.verificationexcellence.in 40
Packages
Module/Program
always blocks/initial
blocks/processes
Parameters/defines, type defines, structs
etc useful across files
•Contains declarations
•functions/tasks, data types, objects etc
•Contains concurrent processes/blocks
•module instance, continuous assign,
always blocks etc
•Contains sequential code
•If then else, case etc -> control constructs
•Repeat/for loops/do..while -> loops
•Blocking/non-blocking assignments etc
Language Constructs
-DataTypes
Ramdas M
6/17/2016www.verificationexcellence.in 41
Data Types
▪ Nets
▪ Can be written by one or more continuous
assignments
▪ No procedural assignment allowed
▪ Used to model physical connections (e.g. wires)
▪ Multiple drivers will result in a value based on net
type
6/17/2016www.verificationexcellence.in 42
Data Types
▪ Variables
▪ Can be written by one or more procedural assignments
▪ Or can be written by “one” continuous assignment
▪ Last write determines the value
▪ Normally declared as
▪ <data type> instance
▪ E.g. logic abc;
▪ e.g. int value;
▪ 2 state vs. 4 state variables
▪ Values = 0, 1, x and Z
6/17/2016www.verificationexcellence.in 43
DataTypes
▪ 2 valued data types
▪ bit (1 bit)
▪ byte (8bits)
▪ shortint (16 bit)
▪ int (32 bits)
▪ 4 valued data types
▪ logic (1bit)
▪ integer (32 bit)
▪ Time (64 bit)
6/17/2016www.verificationexcellence.in 44
Integer DataType
6/17/2016www.verificationexcellence.in 45
Signed/UnsignedTypes
▪ byte, shortint, int, integer and longint defaults to signed
▪ Use unsigned to represent unsigned integer value
▪ time, bit, reg and logic defaults to unsigned
▪ Use signed to represent signed values
▪ Signedness can be explicitly defined as follows:
6/17/2016www.verificationexcellence.in 46
Vectors
▪ Vectors are packed array of scalars
▪ Both MSB and LSB needs to be constant integer expressions
▪ Cannot be x (unknown) or z( high impedance)
6/17/2016www.verificationexcellence.in 47
Strings
6/17/2016www.verificationexcellence.in 48
• String – ordered collection of characters
• If not initialized defaults to empty string - “ “
Strings - operators
6/17/2016www.verificationexcellence.in 49
Str1 == Str2 Equality
Str1 != Str2 Inequality
<, <=, >, >= Comparison
{Str1, Str2, … Strn} Concatenation
Str1[index] indexing – return 0 if out
of range
String Methods
6/17/2016www.verificationexcellence.in 50
• len
• putc
• getc
• toupper
• tolower
• compare
• icompare
• substr
• atoi, atohex,
atoct, atobin
• atoreal
• itoa
• hextoa
• octtoa
• bintoa
• realtoa
User defined types
▪ A typedef can be used to give a user defined name to an
existing type
6/17/2016www.verificationexcellence.in 51
EnumeratedTypes
▪ An enumerated type defines a set of named values.
▪ Defaults to “int” if data type declaration missing
6/17/2016www.verificationexcellence.in 52
Defining new data types as enums
▪ A type name can be given to a enumerated type to create a
new data type
▪ Ranges in elements
▪ Creates 5 elements sub0, sub1, sub2, sub3, sub4 and 3
elements jmp6, jmp7, jmp8
6/17/2016www.verificationexcellence.in 53
Other data types
▪ void data type represents nonexistent data. Usually
used for functions with no return values
▪ chandle data type represents storage for pointers
passed using DPI
▪ class - A variable that can hold handle to a class
object
▪ event – Provides a way of synchronization of two ore
more concurrently active process
▪ Constant data types - parameters (evaluated
elaboration time) and const (set during simulation)
6/17/2016www.verificationexcellence.in 54
Other data types
▪ Aggregate Data types (Will explain in later section)
▪ Structures
▪ Unions
▪ Arrays
▪ Dynamic , Associative arrays
▪ Queues
6/17/2016www.verificationexcellence.in 55
Operators and
Expressions
Ramdas
6/17/2016www.verificationexcellence.in 56
Operators
6/17/2016www.verificationexcellence.in
57
Operators
6/17/2016www.verificationexcellence.in 58
Operators
6/17/2016www.verificationexcellence.in 59
Operators
▪ Similar to other languages
▪ For more specifics refer to LRM Chapter 11
▪ As this needs to be used as a reference
6/17/2016www.verificationexcellence.in 60
Loops and Flow
control
Ramdas
6/17/2016www.verificationexcellence.in 61
Loops and Flow Control
▪ If-else-if
▪ case/casex/casez
▪ forever
▪ repeat
▪ while
▪ do..while
▪ foreach
6/17/2016www.verificationexcellence.in 62
Examples - Loops
6/17/2016www.verificationexcellence.in 63
for (int i; i < arr.size();
j+=2, i++) begin
arr[i] += 200;
arr[i]--;
end
1)x = 0;
while (x) begin
$display(“%d”, x);
x--;
end
2) do
begin
$display(“%d”, x);
x--;
end
while (x);
forever
▪ Continuous execution, without end
▪ Used with timing controls
▪ Usually last statement in some block
initial : clock_drive
begin
clk = 1’b0;
forever #10 clk = ~clk;
end : clock_drive
6/17/2016www.verificationexcellence.in 64
repeat
▪ Repeat a block ‘x’ times, no conditional test
▪ repeat (expr) statement
▪ Example
x = 0;
repeat (16)
begin
$display(“%d”, x++);
end
6/17/2016www.verificationexcellence.in 65
case/casez/casex
▪ case:
▪ 4-value exact matching.
▪ No don’t cares allowed
6/17/2016www.verificationexcellence.in 66
case/casez/casex
▪ casez/casex:
▪ Allows don’t care to be specified
▪ Useful for priority decoders
▪ casez will handle z as don’t care
▪ casex will handle both z and x as don’t care
▪ Not so commonly used in verification/testbench
6/17/2016www.verificationexcellence.in 67
Arrays
6/17/2016www.verificationexcellence.in 68
Fixed Size Arrays
Declaring fixed-size arrays
▪ int values[0:15]; // 16 ints [0]..[15]
▪ int styles[16]; // 16 ints [0]..[15]
Multi Dimensional
▪ int memarray [0:7][0:3]; //Verbose declaration
▪ memarray[7][3] = 1; // Set last array element
▪ int testarray [8][4]; // Compact declaration
6/17/2016www.verificationexcellence.in 69
Packed Arrays
▪ An array that represents a contiguous set of bits
▪ Can access subfields of array as elements
▪ Can be made of only single bit data types – bit, logic,
reg or enumerated types
▪ E.g.: bit [7:0] data //packed array of 8 bits
6/17/2016www.verificationexcellence.in 70
Unpacked Arrays
▪ Unpacked arrays need not be set as contiguous bits in
memory
▪ real latency [7:0]; // unpacked array of real types
▪ Unpacked arrays can be made of any data types
▪ Class record_c;
▪ record_c table[7:0] // unpacked array of objects
6/17/2016www.verificationexcellence.in 71
Packed and Unpacked Arrays
6/17/2016 www.verificationexcellence.in 72
Dynamic Arrays
▪ An array whose size can be changed at run time
▪ Uninitialized size will be zero
6/17/2016www.verificationexcellence.in 73
Dynamic Arrays
6/17/2016www.verificationexcellence.in 74
Dynamic Array - Methods
6/17/2016www.verificationexcellence.in 75
function int size() Returns the current size of the array
int addr[ ] = new[256];
int j = addr.size(); // j = 256
function void delete() Empties array contents and zero-sizes it
int addr[ ] = new[256];
addr.delete();
Resizing
<array> = new[<size>](<src_array>);
dyn= new[j * 2](fix);
ArrayAssignments
6/17/2016www.verificationexcellence.in 76
Associative Arrays
6/17/2016www.verificationexcellence.in 77
• Associative arrays are used when the size of the
array is not known or the data is sparse.
• Syntax:
data_type array_name [index_type];
Associative Array Methods
Function Use
num() / size() Returns number of entries
delete(<index>) Index for delete optional. When
specified used to delete given index
else whole array.
exists (<index>) Returns 1 if element exists at index
else 0
first (<index>), last (<index>) assigns to the given index variable the
value of the first/last (smallest/largest)
index in the associative array.
It returns 0 if the array is empty, and 1
otherwise.
next (<index>), prev (<index>) finds the entry whose index is
greater/smaller than the given index.
6/17/2016www.verificationexcellence.in 78
Example : Printing an associative
array
6/17/2016www.verificationexcellence.in 79
Queues
▪ A queue is a variable size, ordered collection of
homogeneous elements
▪ Can grow or shrink in size
▪ Few examples
6/17/2016www.verificationexcellence.in 80
Queue Operators
▪ Q[ a : b ] yields a queue with b - a + 1 elements.
▪ If a > b , resultant queue will be an empty queue
▪ If a = b, resultant queue will be a single element queue
▪ If either a or b are 4-state expressions containing X or Z
values, it yields the empty queue {}.
▪ Q[ a : b ] where a < 0 is the same as Q[ 0 : b ].
▪ Q[ a : b ] where b > $ is the same as Q[ a : $ ].
6/17/2016www.verificationexcellence.in 81
Queue Methods
6/17/2016www.verificationexcellence.in 82
Queue Methods
6/17/2016www.verificationexcellence.in 83
Queues - Examples
item = q1[0]; // read leftmost ( first ) item from list
item = q1[$]; // read rightmost ( last ) item from list
n = q1.size; // determine number of items on q1
q1 = q1[1:$]; // delete leftmost ( first ) item of q1
q1 = q1[0:$-1]; // delete rightmost ( last ) item of q1
for (int i=0; i < q1.size; i++) // step through a list using integers
begin … end
q1 = { }; // clear the q1 list
6/17/2016www.verificationexcellence.in 84
Array locator methods
▪ Methods that allow searching through an array including
queues
▪ Returns a queue of matching entries
6/17/2016www.verificationexcellence.in 85
Array locator methods
6/17/2016www.verificationexcellence.in 86
Array locator - Examples
6/17/2016www.verificationexcellence.in 87
Array Ordering Methods
▪ reverse() reverses the order of the elements in the
array
▪ sort() sorts the array in ascending order
▪ rsort() sorts the array in descending order
▪ shuffle() randomizes the order of the elements in the
array
6/17/2016www.verificationexcellence.in 88
Array Ordering Methods -
Examples
6/17/2016www.verificationexcellence.in 89
Exercises
6/17/2016www.verificationexcellence.in 90
Process and Inter
Process Communication
Ramdas
6/17/2016www.verificationexcellence.in 91
Sequential vs Concurrent Blocks
▪ Sequential Block:
▪ A block of statements executed
in a sequential order
▪ It finishes the current
statement, then begins the next
▪ You always know the order in
which it actually executes the
statements
▪ The simulator exits the block
after finishing the last
statement
• Concurrent Block
– A block of statement(s) executed
concurrently (parallel) by a
simulator.
– It starts executing all statements
simultaneously
– You cannot know the order in
which it actually executes
statements scheduled for the same
simulation time
– The simulator exits the block after
finishing the latest statement.
6/17/2016 92www.verificationexcellence.in
Examples
▪ Sequential block
▪ Concurrent block
▪ always procedures
▪ initial procedures
▪ final procedures
▪ fork..join blocks
6/17/2016www.verificationexcellence.in 93
initial procedure
▪ initial procedure executes only once
▪ It ends when the last statement finishes.
▪ Multiple initial procedures execute concurrently
6/17/2016www.verificationexcellence.in 94
final procedure
▪ Similar to initial procedure but executed at end of
simulation
▪ Unlike initial procedure, this executes in zero time
▪ No delays allowed
6/17/2016www.verificationexcellence.in 95
always procedure
▪ Four forms of always procedures supported
▪ always
▪ General purpose, needs a timing control
▪ always_comb
▪ Used for modelling combinational logic
▪ always_latch
▪ Used for modelling latched logic behavior
▪ always_ff
▪ Used to model synthesizable sequential logic behavior
6/17/2016www.verificationexcellence.in 96
Parallel Blocks
▪ Parallel blocks (Threads) are created via fork…join
▪ All threads execute concurrently
▪ Delay control for separate threads
▪ Highly useful to maximize stimulus interactions
6/17/2016www.verificationexcellence.in 97
Applications
▪ Testbenches need to model multiple concurrent
processes
▪ Providing inputs/stimulus to Design UnderTest
▪ Parallel stimulus on multiple interfaces
▪ Monitoring multiple inputs and outputs for
checking/logging
▪ Detecting timeout problems
6/17/2016www.verificationexcellence.in 98
fork
a;
b;
c;
join
join
fork
fork-join
6/17/2016www.verificationexcellence.in 99
fork
a;
b;
c;
join_any
fork
a;
b;
c;
join_none
Join_any
fork
Join_none
fork
fork-join_nonefork-join_any
Examples
6/17/2016www.verificationexcellence.in 100
Process Controls
▪ wait fork statement
▪ Blocks process execution flow until all immediate child
subprocesses completes
6/17/2016www.verificationexcellence.in 101
Process Controls
▪ disable fork statement
▪ Stops execution of all child sub processes
6/17/2016www.verificationexcellence.in 102
Mailboxes
▪ Mailbox is a communication mechanism that allows
messages to be exchanged between different processes.
▪ Data can be sent to a mailbox by one process and retrieved
by another
6/17/2016www.verificationexcellence.in 103
Mailbox Methods
6/17/2016 104
Method Use
new() Create a new mailbox.
put() Place a message in a mailbox.
get() Retrieve a message from mailbox.
try_get()/
try_peek()
Try to retrieve a message from the mailbox without
blocking.
try_put() Try to place a message in mailbox without blocking.
Useful only for bounded mailboxes.
peek() Copies a message from mailbox without actually
removing it.
www.verificationexcellence.in
MailboxTypes
▪ Unbounded Mailboxes
▪ No restrictions placed on size of mailbox
▪ put() will never block.
▪ Eg: mailbox m = new ();
▪ Bounded Mailboxes
▪ Number of entries is determined when the mailbox is
created.
▪ Bound value should be positive.
▪ put() will be blocked if the mailbox is full.
▪ Eg: mailbox m = new (5); // mailbox of depth = 5
6/17/2016www.verificationexcellence.in 105
Mail box Example
6/17/2016 106www.verificationexcellence.in
Mail box Example
6/17/2016 107
www.verificationexcellence.in
Events
▪ Events are constructs that allow hand shake
between two processes
▪ Triggered using -> operator.
▪ Triggering unblocks all waiting processes
▪ @ is used to wait for an event
6/17/2016www.verificationexcellence.in 108
Event - example
6/17/2016www.verificationexcellence.in 109
Event - example
6/17/2016www.verificationexcellence.in 110
EventVariables
6/17/2016 111
▪ Merging Events
▪ When one event variable
is assigned to another,
both merge into one
event variable.
▪ Executing -> on either one
of the events affects
processes waiting on
either event variable.
event a, b;
a = b;
-> a; // also triggers b
-> b; // also triggers a
www.verificationexcellence.in
Semaphores
▪ Semaphores are typically used for mutual exclusion, access
control to shared resources, and basic synchronization
▪ Can be described as counters used to control access to shared
resources by multiple processes [threads].
▪ e.g.: Multiple request drivers accessing a shared bus
▪ Implemented as a bucket with fixed number of keys
▪ Processes using semaphores must first procure a key before
executing
▪ All others must wait until a sufficient number of keys is returned
to the bucket.
6/17/2016www.verificationexcellence.in 112
Semaphore Methods
6/17/2016 113
▪ Semaphore provides following built-in methods:
Method Use
new() Create a semaphore with specified
number of keys.
put() Return one or more keys back.
get() Obtain one or more keys.
try_get() Try to get one or more keys without
blocking.
www.verificationexcellence.in
Semaphore example
6/17/2016 114www.verificationexcellence.in
SystemVerilog
Classes
Ramdas
6/17/2016www.verificationexcellence.in 115
What is OOP?
▪ OOP is object oriented programming
▪ Organize programs in same way as objects
are organized in real world
▪ Break programs in the same way
▪ Several Languages support OOP
▪ C++, Java, (SW) and System Verilog (HDL)
6/17/2016www.verificationexcellence.in 116
Class Basics
▪ A Class is a description of some group of
things that have something in common.
▪ Objects are individual instances of
“classes”.
▪ Example: A class might be “Automobile”.
Instances of the “Automobile” class
might be “Joe’s car”, “Bob’s car”, “Sally’s
truck”, etc.
6/17/2016Verification with System Verilog 117
Classes
▪ Inheritance: (is-a relationship)
▪ Allows users to extend existing classes
▪ Eg. Extending the “Automobile” class to create
subclasses for “car”, “truck”, “van”, etc.
▪ When using inheritance, the sub-class “inherits” all
the parents public/protected data properties and
methods.
6/17/2016www.verificationexcellence.in 118
Classes
▪ Composition: (has-a relationship)
▪ Composition is used for the case where one
object HAS-A instance of another class.
▪ For example, an “Automobile” class might
have 4 instances of a “wheel” class
6/17/2016www.verificationexcellence.in 119
Inheritance vs Composition
6/17/2016www.verificationexcellence.in 120
Class Definition
6/17/2016www.verificationexcellence.in 121
classname;
<data_declarations>;
<task/func_decls>;
endclass
Class Instantiation
▪ Objects created and
Initialized via call to the
new Constructor Method
▪ All objects have built-in
new method
▪ Allocates storage for all data
properties
▪ User-defined new method
can initialize and/or do
other things
6/17/2016
www.verificationexcellence.in
122
Class Inheritance
6/17/2016 www.verificationexcellence.in 123
Data Hiding and Encapsulation
Member type Properties
local • Can be accessed only within class
• Not visible in derived class
protected • Can be accessed only within class
• Visible in derived class
public • Can be accessed from class as well as outside
class using object reference
•Visible in derived class
6/17/2016www.verificationexcellence.in 124
Examples
6/17/2016www.verificationexcellence.in 125
Special handle - “this”
▪ Used to refer to current instance of this class
▪ Removes ambiguity as in below example.
▪ X is both a class member and argument to constructor
6/17/2016www.verificationexcellence.in 126
Static class properties
▪ Static properties/data members are “static” to all instances of
the class.
▪ Created only once and shared with all instances
▪ In above example, all instances of packet will share one value
for fileID.
6/17/2016www.verificationexcellence.in 127
Static class methods
▪ Can be called outside class without instantiation
▪ Cannot access non-static members
▪ Cannot access “this” handle
▪ Cannot be virtual
6/17/2016www.verificationexcellence.in 128
Super keyword
▪ super keyword is used from within a derived class to
access base class members/methods
6/17/2016www.verificationexcellence.in 129
Constant Class Properties
▪ const keyword may be used to make class properties
unchangeable.
6/17/2016www.verificationexcellence.in 130
Polymorphism
▪ Polymorphism:
▪ The ability to process objects differently
depending on their data type or class.
6/17/2016www.verificationexcellence.in 131
Polymorphism
▪ Subclass objects are also legal representation of base class
objects
▪ A Derived class object handle can be assigned to base class
pointer
▪ All overridden members in derived class will be hidden in this
case.
▪ Base class definitions will be called when using base class pointer
6/17/2016www.verificationexcellence.in 132
Casting
▪ A base class object handle cannot be assigned to a
derived class handle
▪ If the base class object handle refers to an object of
derived class, then $casting can be used.
6/17/2016www.verificationexcellence.in 133
Virtual Methods
▪ Used as prototype definition in base class
▪ A virtual method definition will override all of definitions
in all base classes
▪ Needs to have matching argument types, identical
qualifiers, directions
▪ “virtual” keyword is optional in derived classes
6/17/2016www.verificationexcellence.in 134
Virtual Method - Example
6/17/2016www.verificationexcellence.in 135
Virtual Method - Example
6/17/2016www.verificationexcellence.in 136
Abstract Classes
▪ The virtual keyword may be used on a class to
make the class “abstract”.
▪ An abstract class may not be instantiated. Users
must derive from abstract class for use.
▪ Useful as prototype class definition
6/17/2016www.verificationexcellence.in 137
pure virtual method
▪ Virtual method in an abstract class can be made as a
prototype with pure keyword
▪ An extended sub class has to provide a definition to
pure virtual method
6/17/2016www.verificationexcellence.in 138
Parameterized Class
▪ Allows Generic Class to be Instantiated as Objects of
Different Types
6/17/2016www.verificationexcellence.in 139
Typedef Class and Forward References
▪ Sometimes it is necessary to use a class before it has been
defined.
▪ e.g. If two classes need handles of each other
6/17/2016www.verificationexcellence.in 140
Overloading
▪ Overloading
▪ multiple methods in the same class with the
same name but different signatures
▪ SV Class doesn’t support
6/17/2016www.verificationexcellence.in 141
Overriding
▪ Overriding
▪ Two methods, one in a parent class and one in a
child class, that have the same signature
▪ lets you define a similar operation in different ways
for different object types.
▪ System Verilog supports overriding not overloading.
6/17/2016www.verificationexcellence.in 142

More Related Content

What's hot (20)

PDF
Basics of Functional Verification - Arrow Devices
Arrow Devices
 
PDF
System verilog important
elumalai7
 
PDF
UVM ARCHITECTURE FOR VERIFICATION
IAEME Publication
 
PDF
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
PDF
Verification challenges and methodologies - SoC and ASICs
Dr. Shivananda Koteshwar
 
PDF
Session 9 advance_verification_features
Nirav Desai
 
PDF
Challenges in Using UVM at SoC Level
DVClub
 
PDF
UVM: Basic Sequences
Arrow Devices
 
PDF
Session 8 assertion_based_verification_and_interfaces
Nirav Desai
 
PDF
Uvm dac2011 final_color
Jamal EL HAITOUT
 
PPT
Verilog Tasks and functions
Vinchipsytm Vlsitraining
 
PDF
2019 2 testing and verification of vlsi design_verification
Usha Mehta
 
PDF
System verilog verification building blocks
Nirav Desai
 
PPTX
ASIC design verification
Gireesh Kallihal
 
DOCX
Design Verification
Ishwaki Thakkar
 
ODP
axi protocol
Azad Mishra
 
PPT
Coding style for good synthesis
Vinchipsytm Vlsitraining
 
PDF
CPU Verification
Ramdas Mozhikunnath
 
PDF
verification_planning_systemverilog_uvm_2020
Sameh El-Ashry
 
PDF
Embedded C - Optimization techniques
Emertxe Information Technologies Pvt Ltd
 
Basics of Functional Verification - Arrow Devices
Arrow Devices
 
System verilog important
elumalai7
 
UVM ARCHITECTURE FOR VERIFICATION
IAEME Publication
 
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
Verification challenges and methodologies - SoC and ASICs
Dr. Shivananda Koteshwar
 
Session 9 advance_verification_features
Nirav Desai
 
Challenges in Using UVM at SoC Level
DVClub
 
UVM: Basic Sequences
Arrow Devices
 
Session 8 assertion_based_verification_and_interfaces
Nirav Desai
 
Uvm dac2011 final_color
Jamal EL HAITOUT
 
Verilog Tasks and functions
Vinchipsytm Vlsitraining
 
2019 2 testing and verification of vlsi design_verification
Usha Mehta
 
System verilog verification building blocks
Nirav Desai
 
ASIC design verification
Gireesh Kallihal
 
Design Verification
Ishwaki Thakkar
 
axi protocol
Azad Mishra
 
Coding style for good synthesis
Vinchipsytm Vlsitraining
 
CPU Verification
Ramdas Mozhikunnath
 
verification_planning_systemverilog_uvm_2020
Sameh El-Ashry
 
Embedded C - Optimization techniques
Emertxe Information Technologies Pvt Ltd
 

Similar to Advances in Verification - Workshop at BMS College of Engineering (20)

PPT
SystemVerilog_veriflcation system verilog concepts for digital vlsi.ppt
Narayan AB
 
PPT
SystemVerilog_veriflcation and UVM for IC design.ppt
ntareq91
 
PPT
SystemVerilog_verification_documents.ppt
ssuserf4000e1
 
PPTX
Randomization and Constraints - Workshop at BMS College
Ramdas Mozhikunnath
 
PPT
SystemVerilog-20041201165354.ppt
ravi446393
 
PDF
Dsp
msmyaseer
 
PPTX
UVM_Full_Print_n.pptx
nikitha992646
 
PDF
An Overview of SystemVerilog for Design and Verification
KapilRaghunandanTrip
 
PDF
COSCUP2023 RSA256 Verilator.pdf
Yodalee
 
PPTX
INTERN VLSI 1.pptx INTERN VLSI 1.pptx ppt
nandithad23
 
PPTX
very large scale integration ppt vlsi.pptx
nandithad23
 
PDF
Verification Challenges and Methodologies
Dr. Shivananda Koteshwar
 
PPTX
Verilog overview
posdege
 
PPTX
HDL_verilog_unit_1 for engagement subjects and technology
praveenbudihal
 
PPTX
Verilog Final Probe'22.pptx
SyedAzim6
 
PPTX
systemverilog and veriog presentation
KhushiV8
 
PPT
Verilog Lecture2 thhts
Béo Tú
 
PDF
L03_4.pdf
SHIVANSHKAUSHIK22
 
PDF
Top five reasons why every DV engineer will love the latest systemverilog 201...
Srinivasan Venkataramanan
 
PDF
SKEL 4273 CAD with HDL Topic 2
alhadi81
 
SystemVerilog_veriflcation system verilog concepts for digital vlsi.ppt
Narayan AB
 
SystemVerilog_veriflcation and UVM for IC design.ppt
ntareq91
 
SystemVerilog_verification_documents.ppt
ssuserf4000e1
 
Randomization and Constraints - Workshop at BMS College
Ramdas Mozhikunnath
 
SystemVerilog-20041201165354.ppt
ravi446393
 
UVM_Full_Print_n.pptx
nikitha992646
 
An Overview of SystemVerilog for Design and Verification
KapilRaghunandanTrip
 
COSCUP2023 RSA256 Verilator.pdf
Yodalee
 
INTERN VLSI 1.pptx INTERN VLSI 1.pptx ppt
nandithad23
 
very large scale integration ppt vlsi.pptx
nandithad23
 
Verification Challenges and Methodologies
Dr. Shivananda Koteshwar
 
Verilog overview
posdege
 
HDL_verilog_unit_1 for engagement subjects and technology
praveenbudihal
 
Verilog Final Probe'22.pptx
SyedAzim6
 
systemverilog and veriog presentation
KhushiV8
 
Verilog Lecture2 thhts
Béo Tú
 
Top five reasons why every DV engineer will love the latest systemverilog 201...
Srinivasan Venkataramanan
 
SKEL 4273 CAD with HDL Topic 2
alhadi81
 
Ad

Recently uploaded (20)

PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PPTX
Alan Turing - life and importance for all of us now
Pedro Concejero
 
PPTX
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
PPTX
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PDF
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
 
PDF
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
PPTX
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PDF
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PPTX
Electrical_Safety_EMI_EMC_Presentation.pptx
drmaneharshalid
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PPTX
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
PDF
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
PPTX
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
Alan Turing - life and importance for all of us now
Pedro Concejero
 
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
 
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
Electrical_Safety_EMI_EMC_Presentation.pptx
drmaneharshalid
 
Functions in Python Programming Language
BeulahS2
 
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
Ad

Advances in Verification - Workshop at BMS College of Engineering

  • 1. Advances inVerification Methodologies Workshop at BMS college – June 2016 As part ofTEQIP 6/17/2016www.verificationexcellence.in 1
  • 2. Verification with System Verilog Ramdas M ExperiencedVerification Engineer, Applied Micro 17+ years experience, Author, OnlineTeacher, Blogger 6/17/2016www.verificationexcellence.in 2
  • 3. Introduction - Instructor ▪ ExperiencedVerification Engineer with 17 years of experience ▪ Applied Micro, Intel, IBM, C-DOT ▪ OnlineTeacher ▪ www.verificationexcellence.in ▪ FREE online courses on SystemVerilog, Assertions, Coverage, UVM ▪ Author ▪ Cracking Digital VLSIVerification Interviews: Interview Success ▪ Quora Blogger ▪ 200+ answers and 5 blogs, Most viewed writer inVLSI topics 6/17/2016www.verificationexcellence.in 3
  • 4. Agenda – Day 1 ▪ Day 1 - Morning ( 9 - 11) ▪ Introduction to SV - 10 mins ▪ Building blocks - 30 mins ▪ Language constructs -50 mins ▪ Exercise/Quiz/Q&A - 30 mins 6/17/2016www.verificationexcellence.in 4 ▪ Day 1 - Morning ( 11.15 - 1) ▪ Threads and Inter process communication ▪ Exercises/Quiz/Q& A ▪ Day 1 – Noon (2-4) ▪ SystemVerilog Classes ▪ Exercises/Quiz/Q& A
  • 5. Agenda – Day 2 ▪ Day 2 - Morning ( 9 - 11) ▪ Interfaces/Virtual Interfaces ▪ Randomization and Constraints ▪ Exercise/Quiz/Q&A 6/17/2016www.verificationexcellence.in 5 ▪ Day 2 -Noon ( 2-4) ▪ Lab Exercises
  • 7. What is SystemVerilog ▪ SystemVerilog is a combined hardware description language and hardware verification language ▪ SystemVerilog is an extensive set of enhancements to IEEE 1364Verilog-2001 standards ▪ It has features inherited fromVerilog HDL,VHDL,C,C++ 6/17/2016 www.verificationexcellence.in 7
  • 8. History and evolution of SV ▪ Verilog (IEEE standard 1364) ▪ Began in 1983 as a proprietary language ▪ Opened to the public in 1992 ▪ Became an IEEE standard in 1995 (updated in 2001 and 2005) ▪ Between 1983 and 2005 design sizes increased dramatically! ▪ SystemVerilog (IEEE standard 1800) ▪ Originally intended to be the 2005 update toVerilog ▪ Contains hundreds of enhancements and extensions toVerilog ▪ Published in 2005 as a separate document ▪ Officially supersededVerilog in 2009 ▪ Updated with more features in 2012 (IEEE 1800 2012 standard) 6/17/2016 www.verificationexcellence.in 8
  • 9. SystemVerilog – UserView ▪ SVD -SystemVerilog for Design ▪ Features supporting Design ▪ SVTB – SystemVerilog forTest benches ▪ Test bench specific Features ▪ SVA – SystemVerilogAssertions ▪ Features for temporal and concurrent assertions ▪ SVDPI – SV Direct Programming Interface ▪ For better C/C++ integration ▪ SVAPI – SV Application Programming Interface ▪ For better Coverage/Assertion integration 6/17/2016 www.verificationexcellence.in 9
  • 11. What isVerification ? ▪ Process of demonstrating functional correctness of a design. 6/17/2016 Verification with System Verilog 11
  • 12. SystemVerilog forVerification ▪ Where do we really use SystemVerilog Language inVerification ? ▪ Building Test bench components ▪ Stimulus generators, drivers ▪ Monitors, Checkers,Assertions ▪ Coverage ▪ Reference Models ▪ Test cases 6/17/2016www.verificationexcellence.in 12
  • 14. Basic Building Blocks Srividhya TP 6/17/2016www.verificationexcellence.in 14
  • 15. Agenda ▪ What is coding for Design /Validation ▪ Delta overVerilog ▪ What should u Know in SystemVerilog ▪ UVM/System C 6/17/2016www.verificationexcellence.in 15
  • 16. SystemVerilog Enhancements ▪ Goal ▪ Model More functionality in fewer lines of code ▪ Reduce redundancy ▪ Reduce risk of coding errors 6/17/2016www.verificationexcellence.in 16
  • 17. How do u handle any HDL/Language ▪ U google  ▪ Design :Synthesizability ▪ What constructs are synthesizable ▪ What construct converts to what real logic? ▪ What are the diff optimized ways of coding? ▪ Coding for Performance, Power ▪ Macros that optimize place and route ▪ Latency, Different frequencies- FIFO Design, Standard library components ▪ Coding for FPGAs, Silicon debug ▪ Documentation; Specification ▪ Project independence 6/17/2016www.verificationexcellence.in 17
  • 18. Verification Mindset ▪ What is architecting forTestbench? Find Bugs known and unknown? ▪ How? ▪ Formal/ assertions ▪ Coverage ▪ How to eliminate Human dependency over generations ▪ What is a right construct? ▪ Simulation time.. ▪ Hierarchy porting ▪ UVM – refer slide 9 ▪ Error Scenarios ▪ Conferences 6/17/2016www.verificationexcellence.in 18
  • 19. Common mistakes - Design ▪ Coding? Instead ofArchitecting -- Clarity ▪ IP based approach? ▪ Assumptions not coded? ▪ Latency unknown ▪ Scaleability 6/17/2016www.verificationexcellence.in 19
  • 20. Common Mistakes -Verification ▪ Out of the Box thinking ▪ Architecting? ▪ Thinking Beyond the Spec ▪ Hard coding ▪ Scope for scalabilityTest /Testbench ▪ Human dependency ▪ EnhancingTB for feature is recoding/patching? ▪ Auto code generation ▪ TB randomness 6/17/2016www.verificationexcellence.in 20
  • 21. Design/Verification Building blocks ▪ Modules ▪ Interfaces ▪ Subroutines (Tasks, Functions) ▪ Packages ▪ Configurations ▪ Hierarchy 6/17/2016www.verificationexcellence.in 21
  • 22. Modules ▪ Basic building block for design/verification ▪ Ports with declarations (input, output ) ▪ Data declarations – nets, variables, structures ▪ Constants, user defined types ▪ Class definitions ▪ Import from packages ▪ Sub routine definition ▪ Instantiation of other modules, interfaces, ▪ Instantiation of class objects ▪ Continuous assignments 6/17/2016www.verificationexcellence.in 22
  • 24. Module Instance and Port connections ▪ InVerilog, port connections must be named ▪ Very verbose and redundant info ▪ SV adds .name and .* shortcuts ▪ .name connects a port to a net of same name ▪ .* automatically connects all ports and nets with same name 6/17/2016www.verificationexcellence.in 24
  • 25. Interfaces ▪ A named bundle of nets or variables ▪ Encapsulates communication between blocks ▪ Connectivity - Port list and signals ▪ Functionality – Functions and tasks ▪ An instantiation of interface can be used to connect between multiple modules. ▪ A single name can replace a list of port 6/17/2016www.verificationexcellence.in 25
  • 26. Interface example ▪ How do we abstract signal between two design blocks like below? 6/17/2016www.verificationexcellence.in 26
  • 27. Interface Example ▪ Advantages ▪ Simplifies complex bus definitions and interconnections ▪ Ensures consistency through out design and verification blocks 6/17/2016www.verificationexcellence.in 27
  • 28. Interface - Another Example 6/17/2016www.verificationexcellence.in 28
  • 30. Tasks and Functions - Usage ▪ Tasks ▪ Tasks can enable other tasks and functions ▪ Tasks may execute in non-zero simulation time. ▪ Tasks may have zero or more arguments of type input, output and inout. 6/17/2016www.verificationexcellence.in 30
  • 31. Synthesizable Variable types ▪ New useful synthesizable types ▪ logic - 4 state variable, user defined size (replaces reg) ▪ reg doesn’t always infer register ▪ Use of logic makes less confusion s in code ▪ enum – variable with specified set of legal values ▪ int - 32 bit 2 state variable ( can replace integer in for loops) ▪ Avoid using 2 state variables in synthesizable code 6/17/2016www.verificationexcellence.in 31
  • 32. Simplified port type rules ▪ Traditional verilog has strict and confusing port type rules ▪ Inputs must be declared wire ▪ Outputs must be ▪ reg if driven from procedural statement ▪ wire if driven by continuous statement ▪ wire if connected to module instances ▪ SystemVerilog makes it easy ▪ Declare all as logic 6/17/2016www.verificationexcellence.in 32
  • 33. Tasks and Functions - Usage ▪ Functions ▪ Function can enable other functions only. Task cannot be called from functions. ▪ Functions should execute in zero simulation time. ▪ Functions have only one return value but System Verilog also allows functions to have input, output or inout types. ▪ 6/17/2016www.verificationexcellence.in 33
  • 36. Argument passing ▪ Pass by value ▪ Each argument is copied to the subroutine area 6/17/2016www.verificationexcellence.in 36 ▪ Pass by reference ▪ A reference to the original argument is passed instead of copying
  • 37. Packages ▪ Provides a declaration space that can be shared by building blocks ▪ Supports declaration of nets, variables, tasks, functions, classes, parameters etc ▪ Declarations can be imported to other building blocks by importing package 6/17/2016www.verificationexcellence.in 37
  • 40. Structure of a Design or Test bench code 6/17/2016www.verificationexcellence.in 40 Packages Module/Program always blocks/initial blocks/processes Parameters/defines, type defines, structs etc useful across files •Contains declarations •functions/tasks, data types, objects etc •Contains concurrent processes/blocks •module instance, continuous assign, always blocks etc •Contains sequential code •If then else, case etc -> control constructs •Repeat/for loops/do..while -> loops •Blocking/non-blocking assignments etc
  • 42. Data Types ▪ Nets ▪ Can be written by one or more continuous assignments ▪ No procedural assignment allowed ▪ Used to model physical connections (e.g. wires) ▪ Multiple drivers will result in a value based on net type 6/17/2016www.verificationexcellence.in 42
  • 43. Data Types ▪ Variables ▪ Can be written by one or more procedural assignments ▪ Or can be written by “one” continuous assignment ▪ Last write determines the value ▪ Normally declared as ▪ <data type> instance ▪ E.g. logic abc; ▪ e.g. int value; ▪ 2 state vs. 4 state variables ▪ Values = 0, 1, x and Z 6/17/2016www.verificationexcellence.in 43
  • 44. DataTypes ▪ 2 valued data types ▪ bit (1 bit) ▪ byte (8bits) ▪ shortint (16 bit) ▪ int (32 bits) ▪ 4 valued data types ▪ logic (1bit) ▪ integer (32 bit) ▪ Time (64 bit) 6/17/2016www.verificationexcellence.in 44
  • 46. Signed/UnsignedTypes ▪ byte, shortint, int, integer and longint defaults to signed ▪ Use unsigned to represent unsigned integer value ▪ time, bit, reg and logic defaults to unsigned ▪ Use signed to represent signed values ▪ Signedness can be explicitly defined as follows: 6/17/2016www.verificationexcellence.in 46
  • 47. Vectors ▪ Vectors are packed array of scalars ▪ Both MSB and LSB needs to be constant integer expressions ▪ Cannot be x (unknown) or z( high impedance) 6/17/2016www.verificationexcellence.in 47
  • 48. Strings 6/17/2016www.verificationexcellence.in 48 • String – ordered collection of characters • If not initialized defaults to empty string - “ “
  • 49. Strings - operators 6/17/2016www.verificationexcellence.in 49 Str1 == Str2 Equality Str1 != Str2 Inequality <, <=, >, >= Comparison {Str1, Str2, … Strn} Concatenation Str1[index] indexing – return 0 if out of range
  • 50. String Methods 6/17/2016www.verificationexcellence.in 50 • len • putc • getc • toupper • tolower • compare • icompare • substr • atoi, atohex, atoct, atobin • atoreal • itoa • hextoa • octtoa • bintoa • realtoa
  • 51. User defined types ▪ A typedef can be used to give a user defined name to an existing type 6/17/2016www.verificationexcellence.in 51
  • 52. EnumeratedTypes ▪ An enumerated type defines a set of named values. ▪ Defaults to “int” if data type declaration missing 6/17/2016www.verificationexcellence.in 52
  • 53. Defining new data types as enums ▪ A type name can be given to a enumerated type to create a new data type ▪ Ranges in elements ▪ Creates 5 elements sub0, sub1, sub2, sub3, sub4 and 3 elements jmp6, jmp7, jmp8 6/17/2016www.verificationexcellence.in 53
  • 54. Other data types ▪ void data type represents nonexistent data. Usually used for functions with no return values ▪ chandle data type represents storage for pointers passed using DPI ▪ class - A variable that can hold handle to a class object ▪ event – Provides a way of synchronization of two ore more concurrently active process ▪ Constant data types - parameters (evaluated elaboration time) and const (set during simulation) 6/17/2016www.verificationexcellence.in 54
  • 55. Other data types ▪ Aggregate Data types (Will explain in later section) ▪ Structures ▪ Unions ▪ Arrays ▪ Dynamic , Associative arrays ▪ Queues 6/17/2016www.verificationexcellence.in 55
  • 60. Operators ▪ Similar to other languages ▪ For more specifics refer to LRM Chapter 11 ▪ As this needs to be used as a reference 6/17/2016www.verificationexcellence.in 60
  • 62. Loops and Flow Control ▪ If-else-if ▪ case/casex/casez ▪ forever ▪ repeat ▪ while ▪ do..while ▪ foreach 6/17/2016www.verificationexcellence.in 62
  • 63. Examples - Loops 6/17/2016www.verificationexcellence.in 63 for (int i; i < arr.size(); j+=2, i++) begin arr[i] += 200; arr[i]--; end 1)x = 0; while (x) begin $display(“%d”, x); x--; end 2) do begin $display(“%d”, x); x--; end while (x);
  • 64. forever ▪ Continuous execution, without end ▪ Used with timing controls ▪ Usually last statement in some block initial : clock_drive begin clk = 1’b0; forever #10 clk = ~clk; end : clock_drive 6/17/2016www.verificationexcellence.in 64
  • 65. repeat ▪ Repeat a block ‘x’ times, no conditional test ▪ repeat (expr) statement ▪ Example x = 0; repeat (16) begin $display(“%d”, x++); end 6/17/2016www.verificationexcellence.in 65
  • 66. case/casez/casex ▪ case: ▪ 4-value exact matching. ▪ No don’t cares allowed 6/17/2016www.verificationexcellence.in 66
  • 67. case/casez/casex ▪ casez/casex: ▪ Allows don’t care to be specified ▪ Useful for priority decoders ▪ casez will handle z as don’t care ▪ casex will handle both z and x as don’t care ▪ Not so commonly used in verification/testbench 6/17/2016www.verificationexcellence.in 67
  • 69. Fixed Size Arrays Declaring fixed-size arrays ▪ int values[0:15]; // 16 ints [0]..[15] ▪ int styles[16]; // 16 ints [0]..[15] Multi Dimensional ▪ int memarray [0:7][0:3]; //Verbose declaration ▪ memarray[7][3] = 1; // Set last array element ▪ int testarray [8][4]; // Compact declaration 6/17/2016www.verificationexcellence.in 69
  • 70. Packed Arrays ▪ An array that represents a contiguous set of bits ▪ Can access subfields of array as elements ▪ Can be made of only single bit data types – bit, logic, reg or enumerated types ▪ E.g.: bit [7:0] data //packed array of 8 bits 6/17/2016www.verificationexcellence.in 70
  • 71. Unpacked Arrays ▪ Unpacked arrays need not be set as contiguous bits in memory ▪ real latency [7:0]; // unpacked array of real types ▪ Unpacked arrays can be made of any data types ▪ Class record_c; ▪ record_c table[7:0] // unpacked array of objects 6/17/2016www.verificationexcellence.in 71
  • 72. Packed and Unpacked Arrays 6/17/2016 www.verificationexcellence.in 72
  • 73. Dynamic Arrays ▪ An array whose size can be changed at run time ▪ Uninitialized size will be zero 6/17/2016www.verificationexcellence.in 73
  • 75. Dynamic Array - Methods 6/17/2016www.verificationexcellence.in 75 function int size() Returns the current size of the array int addr[ ] = new[256]; int j = addr.size(); // j = 256 function void delete() Empties array contents and zero-sizes it int addr[ ] = new[256]; addr.delete(); Resizing <array> = new[<size>](<src_array>); dyn= new[j * 2](fix);
  • 77. Associative Arrays 6/17/2016www.verificationexcellence.in 77 • Associative arrays are used when the size of the array is not known or the data is sparse. • Syntax: data_type array_name [index_type];
  • 78. Associative Array Methods Function Use num() / size() Returns number of entries delete(<index>) Index for delete optional. When specified used to delete given index else whole array. exists (<index>) Returns 1 if element exists at index else 0 first (<index>), last (<index>) assigns to the given index variable the value of the first/last (smallest/largest) index in the associative array. It returns 0 if the array is empty, and 1 otherwise. next (<index>), prev (<index>) finds the entry whose index is greater/smaller than the given index. 6/17/2016www.verificationexcellence.in 78
  • 79. Example : Printing an associative array 6/17/2016www.verificationexcellence.in 79
  • 80. Queues ▪ A queue is a variable size, ordered collection of homogeneous elements ▪ Can grow or shrink in size ▪ Few examples 6/17/2016www.verificationexcellence.in 80
  • 81. Queue Operators ▪ Q[ a : b ] yields a queue with b - a + 1 elements. ▪ If a > b , resultant queue will be an empty queue ▪ If a = b, resultant queue will be a single element queue ▪ If either a or b are 4-state expressions containing X or Z values, it yields the empty queue {}. ▪ Q[ a : b ] where a < 0 is the same as Q[ 0 : b ]. ▪ Q[ a : b ] where b > $ is the same as Q[ a : $ ]. 6/17/2016www.verificationexcellence.in 81
  • 84. Queues - Examples item = q1[0]; // read leftmost ( first ) item from list item = q1[$]; // read rightmost ( last ) item from list n = q1.size; // determine number of items on q1 q1 = q1[1:$]; // delete leftmost ( first ) item of q1 q1 = q1[0:$-1]; // delete rightmost ( last ) item of q1 for (int i=0; i < q1.size; i++) // step through a list using integers begin … end q1 = { }; // clear the q1 list 6/17/2016www.verificationexcellence.in 84
  • 85. Array locator methods ▪ Methods that allow searching through an array including queues ▪ Returns a queue of matching entries 6/17/2016www.verificationexcellence.in 85
  • 87. Array locator - Examples 6/17/2016www.verificationexcellence.in 87
  • 88. Array Ordering Methods ▪ reverse() reverses the order of the elements in the array ▪ sort() sorts the array in ascending order ▪ rsort() sorts the array in descending order ▪ shuffle() randomizes the order of the elements in the array 6/17/2016www.verificationexcellence.in 88
  • 89. Array Ordering Methods - Examples 6/17/2016www.verificationexcellence.in 89
  • 91. Process and Inter Process Communication Ramdas 6/17/2016www.verificationexcellence.in 91
  • 92. Sequential vs Concurrent Blocks ▪ Sequential Block: ▪ A block of statements executed in a sequential order ▪ It finishes the current statement, then begins the next ▪ You always know the order in which it actually executes the statements ▪ The simulator exits the block after finishing the last statement • Concurrent Block – A block of statement(s) executed concurrently (parallel) by a simulator. – It starts executing all statements simultaneously – You cannot know the order in which it actually executes statements scheduled for the same simulation time – The simulator exits the block after finishing the latest statement. 6/17/2016 92www.verificationexcellence.in
  • 93. Examples ▪ Sequential block ▪ Concurrent block ▪ always procedures ▪ initial procedures ▪ final procedures ▪ fork..join blocks 6/17/2016www.verificationexcellence.in 93
  • 94. initial procedure ▪ initial procedure executes only once ▪ It ends when the last statement finishes. ▪ Multiple initial procedures execute concurrently 6/17/2016www.verificationexcellence.in 94
  • 95. final procedure ▪ Similar to initial procedure but executed at end of simulation ▪ Unlike initial procedure, this executes in zero time ▪ No delays allowed 6/17/2016www.verificationexcellence.in 95
  • 96. always procedure ▪ Four forms of always procedures supported ▪ always ▪ General purpose, needs a timing control ▪ always_comb ▪ Used for modelling combinational logic ▪ always_latch ▪ Used for modelling latched logic behavior ▪ always_ff ▪ Used to model synthesizable sequential logic behavior 6/17/2016www.verificationexcellence.in 96
  • 97. Parallel Blocks ▪ Parallel blocks (Threads) are created via fork…join ▪ All threads execute concurrently ▪ Delay control for separate threads ▪ Highly useful to maximize stimulus interactions 6/17/2016www.verificationexcellence.in 97
  • 98. Applications ▪ Testbenches need to model multiple concurrent processes ▪ Providing inputs/stimulus to Design UnderTest ▪ Parallel stimulus on multiple interfaces ▪ Monitoring multiple inputs and outputs for checking/logging ▪ Detecting timeout problems 6/17/2016www.verificationexcellence.in 98
  • 101. Process Controls ▪ wait fork statement ▪ Blocks process execution flow until all immediate child subprocesses completes 6/17/2016www.verificationexcellence.in 101
  • 102. Process Controls ▪ disable fork statement ▪ Stops execution of all child sub processes 6/17/2016www.verificationexcellence.in 102
  • 103. Mailboxes ▪ Mailbox is a communication mechanism that allows messages to be exchanged between different processes. ▪ Data can be sent to a mailbox by one process and retrieved by another 6/17/2016www.verificationexcellence.in 103
  • 104. Mailbox Methods 6/17/2016 104 Method Use new() Create a new mailbox. put() Place a message in a mailbox. get() Retrieve a message from mailbox. try_get()/ try_peek() Try to retrieve a message from the mailbox without blocking. try_put() Try to place a message in mailbox without blocking. Useful only for bounded mailboxes. peek() Copies a message from mailbox without actually removing it. www.verificationexcellence.in
  • 105. MailboxTypes ▪ Unbounded Mailboxes ▪ No restrictions placed on size of mailbox ▪ put() will never block. ▪ Eg: mailbox m = new (); ▪ Bounded Mailboxes ▪ Number of entries is determined when the mailbox is created. ▪ Bound value should be positive. ▪ put() will be blocked if the mailbox is full. ▪ Eg: mailbox m = new (5); // mailbox of depth = 5 6/17/2016www.verificationexcellence.in 105
  • 106. Mail box Example 6/17/2016 106www.verificationexcellence.in
  • 107. Mail box Example 6/17/2016 107 www.verificationexcellence.in
  • 108. Events ▪ Events are constructs that allow hand shake between two processes ▪ Triggered using -> operator. ▪ Triggering unblocks all waiting processes ▪ @ is used to wait for an event 6/17/2016www.verificationexcellence.in 108
  • 111. EventVariables 6/17/2016 111 ▪ Merging Events ▪ When one event variable is assigned to another, both merge into one event variable. ▪ Executing -> on either one of the events affects processes waiting on either event variable. event a, b; a = b; -> a; // also triggers b -> b; // also triggers a www.verificationexcellence.in
  • 112. Semaphores ▪ Semaphores are typically used for mutual exclusion, access control to shared resources, and basic synchronization ▪ Can be described as counters used to control access to shared resources by multiple processes [threads]. ▪ e.g.: Multiple request drivers accessing a shared bus ▪ Implemented as a bucket with fixed number of keys ▪ Processes using semaphores must first procure a key before executing ▪ All others must wait until a sufficient number of keys is returned to the bucket. 6/17/2016www.verificationexcellence.in 112
  • 113. Semaphore Methods 6/17/2016 113 ▪ Semaphore provides following built-in methods: Method Use new() Create a semaphore with specified number of keys. put() Return one or more keys back. get() Obtain one or more keys. try_get() Try to get one or more keys without blocking. www.verificationexcellence.in
  • 116. What is OOP? ▪ OOP is object oriented programming ▪ Organize programs in same way as objects are organized in real world ▪ Break programs in the same way ▪ Several Languages support OOP ▪ C++, Java, (SW) and System Verilog (HDL) 6/17/2016www.verificationexcellence.in 116
  • 117. Class Basics ▪ A Class is a description of some group of things that have something in common. ▪ Objects are individual instances of “classes”. ▪ Example: A class might be “Automobile”. Instances of the “Automobile” class might be “Joe’s car”, “Bob’s car”, “Sally’s truck”, etc. 6/17/2016Verification with System Verilog 117
  • 118. Classes ▪ Inheritance: (is-a relationship) ▪ Allows users to extend existing classes ▪ Eg. Extending the “Automobile” class to create subclasses for “car”, “truck”, “van”, etc. ▪ When using inheritance, the sub-class “inherits” all the parents public/protected data properties and methods. 6/17/2016www.verificationexcellence.in 118
  • 119. Classes ▪ Composition: (has-a relationship) ▪ Composition is used for the case where one object HAS-A instance of another class. ▪ For example, an “Automobile” class might have 4 instances of a “wheel” class 6/17/2016www.verificationexcellence.in 119
  • 122. Class Instantiation ▪ Objects created and Initialized via call to the new Constructor Method ▪ All objects have built-in new method ▪ Allocates storage for all data properties ▪ User-defined new method can initialize and/or do other things 6/17/2016 www.verificationexcellence.in 122
  • 124. Data Hiding and Encapsulation Member type Properties local • Can be accessed only within class • Not visible in derived class protected • Can be accessed only within class • Visible in derived class public • Can be accessed from class as well as outside class using object reference •Visible in derived class 6/17/2016www.verificationexcellence.in 124
  • 126. Special handle - “this” ▪ Used to refer to current instance of this class ▪ Removes ambiguity as in below example. ▪ X is both a class member and argument to constructor 6/17/2016www.verificationexcellence.in 126
  • 127. Static class properties ▪ Static properties/data members are “static” to all instances of the class. ▪ Created only once and shared with all instances ▪ In above example, all instances of packet will share one value for fileID. 6/17/2016www.verificationexcellence.in 127
  • 128. Static class methods ▪ Can be called outside class without instantiation ▪ Cannot access non-static members ▪ Cannot access “this” handle ▪ Cannot be virtual 6/17/2016www.verificationexcellence.in 128
  • 129. Super keyword ▪ super keyword is used from within a derived class to access base class members/methods 6/17/2016www.verificationexcellence.in 129
  • 130. Constant Class Properties ▪ const keyword may be used to make class properties unchangeable. 6/17/2016www.verificationexcellence.in 130
  • 131. Polymorphism ▪ Polymorphism: ▪ The ability to process objects differently depending on their data type or class. 6/17/2016www.verificationexcellence.in 131
  • 132. Polymorphism ▪ Subclass objects are also legal representation of base class objects ▪ A Derived class object handle can be assigned to base class pointer ▪ All overridden members in derived class will be hidden in this case. ▪ Base class definitions will be called when using base class pointer 6/17/2016www.verificationexcellence.in 132
  • 133. Casting ▪ A base class object handle cannot be assigned to a derived class handle ▪ If the base class object handle refers to an object of derived class, then $casting can be used. 6/17/2016www.verificationexcellence.in 133
  • 134. Virtual Methods ▪ Used as prototype definition in base class ▪ A virtual method definition will override all of definitions in all base classes ▪ Needs to have matching argument types, identical qualifiers, directions ▪ “virtual” keyword is optional in derived classes 6/17/2016www.verificationexcellence.in 134
  • 135. Virtual Method - Example 6/17/2016www.verificationexcellence.in 135
  • 136. Virtual Method - Example 6/17/2016www.verificationexcellence.in 136
  • 137. Abstract Classes ▪ The virtual keyword may be used on a class to make the class “abstract”. ▪ An abstract class may not be instantiated. Users must derive from abstract class for use. ▪ Useful as prototype class definition 6/17/2016www.verificationexcellence.in 137
  • 138. pure virtual method ▪ Virtual method in an abstract class can be made as a prototype with pure keyword ▪ An extended sub class has to provide a definition to pure virtual method 6/17/2016www.verificationexcellence.in 138
  • 139. Parameterized Class ▪ Allows Generic Class to be Instantiated as Objects of Different Types 6/17/2016www.verificationexcellence.in 139
  • 140. Typedef Class and Forward References ▪ Sometimes it is necessary to use a class before it has been defined. ▪ e.g. If two classes need handles of each other 6/17/2016www.verificationexcellence.in 140
  • 141. Overloading ▪ Overloading ▪ multiple methods in the same class with the same name but different signatures ▪ SV Class doesn’t support 6/17/2016www.verificationexcellence.in 141
  • 142. Overriding ▪ Overriding ▪ Two methods, one in a parent class and one in a child class, that have the same signature ▪ lets you define a similar operation in different ways for different object types. ▪ System Verilog supports overriding not overloading. 6/17/2016www.verificationexcellence.in 142