Trung tâm đào tạo thiết kế vi mạch Semicon


  • ĐĂNG KÝ TÀI KHOẢN ĐỂ TRUY CẬP NHIỀU TÀI LIỆU HƠN!
  • Đăng ký
    *
    *
    *
    *
    *
    Fields marked with an asterisk (*) are required.
wafer.jpg

CONSTRAINT OVERRIDE IN SYSTEM VERILOG

Email In PDF.

Here in this overriding of constraint if we will have the same constraint name in the parent class as well as child class then we can say that our constraint is overridden in the child class.

Let us understand through an example:

class parent;

  rand int data;

  constraint ct_c

  {

    data inside {[100:200]};

  }

endclass : parent

 

class child extends parent;

  constraint ct_c

  {

    data inside {[250:500]};

  }

endclass : child

 

program main;

  child c;

  initial begin

    c = new();

    if (!c.randomize()) begin

      $display("Randomization failed");

    end

    else begin

      $display("data = %0d", c.data);

    end

  end

endprogram : main


In the above example, you can observe that the EDA tool will try to solve only child (extended/derived) class’s constraint because Child class Override parent class’s Constraint as both constraints is having the same name.

Let us see another example with a different constraint name:

class parent;

  rand int data;

  constraint ct_c

  {

    data inside {[100:200]};

  }

endclass : parent

 

class child extends parent;

  constraint ct_child

  {

    data inside {[250:500]};

  }

endclass : child

 

program main;

  child c;

  initial begin

    c = new();

    if (!c.randomize()) begin

      $display("Randomization failed");

    end

    else begin

      $display("data = %0d", c.data);

    end

  end

endprogram : main


In the above example, EDA Tool will consider two different constraints so it will try to resolve both constraints because the Same variable is constrained using two different constraints (Names are different so the Child class can’t override the Parent class’s constraint) having different names and both constraints are contradict to each other.

 Bạn Có Đam Mê Với Vi Mạch hay Nhúng      -     Bạn Muốn Trau Dồi Thêm Kĩ Năng

Mong Muốn Có Thêm Cơ Hội Trong Công Việc

Và Trở Thành Một Người Có Giá Trị Hơn

Bạn Chưa Biết Phương Thức Nào Nhanh Chóng Để Đạt Được Chúng

Hãy Để Chúng Tôi Hỗ Trợ Cho Bạn. SEMICON  

 

Lần cập nhật cuối ( Thứ ba, 29 Tháng 3 2022 00:55 )  
Chat Zalo