Skip to content
asicguru.tech@gmail.com
REGISTER LOGIN
AsicGuru Ventures
  • All Courses
  • CONTACT
  • GALLERY
  • HOME
  • Tutorials

0

Verilog Tutorial

17
  • Verilog Introduction
  • Lexical Tokens
  • Gate-Level Modelling
  • Data Types
  • Operators
  • Operands
  • Modules
  • Behavioral Modeling
  • Timing Controls
  • Procedures: Always and Initial Blocks
  • Functions
  • Tasks
  • Component Inference
  • Finite State Machines.
  • Compiler Directives
  • System Tasks and Functions
  • Test Benches

System Verilog

23
  • System Verilog Introduction
  • Data Types
  • Type Casting
  • Arrays
  • Associative Arrays
  • Dynamic Arrays
  • Queue
  • Operators
  • Procedural statements and Control flow
  • Classes
  • Inheritance
  • Encapsulation
  • This and Super operator
  • In-Line Constraints
  • Class Constraints
  • Virtual Classes
  • Parameterized Classes
  • Classes Summary
  • Singleton Classes
  • Functional Coverage Introduction
  • Covergroup
  • Tools
  • Books

Scripting

15
  • Introduction
  • Perl Tutorial
  • What is Perl
  • Perl: Syntax And Variable
  • Perl Strings
  • Perl Arrays
  • Perl Associative Arrays
  • If/While Syntax
  • File Input
  • Print Output
  • String Processing with Regular Expressions
  • Subroutines
  • Running External Programs
  • References
  • Terse Perl

Makefile

1
  • Makefile Tutorial
View Categories
  • Home
  • Tutorials
  • System Verilog
  • In-Line Constraints

In-Line Constraints

< 1 min read

#

One of the main feature of the systemverilog classes are randomization. You can randomize the system verilog classes with the randomize method using

obj.randomize();

It will randomize all the properties which are declared as rand and randc and can take any valid value for the varialbe. like for variable

rand bit [3:0] a;

A can take any value between 0 – 15.  Constraints can be applied to or used to contol the value generated with randomization. In system verilog constraints can be applied in two ways :

  1. In line constraints
  2. Class constraints

Inline constraints can be attached to randomize using with.

  – Simple relational constraint

  – Change weighting of values with dist

But they are difficult to maintain and a better option is to use subclasses and inheritance.

view source

print?

01.class randframe;

02.local logic [3:0] addr;

03.rand local logic [3:0] len;

04.logic [7:0] data_arr [];

05. 

06.function new(input logic [3:0] pa);

07.addr = pa;

08.endfunction

09. 

10.function void post_randomize();

11.data_rand();

12.endfunction

13. 

14....

15. 

16.endclass

17. 

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

19. 

20.initial begin

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

22....

23.assert(one.randomize() with {len dist {[1:7]:=2, [8:15]:=1};});

24....

Updated on May 4, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
This and Super operatorClass Constraints

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents

Archives

  • May 2025

Categories

  • Slider Post
  • Uncategorized

Copyright @ Asicguru Ventures by Misbah WP | Proudly powered by WordPress