Constraints are Virtual in Nature


//constraints are virtual in natur
class eth_pkt;
rand bit [7:0] count;
constraint count_c {count < 10;}
endclass


class eth_ext_pkt extends eth_pkt;
constraint count_c {count > 50;}
endclass


module top;
eth_pkt pkt =new();
eth_ext_pkt epkt =new();


initial begin
	assert(pkt.randomize());
	$display("pkt.count = %0d <= here the pkt is less than 10\n",pkt.count);
	assert(epkt.randomize());
	$display("epkt.count = %0d\n",epkt.count);
	$display("before casting",$typename(pkt));
	$display("pkt type is %s\n",$typename(pkt));
	$cast(pkt,epkt);
	assert(pkt.randomize());
	$display("after cast pkt.count = %0d <= here the same pke is greater than 50 after casting",pkt.count);
	$display("pkt type is %s",$typename(pkt));
	$display("epkt type is %s",$typename(epkt));
end
endmodule        
No alt text provided for this image

要查看或添加评论,请登录

mohamed irsath I的更多文章

  • Types of Assertion

    Types of Assertion

    In this article, we are going to discuss the Types of Assertion. There are two types of assertion, They are 1)…

    4 条评论
  • What is an Assertion and its needs DV

    What is an Assertion and its needs DV

    Assertions are checks which used to verify that your design meets the given requirements. Assertions in design…

    5 条评论
  • Constraint for a Palindrome No.

    Constraint for a Palindrome No.

    In order to solve the above constraints, we first need to understand what a palindrome number is. A palindrome number…

    2 条评论
  • System Verilog Assertions

    System Verilog Assertions

    Dear Followers, We are excited to announce that our upcoming newsletter will be focusing on SystemVerilog Assertions…

    1 条评论
  • Constraint for AXI Strobe Signal

    Constraint for AXI Strobe Signal

    In the AXI protocol, the wstrb signal (write strobe) is used to indicate which bytes of the wdata signal (write data)…

    6 条评论
  • Corner case in constraint #49 Learnings & Solution

    Corner case in constraint #49 Learnings & Solution

    Constraint for a variable i) on every 2nd randomization the value should be the reverse of the previous value ii)…

    4 条评论
  • Constraint for AXI 4kb Boundary

    Constraint for AXI 4kb Boundary

    In order to achieve the above constraint, first, we need to understand what the AXI-4Kb Boundary is. AXI is a parallel…

    7 条评论
  • Constraint #49

    Constraint #49

    Constraint for a variable i) on every 2nd randomization the value should be the reverse of the previous value ii)…

    10 条评论
  • Constraint #48

    Constraint #48

    Constraint to generate any Prime No. in a given range #2 To achieve the given constraint, we utilize the prime_number…

  • Constraint #47

    Constraint #47

    Constraint to generate any one Prime No. in a given range #1 To generate a prime number, we first need to understand…

    3 条评论

社区洞察

其他会员也浏览了