# $strobe in a class

**URL:** <https://verificationacademy.com/forums/t/strobe-in-a-class/38740>\
**Category:** SystemVerilog\
**Tags:** FunctionArgument, strobe, SystemVerilog, systemverilog-class-event\
**Created:** [February 22, 2021, 11:16am UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740 "2021-02-22T11:16:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [February 22, 2021, 11:16am UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/1 "2021-02-22T11:16:31Z")

</div>

I have written the following code in an SV class

```verilog
function void print();
    $strobe("A = %0d", a);
    $strobe("B = %0d", b);
    $strobe("C = %0d", c);
    $strobe("D = %0d", d);
    $strobe("E = %0d", e);
    $strobe("F = %0d", f);
    $strobe("G = %0d\n", g);
endfunction : print

```

But when I created an object of this class and called the above method, it’s not displaying anything.  
What are the possible reasons/issues?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 22, 2021, 3:27pm UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/2 "2021-02-22T15:27:59Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/strobe-in-a-class/38740):_

There’s a problem somewhere in the code you have not shown.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [February 23, 2021, 6:51am UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/3 "2021-02-23T06:51:46Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/2):_

Hi dave,  
Happy to hear fom you again.  
I quote my SV code here.

```verilog
class packet;
    rand byte a,b,c,d,e,f,g;
    
    //Constraining values from 1 to7
    constraint value {a>0; a<8;
                b>0; b<8;
                c>0; c<8;
                d>0; d<8;
                e>0; e<8;
                f>0; f<8;
                g>0; g<8;
    }
    
    //No one shares same floor
    constraint unique_value { unique {a,b,c,d,e,f,g};}

    //E does not live on an even numbered floor  
    constraint E { e%2 !=0;}
    //G does not live on the top most floor
    constraint G { g != 7;}
    //Only one person lives between E and G
    constraint E_G { e-g == 2 || g-e == 2;}
    //A does not live on even numbered floor and does not live below F
    constraint A { a%2 !=0; a > f; }
    //D does not live immediately above or immediately below G
    constraint D_G { d-g != 1 || g-d != 1;}
    // There two floors between D and E
    constraint D_E { e-d == 3 || d-e == 3;}
    // Both B and C live on even-numbered floor.
    constraint B { b%2 == 0;}
    constraint C { c%2 ==0;}
    // F lives on floor number 5
    constraint F { f == 5;}
    //G and C live in between the two floors.
    constraint G_C { g-c == 1 || c-g == 1;}

  function void print();
    $strobe("A = %0d", a);
    $strobe("B = %0d", b);
    $strobe("C = %0d", c);
    $strobe("D = %0d", d);
    $strobe("E = %0d", e);
   $strobe("F = %0d", f);
   $strobe("G = %0d\n", g);
  endfunction : print

endclass

module tb;
packet obj;

initial begin
repeat(1) begin
    obj= new();
void'(obj.randomize());
obj.print();
end
$finish();
end
endmodule : tb

```

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 23, 2021, 3:59pm UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/4 "2021-02-23T15:59:40Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/3):_

You $strobe is not printing because you call $finish before the output is schedule appear. Add a delay before calling $finish.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [February 24, 2021, 4:22am UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/5 "2021-02-24T04:22:05Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/4):_

Thanks Dave  
Understood the mistake

In which event schedule region the $finish() is called

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 24, 2021, 8:51pm UTC](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/6 "2021-02-24T20:51:08Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/strobe-in-a-class/38740/5):_

Since your $finish is a statement inside an initial block of a module, it’s the executed in the active region. But regardless, the output from $strobe gets schedules in the last region --postponed.
