Parameterized class with typedef variables

Hello,

How can I parameterize my uvm class with typedef variables? I’m doing this, but it gives syntax error.

my monitor:

typedef enum { SRC, DST ) kind_e;

class my_monitor#( type kind=kind_e ) extends uvm_monitor;

 `uvm_component_param_utils_begin( my_monitor#( kind ) )
 ....

my_env:

class my_env extends uvm_env;

 my_monitor monitor;

 function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    monitor = my_monitor#( SRC )::type_id::create( "monitor", this );
    ....

Hi,

There are 2 parts to answer your question.

  1. When you mention
type kind=kind_e

, it is the default value if someone does not say what datatype my_monitor the user wants.
2.

monitor = my_monitor#( SRC )::type_id::create( "monitor", this );

means we want the monitor to work with the datatype called SRC.

In this case, the datatype called SRC si not defined, hence the error.

Regards,
Ashith

In reply to Ashith:

Thank you Ashith. I think I understood my mistake.