Kyle Hsieh (謝阿Sa)
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    [TOC] # Review and Know-how ## Randomization ### Soft Constraints - Soft constraints are default constraints which hold true until contradicted by another similar constraint. > Ref.: http://vlsiwithvikas.blogspot.tw/2016/05/system-verilog-soft-constraints.html ### Unique ``` unique { open_range_list- } ``` - References: - [SystemVerilog Unique Constraint](https://verificationguide.com/systemverilog/systemverilog-unique-constraint/) - 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 ### [super.super task call](https://verificationacademy.com/forums/uvm/super.super-task-call) - 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: ```verilog class ec_ctl_mem_lock_reg0_sequence extends ec_ctl_base_sequence; parameter ec_addr_width = ec_cfg.ec_addr_width; ``` will get a compiling error ```sh Error-[SV-IRTAV] Illegal reference to automatic variable ../../../../vsrc/ec_tb/ec_ctl_base_sequence.sv, 1518 "ec_cfg.ec_addr_width" Hierarchical reference to automatic variable 'ec_addr_width' is not legal. Declared at: "../../../../vsrc/ec_tb/ec_config.sv", 439 ``` 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: ```verilog Error-[NCE] Non-constant expression The following expression should be a constant. Expression: (64 - this.ec_addr_width) "../../../../vsrc/ec_tb/ec_ctl_base_sequence.sv", 1543 Source info: wr_data[0][63 -: (64-ec_addr_width)] = '{(64-ec_addr_width){'b1}};//reserved and read as all 1. So initialising to all 1 'this' is not an elaboration-time constant. To correct the error you may convert this const variable to a parameter or a localparam. ``` ## `Package` ## Others ### The Top Most Common SystemVerilog Constrained Random Gotchas - https://dvcon-europe.org/sites/dvcon-europe.org/files/archive/2014/proceedings/T5_1_paper.pdf ### Chapters of Testplan 1. HW SPEC study - list features 2. List direct tests for each feature - Completion criteria: mini/full regressions all pass - Code freeze for back-end synthesis 3. 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% 4. 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:](https://hackmd.io/0l8lVqxQQBaaNrxeX6yCbw#-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 - :thinking_face: (Review) malloc/free an object on [11.26 Memory management](https://hackmd.io/mSdqwKkLSfCIM_GWfhCwOQ?both#1126-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 - TO-REVIEW - Variables of the Class Type ![](https://hackmd.io/_uploads/H1jDByh35.png) *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 ![](https://hackmd.io/_uploads/rJrGX0shq.png) - Class Example - [ ] Practice Module info ![](https://hackmd.io/_uploads/rJLRY0jh9.png) **My answer**: ### 2: Static Members ![](https://hackmd.io/_uploads/Hyjf6As3c.png) ![](https://hackmd.io/_uploads/ryET0Cshq.png) ![](https://hackmd.io/_uploads/BJnUxkh25.png) - Can only access `static properties` or other `static methods` - 建議透過 class 的名子加上resolution operator `::` 來存取 static 變數 > 可以清楚的表示該 member 是靜態的 ![](https://hackmd.io/_uploads/ByMDM1nhc.png) - [ ] practice ### 3: Aggregate Classes - Properties of a Class Type ![](https://hackmd.io/_uploads/rky5lH2n9.png) - A class property can be an instance of another class e.g. the class frame handles `f1` and `f2` in the class twoframe - 必須明確地呼叫 class properties 的 constructors ![](https://hackmd.io/_uploads/ry0ogB23c.png) - Encapsulation and Aggregate Classes ![](https://hackmd.io/_uploads/rkfeWr3hq.png) - Aggregation Summary ![](https://hackmd.io/_uploads/rkOMWS2n9.png) ### 4: Inheritance - `subclass` 可以 re-declare (over-ride) parent members $\rightarrow$ 透過宣告相同名字的task或function - The keryword `super` ![](https://hackmd.io/_uploads/HJM_Br3n5.png =320x400) - `parent` 的 constructor 會自動被 `subclass` 的 constructor 執行 - 可以想像是*subclass constructor 的第一行* - 即 `parent` 的 **new()** 放到 `subclass` 的 **new()** 中 - :question: 但上例在 construct `subclass` *badtagframe* 時會遇到 "compilation error" - 因為 implictly 呼叫 parent 的 new(),沒有給予需要的引數(*arguments*) ![](https://hackmd.io/_uploads/S1KSYS3hq.png) $\rightarrow$ ==明確地呼叫 parent 的 new(),by **super** keyword,並給予其需要的引數== - 在*多層的繼承*,`subclasses` 的建構子 (constructors),必須明確地將引數往需要的 class 傳 ![](https://hackmd.io/_uploads/HJVqsH3h5.png) - 一次只能傳一層, 故不能寫以下的 code ```verilog super.super.new() ``` ### 5: Polymorphism - Multiple subclasses - 當我們需要`基底類型`的`成員(member)`有不同的 (?)值 的一個`子類別(subclass)`,此時會宣告多個繼承基底類型的子類別並給予他們成員不同的值;以不同的 `constraints` 為例: - Source code ![](https://hackmd.io/_uploads/ryBOP1T3q.png =320x400) - Relation of the classes ![](https://hackmd.io/_uploads/BJfxO1ph9.png) > 每個子類型只有一個 parent - [ ] :question: C++的多重繼承 - Polymorphism的需求 - 延續上例;當我們有不同種類的frames,要如何存取他們? 1. 每種frame都宣告一個handle $\rightarrow$ 需要多個記憶體空間來儲存handles 2. :star: 不同子類別的`實例(instance)`可以共用一個handle > The OOP term for multiple methods sharing a common name is “polymorphism.” > > 提供一個 virtual method 供上層 programmer 參考,以簡化 coding 的思考;而此 method 可能有不同種類的實作,這部份可以交由底層的 programmer 來攥寫 ![](https://hackmd.io/_uploads/r1NwiJah9.png) - 所以一個`handle` *type* 的概念: - `Class type` is used in *declaration* and the `contents` of the handle - `Class instance` is held by the handle ![](https://hackmd.io/_uploads/ByryAJanc.png) - [x] 實例:Assigning Subclass/Parent Instance to Parent/Subclass Handle ```verilog handle of parent = handle of subclass // 允許 handle of subclass = handle of parent // 會有編譯上的錯誤 ``` :question: 觀念是? - ==subclass 有包含 parent 所有的 propertities , 所以 subclass 的 handle 可以無痛 copy 給 parent 的 handle==;如下例 `BadTr` 繼承 `Transaction`: ![](https://hackmd.io/_uploads/SyP4ImRh5.png) :notes: 承上,一個 *Cast* base class 的 handle 到 指向一個由此 base type 延伸出來的 class 的 object 的動作,稱作 **Downcasting** 或 **conversion** - 反之, parent 沒有包含 subclass 所有的 propertities,所以無法將指向自己的 handle copy 給 subclass 的 handle ![](https://hackmd.io/_uploads/r1avLQCn5.png) - :notes: parent 不能存取 child 的成員 - 但,並非全然不行;只是必須先使用`$cast`。 - :notes: 若 `base handle` 原來是指向一個 `extened object`,則此*賦值*是允許的 - 所以*賦值*前需先透過 $cast 來檢查上述條件;記住,這裡是檢查*物件*的*型別*,並非只是 handle。如以下範例: ![](https://hackmd.io/_uploads/BJ1cc7Cn5.png) :::info 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 > - *8.3.1 Downcasting with $cast* in > < SystemVerilog for Verifiction, 3rd > > - [11.13 Overridden members](https://hackmd.io/VcksXsrUTsK5IGEnn2xFjg#1113-Overridden-members) - [x] 實例:一個包含不同種類 `frame` 的 array ![](https://hackmd.io/_uploads/S1tAXNC3c.png) ### 6: Virtual Methods and Classes - multi-level inheritance - class member access is restricted > `Class members` ++are resolved by searching from++ *class handle type* ![](https://hackmd.io/_uploads/rJrjpVRnc.png) ![](https://hackmd.io/_uploads/HyM66E0n9.png) :thinking_face: parent 不能存取 child 的成員 in [5-Polymorphism](https://hackmd.io/mSdqwKkLSfCIM_GWfhCwOQ?view#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 ![](https://hackmd.io/_uploads/SkYxlSCnq.png) - :star: class method resolution - which class method will be referenced ![](https://hackmd.io/_uploads/S1wilHR35.png) - virtual class and pure virtual method ![](https://hackmd.io/_uploads/HkCZWSA2q.png) - 延伸閱讀: 11.17 Data hiding and encapsulation in LRM *Here raise a question*: :question: 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++ ![](https://hackmd.io/_uploads/H1W33wC29.png) ![](https://hackmd.io/_uploads/S1846PC39.png) ![](https://hackmd.io/_uploads/ryLYTvC3c.png) ![](https://hackmd.io/_uploads/BktG0P0n5.png) ![](https://hackmd.io/_uploads/r1XKAv0n5.png) ### 8 Constraints ![](https://hackmd.io/_uploads/HJM10_Ch9.png) - Constraint Expressions: Set Membership ![](https://hackmd.io/_uploads/BJfSA_C2q.png) by the **inside** operator: ```verilog [!] (expression) inside { set }) ``` - Constraint Expressions: Weighted Distributions ![](https://hackmd.io/_uploads/SkU8A_Ahq.png) > reference [note on 12.4.4 Distribution in SV 3.1a LRM](https://hackmd.io/VcksXsrUTsK5IGEnn2xFjg#1244-Distribution) ![](https://hackmd.io/_uploads/HyHi0uCh9.png) ## [Verification Guide](https://verificationguide.com/systemverilog/systemverilog-tutorial/) > Review the following items in [SystemVerilog-for-Verification-3rd-by-Chris-Spear-and-Greg-Tumbush](https://hackmd.io/qXQ7KswiQF2q9S9BjzSoKQ?view#SystemVerilog-for-Verification-3rd-by-Chris-Spear-and-Greg-Tumbush) - [x] Arrays - [Chapter 2 Data Type in <SystemVerilog for Verification (3rd)>](https://hackmd.io/qXQ7KswiQF2q9S9BjzSoKQ?both#Chapter-2-Data-Types) - [x] [Choosing a Storage Type](https://hackmd.io/qXQ7KswiQF2q9S9BjzSoKQ?both#27-Choosing-a-Storage-Type) - [ ] Processes - [Chapter-7-Threads-and-Interprocess-Communication](https://hackmd.io/qXQ7KswiQF2q9S9BjzSoKQ?both#Chapter-7-Threads-and-Interprocess-Communication) - [ ] Tasks and Functions

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully