Specman e: When colon equal sign ":=" should be used?

208 views Asked by At

I saw in some Specman e code example the use of := (colon-equal sign), e.g.:

var regs_type := rf_manager.get_exact_subtype_of_instance(graphics_regs);

When and why should we use := ? Thank you for your help.

1

There are 1 answers

0
Tudor Timi On BEST ANSWER

The := means declare a variable of the type the expression on the right returns and assign it to that value. Basically, in your example, the function get_exact_subtype_of_instance(...) returns a value of type rf_struct. The regs_type variable will be declared to that type.

This code is equivalent to (but shorter than):

var regs_type : rf_struct = rf_manager.get_exact_subtype_of_instance(graphics_regs);

This syntax is particularly helpful when casting:

 var foo := some_struct.as_a(FOO some_struct_type);