I’m trying to create a localparam based on a parameterized type. The type passed will always be an enumerated type.
module enum_test2
#(
type my_t = enum reg [ 1 : 0 ] { MY_ENUM[3] }
)();
localparam MY_TYPE_BITS = $bits( my_t );
$info( "MY_TYPE_BITS = %0d", MY_TYPE_BITS );
localparam MY_TYPE_SIZE = $size( my_t );
$info( "MY_TYPE_SIZE = %0d", MY_TYPE_SIZE );
//localparam MY_TYPE_NUM = my_t.num()
//$info( "MY_TYPE_NUM = %0d", MY_TYPE_NUM );
my_t dummy;
initial $display( "dummy.num() = %0d", dummy.num() );
endmodule
module top2();
typedef enum reg [ 1 : 0 ]
{
FOO[3]
} foo_t;
enum_test2 #( .my_t( foo_t ) ) foo_test();
typedef enum reg [ 2 : 0 ]
{
BAR[6]
} bar_t;
enum_test2 #( .my_t( bar_t ) ) bar_test();
endmodule
I’d like the commented out code to work. Basically - I want to access the enumerated type .num() value - as an elaboration time constant. Is there any hope here for getting this to work?