How to configure monitor from sequencer after item randomization

Hi
I need some help with the following issue I have learning the uvm flow. In the environment a uart is under test. I’ve written a monitor for catching DUT transmit packets. The uart allows programming for the number of data bits, number of stop bits, parity enable and baud rate so before transmitting data the monitor needs to be configured. This is where I am stuck. If I use a fixed configuration then the monitor correctly gets the data and scoreboard checks on the packet work. However when the configuration is randomized then the monitor has no idea of the new configuration so cannot correctly decode the transmit packet. This randomization is done in a virtual sequencer if that’s significant.

Below is my test topology. In m_uart_tx_agent.m_monitor there is a function named config() that I wish to access. In uart_ctrl_tx_poll_test I can call the function with m_env.m_uart_tx_agent.m_monitor.config() and this works. As mentioned item randomization is done in the sequence not in the test. From the virtual sequencer I’ve been unable to access the function. I appreciate that using dot hierarchy is not recommended with uvm for reuse but it’s all that I can get working at the moment. Any advice or examples on this issue would be greatly appreciated.

--------------------------------------------------------------------------

Name Type Size Value

--------------------------------------------------------------------------

uvm_test_top uart_ctrl_tx_poll_test - @470

m_env uart_ctrl_env - @569

apb2reg_predictor uvm_component - @588

bus_in uvm_analysis_imp - @595

reg_ap uvm_analysis_port - @603

m_apb_agent apb_agent - @581

m_driver apb_driver - @653

m_monitor apb_monitor - @646

m_sequencer apb_sequencer - @676

m_reg_func_cov_monitor uart_ctrl_reg_functional_coverage - @622

analysis_imp uvm_analysis_imp - @629

m_scoreboard uart_ctrl_scoreboard - @637

apb uvm_tlm_analysis_fifo #(T) - @801

m_uart_tx_agent uart_transmit_agent - @615

m_monitor uart_transmit_monitor - @849

--------------------------------------------------------------------------

Thanks
Andrew

The key is that you want to make sure that your monitor and UART are configured exactly the same way. The recommendation is to use a configuration object that includes data members to hold the information.


class uart_cfg extends uvm_object;
  `uvm_object_utils(uart_cfg)
   rand int numdatabits;
   rand int numstopbits;
   rand bit parityenable; 
   rand int baudrate;

  constraint{...};
endclass

or something like that. Once you have this, it’s an easy matter of passing it down to your monitor via the uvm_config_db:


   uvm_config_db #( uart_cfg )::set( this , "*.monitor" , "mon_config" , uart_config );

see the Cookbook here for details.
The other thing you need to do is to pass the same configuration object to your sequence to program the DUT.


 uvm_config_db #( uart_cfg )::set( this , "agent1.sequencer.config_seq" , "uart_config" , uart_config );

see the Cookbook here for details on configuring a sequence. Once configured, the sequence will extract the settings from the configuration object and perform the appropriate transactions to program the DUT, just as the monitor will use the same settings to configure itself to look for the desired packets.
There’s really no need for a virtual sequencer, which we don’t ever recommend anyway.
Good luck,
-Tom

Hi Tom
Thanks a lot for taking the time to give this detailed answer. It’s much appreciated and very helpful.

Regards
Andrew