// example 3 <' struct packet_s { // structs are more or less like classes or structures in C, //I will talk more about them later on length : uint; // This is a regular field that will be given a random value within the //relevant constraints when a new packet is // created. keep length >= 10 and length <=20; // length of the packet in bytes %header1 : byte; // The percent sign indicates that this field is a real part //of the packet, which will be sent (physical field). // The length field for example is a virtual field and //will not be sent. After the packet is created, // you can translate it into bits using a method of every // struct called pack() (which is a lot like // the serialize() method that C++ provides for writing //data structures into a file). // pack() translates all the real, physical fields //into bits and then concatenates them. keep header1 != 0; // header1 can get any random value except 0 %header2 : byte; keep header1 < 128 => header2 != 0; // The Value of header2 depends on the value of header1. // If header1 is smaller than 128 // header2 must not be equal to zero. If header1 is // equal or greater than 128 header2 can get any value. // Note that header1 is assigned a random value (generated) // before header2 because header1 is defined above header2. %data : list of byte; // data is a list of bytes keep data.size() == length-2; // size() is a method of every list. One of the best things // about Specman is the large // number of predefined methods for list objects. // When a list is randomly generated // the size of the list is also random. The constraint // assures that the length of the packet // including the two header bytes will in fact be equal // to the field length }; '>