So I have the following code in bool_struct.sv:
typedef enum {false=0, true=1} bool;
class my_bool_class;
bool my_bool_value;
function new (bool initial_bool_value)
my_bool_value = initial_bool_value;
endfunction
endclass
In checker.sv I want to do the following:
class checker;
my_bool_class bool_class_handle = new(true)
endclass
My question is, will this compile? I imagine the "true" in the new call will be out of the scope of the typedef so it will not. How do I get that "true" in the new call to work?
A typedef
for an enumerated type declares all the labels as well as the enumeration at the same level (That is why you cannot declare two different enumerations with overlapping labels in the same scope).
What you should always do is put typedef
s and class declarations in a package
and then import
the package where you want to use bool
, false
, true
, and my_bool
.