Review and Know-how Randomization Soft Constraints Unique
References:
can only be used on numeric variable
From 18.5.5 in IEEE 1800-2017 :
The open_range_list in a uniqueness_constraint shall contain only expressions that denote scalar or array variables
Arrays Slice an array element by a variable // TODO
OOP
How to traverse all the members of an enumeration
Reference IEEE Std 1800-2017 6.19.5 Enumerated type methods
paramters
cannot be declare in a class
An Example:
will get a compiling error
From the section 5.3 constant
of SV 3.1a LRM :
A parameter or local parameter can only be set to an expression of literals, parameters or local parameters, genvars, enumerated names, or a constant function of these. Hierarchical names are not allowed.
– > Hierarchical names are not allowed
Get the other error:
Package
Others The Top Most Common SystemVerilog Constrained Random Gotchas Chapters of Testplan
HW SPEC study
List direct tests for each feature
Completion criteria: mini/full regressions all pass
Code freeze for back-end synthesis
Do random tests and collect coverages
extend direct tests to random tests
Completion criteria: random regressions all pass for weeks
if a bug is found, designer does ECO to fix the bug and verifier create a direct test for testing the fixed design
collect line / fsm /toggle/functional/assertion coverages
Completion criteria: at least line and fsm coverages achieve 100%
Chip tape out and prepare cases to bring chip up
run random tests until chip is produced
Reviews from Google's stuff on 2022
Items related to DV in Helpful links and videos to prepare for the interview process:
DV methodology
which takes many forms, including test planning, coverage methodology, test bench methodology, etc
SystemVerilog Class 1: Basics
Class Overview
A class is a user-defined data type
Must be delcared in a module , package , or interface
it cannot be compiled standalone
Class object
can be dynamically created and deleted during simulation
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
(Review) malloc/free an object on 11.26 Memory management in < SV 3.1a LRM >
Used in Object-Oriented (OO) programming for testbenches and simulation models
Abstract data modeling
Inheritance
Data hiding and encapsulation
Polymorphism
Variables of the Class Type
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
A variable of a class type is called a handle
Uninitialized value is null
A class instance must be created for handle
using a constructor , new
function
Creates an area of memory holding the class instance
Assigns the memory pointer to the handle
An instance persists until it is no longer in use
No deconstructor
Automatic "garbage collection" like C++
Class Properties and Methods
The class type declaration declares class members :
Data items , called properties
or fields
Tasks or functions which operate on data items, call methods
External Method Declaration
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Class Example
2: Static Members
Can only access static properties
or other static methods
建議透過 class 的名子加上resolution operator ::
來存取 static 變數
可以清楚的表示該 member 是靜態的
3: Aggregate Classes
Encapsulation and Aggregate Classes
Aggregation Summary
4: Inheritance
subclass
可以 re-declare (over-ride) parent members
透過宣告相同名字的task或function
The keryword super
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
在 多層的繼承 , subclasses
的建構子 (constructors),必須明確地將引數往需要的 class 傳
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
5: Polymorphism
Multiple subclasses
當我們需要 基底類型
的 成員(member)
有不同的 (?)值 的一個 子類別(subclass)
,此時會宣告多個繼承基底類型的子類別並給予他們成員不同的值;以不同的 constraints
為例:
Source code
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Relation of the classes
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
每個子類型只有一個 parent
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
C++的多重繼承
Polymorphism的需求
延續上例;當我們有不同種類的frames,要如何存取他們?
每種frame都宣告一個handle
需要多個記憶體空間來儲存handles
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
不同子類別的 實例(instance)
可以共用一個handle
The OOP term for multiple methods sharing a common name is “polymorphism.”
提供一個 virtual method 供上層 programmer 參考,以簡化 coding 的思考;而此 method 可能有不同種類的實作,這部份可以交由底層的 programmer 來攥寫
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
所以一個 handle
type 的概念:
Class type
is used in declaration and the contents
of the handle
Class instance
is held by the handle
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
實例:Assigning Subclass/Parent Instance to Parent/Subclass Handle
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
觀念是?
subclass 有包含 parent 所有的 propertities , 所以 subclass 的 handle 可以無痛 copy 給 parent 的 handle ;如下例 BadTr
繼承 Transaction
:
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
承上,一個 Cast base class 的 handle 到 指向一個由此 base type 延伸出來的 class 的 object 的動作,稱作 Downcasting 或 conversion
反之, parent 沒有包含 subclass 所有的 propertities,所以無法將指向自己的 handle copy 給 subclass 的 handle
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
parent 不能存取 child 的成員
但,並非全然不行;只是必須先使用 $cast
。
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
若 base handle
原來是指向一個 extened object
,則此 賦值 是允許的
所以 賦值 前需先透過 $cast 來檢查上述條件;記住,這裡是檢查 物件 的 型別 ,並非只是 handle。如以下範例:
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
A know-how:
建議在做 base/extended classes 與 base/extended handle 的賦值前,都加上 $cast
, 以確保型別是相容的(compatible)
Sample 8.14 中,最後透過將 $cast
當作 函數 呼叫 (結果是透過回傳值,不會有 simulation error) 的部份,可改寫成
macro
, 如 Section 6.3.2 的 SV_RAND_CHECK macro
不要使用 immediate assert
statement 當作此 assertion expression 使用;若 assertions
被關掉,此 statement 就不會被 evaluated
References
實例:一個包含不同種類 frame
的 array
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
6: Virtual Methods and Classes
multi-level inheritance
class member access is restricted
Class members
are resolved by searching from class handle type
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
parent 不能存取 child 的成員 in 5-Polymorphism
– > could use $cast
system task introduced on the above section; but there's an easier solution …
the above restriction can be resolved by Virtual methods
Virtual methods are resolved according to the contents of a handle, NOT the type of the handle
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
class method resolution
which class method will be referenced
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
virtual class and pure virtual method
Image Not Showing
Possible Reasons
The image was uploaded to a note which you don't have access to The note which the image was originally uploaded to has been deleted
Learn More →
延伸閱讀: 11.17 Data hiding and encapsulation in LRM
Here raise a question :
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Does SystemVerilog have the reserved words like “public” and “private” which are in C++?
A: Yes. But some of names of the reserved words are different:
Public → ___ (needs no reserve word) ;
in SV, unqualified class properties and methods are public, available to anyone who has access to the object’s name.
Private → local ;
we don't want some members to be accessible from outside. Further, they are also not visible within subclasses
Protected → protected ;
in case we want the local members to be accessible to a child.
A protected class property or method has all of the characteristics of a local member, except that it can be inherited; it's visible to subclasses
7 Randomization Random Class Properties
rand
: random with ++uniform distribution==
randc
: random-cyclic randomly iterates through all values without repetition
8 Constraints
Review the following items in SystemVerilog-for-Verification-3rd-by-Chris-Spear-and-Greg-Tumbush