You need the following
(1) Within a forever loop use uvm_config_db#(bit)::wait_modified( this ,“” , “enable_bit” ) followed by uvm_config_db#(bit)::get( this ,“” , “enable_bit” , check_enable ) as a separate thread in my_monitor to fetch
Using the config_db() in this manner is not recommended. The config_db() is designed to pass configuration data down the testbench hierarchy at time 0, not to pass data between components while the testbench is running.
I would argue that there should be no need to enable/disable your monitor functionality at any time. The monitor should be aware when the data it is monitoring is valid (reset signal/data valid signal, etc.).
If you really feel the need to alter the behavior of your monitor, add an element to your agent’s configuration object. You can then also pass the configuration object to your sequence and modify as required.
Actually, it’s that I would like to disable some of the checking in the monitor for the error injection cases. So, what is a better approach instead?
If you are running a test which generates error scenarios, then you should configure the agent’s configuration object to disable the desired checks as part of the test.