Elaboration time constant for enumerated type.num()

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?

This functionality was enabled indirectly via a fix in the IEEE 1800-2023 SystemVerilog LRM
You would have to do

my_t my_v;
localparam MY_TYPE_NUM = my_v.num()

But as of this date, tools have not implemented this yet, and I cannot think of a workaround unless you provide more information on what you are trying to accomplish.

Thanks for the response Dave. It’s at least good to know that a fix is in the works, and that I didn’t miss something obvious.

I’ve got workarounds - which are ugly. Basically, just have the calling module not only pass down the parameterized type, but also the number of enumerations in that type as a separate parameter.