Home System Verilog SV Classes Class Constraints
Main Menu
Home
System Verilog
    - Constructs
    - SV Classes
        -- Simple Class
        -- Inheritance
        -- Encapsulation
        -- this and super
        -- In Line Constraints
        -- Class Constraints
        -- Virtual Classes
        -- Parameterized Classes
        -- Summary
        -- Singleton Class
    - Functional Coverage SV
    - Examples
    - Tools
    - Links
    - Books
    - Interview Questions SV
Verilog
Methodologies
Open Vera
Digital Concepts
Verification Basics
Protocols
Scripting
Articles
Videos
Interview Questions
Computer Architechture
C and C++
Blog/Article
AsicGuru Blog
Tags Cloud
Ads
Usefull Sites
Know Your IP/Location
Local Information India
Buy Car/Inverter Batteries
Real Estate India
Sports Accessories India
Class Constraints in system verilog
Share This Articale:

Class Constraints in system verilog :

Constraints can be declared as class properties.

  1. No end-of-line semi-colon

Constraints can enforce dependencies for randomization.

  1. Size of dynamic array must equal len property

Dynamic array is now rand. Both size and contents are randomized, but... ...size is randomized first post_randomize and data_rand methods are no longer required.

class randframe;
 local logic [3:0] addr;
 rand local logic [3:0] len;
 rand logic [7:0] data_arr [];

 function new(input logic[3:0] pa);
   addr = pa;
 endfunction

 constraint framelength {
    data_arr.size() == len;
 }

endclass

randframe one = new(.pa(5));

initial begin
  assert(one.randomize() with {len>0; len<=7;});
  ...


This Articles is written/submitted by puneet (Puneet Aggarwal). You can also contribute to Asicguru.com. Click here to start


Prev << In Line Constraints

Next >> Virtual Classes

 
Login/Register
Register
Sign In
Login with :-
gmail-yahoo-twitter-facebook
| | |  
  •  
  • Bookmark
    ADS