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

0

Verilog Tutorial

17
  • 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

Interview Questions

2
  • SystemVerilog Interview Questions
  • Verilog Interview Questions

Handwritten Notes

3
  • Perl (Scripting)
  • Linting
  • CMOS Logic Design
View Categories
  • Home
  • Tutorials
  • System Verilog
  • Classes

Classes

1 min read

What is a Class in SystemVerilog? #

A class in SystemVerilog is a user-defined data type that combines properties (variables) and methods (functions/tasks). Classes enable object-oriented programming features in SystemVerilog, such as encapsulation, inheritance, and polymorphism—commonly used in testbench development.

Why Use Classes? #

In traditional Verilog, everything is procedural and structural. But when you’re building testbenches, you often need:

  • Randomization
  • Reusability
  • Clean code organization
  • Hierarchical modeling

Classes help with all of that. They’re especially important in UVM (Universal Verification Methodology).

How to Define a Class #

class ClassName;
  // Data Members
  // Functions or Tasks
endclass

Example:

class Packet;
  bit [7:0] addr;
  bit [7:0] data;

  function void display();
    $display("Addr = %0h, Data = %0h", addr, data);
  endfunction
endclass

Creating (Allocating) Objects #

In SystemVerilog, classes are dynamic objects.
You must allocate memory using the new keyword.

Example:

Packet p1;        // Declare handle
p1 = new();       // Allocate memory

p1.addr = 8'hA0;
p1.data = 8'h55;
p1.display();
Output:  Addr = A0, Data = 55

Important Features of Classes #

FeatureDescription
Data MembersVariables declared inside the class
MethodsFunctions and tasks declared inside the class
Constructor (new)Initializes class objects when memory is allocated
InheritanceAllows a class to reuse and extend another class
PolymorphismAllows method overriding and dynamic dispatch (used in virtual classes)
EncapsulationKeeps internal data hidden from outside access (with local, protected)
Updated on August 2, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
Procedural statements and Control flowInheritance

Leave a Reply Cancel reply

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

Table of Contents
  • What is a Class in SystemVerilog?
  • Why Use Classes?
  • How to Define a Class
  • Creating (Allocating) Objects
  • Important Features of Classes

Archives

  • May 2025

Categories

  • Slider Post
  • Uncategorized

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