I have a BFM in my tx agent (without a sequence driver).
extend uart_tx_agent_u{
uart_tx_monitor : TX uart_monitor_u is instance;
uart_tx_scb: uart_tx_scoreboard_u is instance;
when ACTIVE uart_tx_agent_u {
uart_bfm : uart_tx_bfm_u is instance;
};
};
When I run the test (I don't change the active_passive field) I can see that the uart_bfm was created (according messages which are printed).
Are you sure you want to change the constraint from test to test? Either the agent is active and sends data to the DUT, or it is passive and only collects data sent from the DUT.
What people usually do is to define the agent as ACTIVE, so that it has a sequence driver and a BFM.
In the test files, you define the scenarios for the tests, by defining the sequences for this agent.
So in tests that you do not want to send any data to the DUT from this agent, set the sequence to do nothing -
extend MAIN my_seq {
body() @drive.clock is only {
// do nothing, this agent should not send data in this test
};
};
If you really want to change the environment topology, and in some tests the agent is to be PASSIVE and in some to be ACTIVE, you can do this in the test file, by constraining the agent.
And this constraint has to be in the pre-run generation. Through the test - the agent is either ACTIVE or not. This cannot be change during the run. You cannot say "i start the test with a PASSIVE agent, but during the test i want to make it ACTIVE".