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

Inheritance

2 min read

What is Inheritance? #

Inheritance is a fundamental concept in Object-Oriented Programming (OOP), and SystemVerilog fully supports it through class-based modeling. In simple terms, inheritance allows a class (called the child class) to automatically acquire the properties and behaviors (variables and methods) of another class (called the parent class or base class).

This promotes:

  • Code reuse (don’t repeat what already exists)
  • Hierarchy-based modeling (natural representation of relationships)
  • Modularity and extensibility (easy to expand or override behavior)

Syntax:

class Parent;
  // variables and methods
endclass

class Child extends Parent;
  // additional variables and methods
endclass

Example:

class Animal;
  function void speak();
    $display("Animal makes sound");
  endfunction
endclass

class Dog extends Animal;
  function void bark();
    $display("Dog barks");
  endfunction
endclass

// Usage
module test;
  initial begin
    Dog d = new();
    d.speak(); // Inherited from Animal
    d.bark();  // Defined in Dog
  end
endmodule
Output: Animal makes sound
        Dog barks

Dog inherits the speak() method from Animal, It can also define its own method like bark().

Overriding Parent Methods #

You can override a method in the child class using the same name.

class Animal;
  function void speak();
    $display("Animal speaks");
  endfunction
endclass

class Cat extends Animal;
  function void speak();
    $display("Cat meows");
  endfunction
endclass

// Usage
module test;
  initial begin
    Cat c = new();
    c.speak();   
  end
endmodule

Now, calling speak() from a Cat object will run the child version, not the parent version.

Output: Cat meows

The super Keyword #

If you still want to call the parent’s method that is overridden by the child class, use super.

class Animal;
  function void speak();
    $display("Animal speaks");
  endfunction
endclass

class Cat extends Animal;
  function void speak();
    super.speak();         // calling parent class method
    $display("Cat meows");
  endfunction
endclass

// Usage
module test;
  initial begin
    Cat c = new();
    c.speak();   
  end
endmodule
Output: Animal speaks
        Cat meows

Quick Summary #

ConceptDescription
extendsKeyword to inherit a parent class
Inherited MembersChild gets access to parent’s variables/functions
Method OverridingChild can redefine parent methods
superUsed to call parent class functions/methods
Updated on August 2, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
ClassesEncapsulation

Leave a Reply Cancel reply

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

Table of Contents
  • What is Inheritance?
  • Overriding Parent Methods
  • The super Keyword
  • Quick Summary

Archives

  • May 2025

Categories

  • Slider Post
  • Uncategorized

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