I would like to know what the keyword try is used for in Specman and especially its usage in the code snippet given below:
try {
unpack(packing.low,lob,pkt);
} else{
message(LOW, “Uh-oh!”){print lob using HEX;};
message(LOW,”bad unpack!!!”);
};
tryandelseare Specman’s exception handling constructs. If an error is created in thetryblock, then theelseblock is immediately executed instead of the rest of thetryblock and the error is suppressed with no printout.In this case, if
lobhas more bits thanpkthas “physical fields”, then the unpack will generate an error. If that happens, the Specman runtime will jump to theelseblock and print out thelobdata structure instead of printing the originalunpackerror. Look in the docs with regards to what “physical fields” are and how they are used. They are a strange construct that specifically interacts with the behavior of Specman’s%,pack, andunpackconstructs. Physical fields ofpktwill be declared with the%modifier preceding the “physical fields” ofpkt.