Each class instance would normally have a copy of each of its internal variables.

class Packet;
  bit [15:0]   addr;
  bit [7:0]   data;
  function new (bit [15:0] ad, bit [7:0] d);
    addr = ad;
    data = d;
    $display ("addr=0x%0h data=0x%0h", addr, data);
module tb;
  initial begin
    Packet   p1, p2, p3;
    p1 = new (16'hdead, 8'h12);
    p2 = new (16'hface, 8'hab);
    p3 = new (16'hcafe, 8'hfc);

Each of the class objects p1, p2, p3 will have addr and data variables within it.

Simulation Log
ncsim> run
addr=0xdead data=0x12
addr=0xface data=0xab
addr=0xcafe data=0xfc
ncsim: *W,RNQUIE: Simulation is complete.

Login to your free account to read more ...

Was this article helpful ?