<' struct structs_units3 { addr : byte; // True it is write rd_wr: bool; // Write data is present only during write operation when TRUE'rd_wr structs_units3 { data : byte; }; }; extend sys { obj : structs_units3; // This method shows a sub type can accessed print_obj () is { if (obj.rd_wr == TRUE) { out ("Access Type is : Write"); outf("Access Address is : %x\n",obj.addr); // To access subtype object is bit complicated, as it does not exit // in nomal struct outf("Access Data is : %x\n",obj.as_a(TRUE'rd_wr structs_units3).data); } else { out ("Access Type is : Read"); outf("Access Address is : %x\n",obj.addr); // Below code if you uncomment it will compile, but will give run time // error, as data does not exist when rd_wr is false //outf("Access Data is : %x\n",obj.as_a(TRUE'rd_wr structs_units3).data); }; }; // Just generate the obj and print it run() is also { for {var i : int = 0; i < 4; i = i + 1} do { gen obj; print_obj(); }; }; }; '>