vmm_data class is to be used to model all transactions in the infrastructure . It provides a standard set of methods expected to be found in all transactions. All transactions in the verification environment inherit this object and override its main generic virtual tasks such as copy(), byte_pack(), byte_unpack(), compare() and psdisplay().
vmm_data has 3 unique identifiers for identifying transaction instance.
int stream_id; // Stream identifier
int scenario_id;// Sequence identifier within stream
int data_id; // instance identifier within sequence
This class is used to generate random, constraint random and directed transactions.
We will see the implementation of some methods.
Let us implement a simple packet using vmm_data.
Packet Specification
-------------------------------
Packet has DA,SA,Len and ..... few more feilds.
All the feilds are 8 bit.
compare = 1; // Assume success by default.
diff = "No differences found";
// data types are the same, do comparison:
if (this.da != cmp.da)
begin diff = $psprintf("Different DA values: %b != %b", this.da, cmp.da);
compare = 0;
end
if (this.sa != cmp.sa)
begin diff = $psprintf("Different SA values: %b != %b", this.sa, cmp.sa);
compare = 0;
end ........
........
7) Define byte_pack() method.
byte_pack() method Packs the content of the transaction or data into the specified dynamic array of bytes.
randbit [7:0] length;
randbit [7:0] da;
randbit [7:0] sa;
randbit [7:0] data[];//Payload using Dynamic array,size is generated on the fly
randbyte fcs;
virtualfunction vmm_data copy(vmm_data to = null);
Packet cpy;
// Copying to a new instance?
if (to == null)
cpy = new;
else
// Copying to an existing instance. Correct type?
if (!$cast(cpy, to))
begin `vmm_fatal(this.log, "Attempting to copy to a non packet instance");
copy = null;
return copy;
end
compare = 1; // Assume success by default.
diff = "No differences found";
if (!$cast(cmp, to))
begin `vmm_fatal(this.log, "Attempting to compare to a non packet instance");
compare = 0;
diff = "Cannot compare non packets";
return compare;
end
// data types are the same, do comparison:
if (this.da != cmp.da)
begin diff = $psprintf("Different DA values: %b != %b", this.da, cmp.da);
compare = 0;
return compare;
end
if (this.sa != cmp.sa)
begin diff = $psprintf("Different SA values: %b != %b", this.sa, cmp.sa);
compare = 0;
return compare;
end if (this.length != cmp.length)
begin diff = $psprintf("Different LEN values: %b != %b", this.length, cmp.length);
compare = 0;
return compare;
end
foreach(data[i])
if (this.data[i] != cmp.data[i])
begin diff = $psprintf("Different data[%0d] values: 0x%h != 0x%h",i, this.data[i], cmp.data[i]);
compare = 0;
return compare;
end if (this.fcs != cmp.fcs)
begin diff = $psprintf("Different FCS values: %b != %b", this.fcs, cmp.fcs);
compare = 0;
return compare;
end endfunction:compare