$strobe in a class

In reply to dave_59:

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

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