Please see following link for more details.
http://standards.ieee.org/announcements/IEEE1647_eLanguageStandard.html
Say a parent struct is having two fields inside it. One is an ungenerated (with do-not-generate sign) child struct and another ungenerated field is of pre defined data types (like uint, bool etc.).
When this parent struct is generated
2) ungenerated field whose value is a range (such as [0..100]) gets the first value in the range.
3) ungenerated field of user defined data types (like sturcts) will not be allocated and none of the fields in it will be generated.
Take a look at following code.
In this example, top_s struct has one ungenerated struct and two ungenerated fields of uint (bits: 3). When top is generated inside the sys
2) x will be generated with value of 2 as it is a range bound ungenerated field.
3) child field will not be generated as it is defined as ungenerated struct. So, the fields a and b of child struct will not be generated as well.
Answer:
a = 2 x.y = 8
a = 2 x.y = 4
Here, variable uint a is not updated and struct x is updated. Why is so? Because in specman, unlike user defined data types (e.g. structs, units), all variables with standard data types are passed by value in the methods. All user defined data types (like structs) are passed by reference. So, whenever, called methods update the passed structs, it is actually updating the original struct and not its copy.
If one wants user defined data types to be passed by value then he/she can use deep_copy to copy the existing variable and pass it to the method as shown below.
Question 2: What is the difference between inheritance implemented by "when" construct and implemented by "like" construct?
Answer:
like inheritance is the concept of the object oriented programming (OOP) where as when inheritance is the concept of aspect oriented programming (AOP). For more detail on AOP, please refer Aspect-Oriented Programming with the e Verification Language book written by David Robinson (Verilab).
like construct is used when someone wants to derive a child object from the already defined struct/unit. This derived child will have new struct/unit name. When someone derive the child object using when construct, the base name of the child will remain the same.
Another difference between like and when construct is that, once the child is derived using like inheritance, one can not add extra fields in the parent struct/unit, wherease, if child is derived using when construct, parent struct/unit can have extra fields.
Take a look at the following example. packet_valid field is added in the parent struct packet_s after the child is derived using like inheritance. This is not allowed and Specman will issue an error during loading phase.
Specman will issue following error.
*** Error: Cannot add new field 'packet_valid' to struct 'packet_s': it has like children (e.g. 'good_packet_s') with fields.
Note that ack() method will be added in the parent struct packet_s even though child is derived using like inheritance.