I have used the m_ prefix for "member variables," but I'm learning that the UVM Cookbook guidelines say this should only be for local or protected member variables. The UVM Cookbook says the following about the m prefix:
2.2 Guideline: Private class members should have a m_ prefix
Any member that is meant to be private should be named with a 'm_' prefix, and should be made local or protected. Any member that will be randomized should not be local or protected.
When I look at the UVM source, I see several member variables that are prefixed with m_ but are not local or protected. Also, the UVM Cookbook examples have several variables with m_ that are not local or protected, and are assessed as public members, like the following example:
class test_mac_simple_duplex extends uvm_test;
wb_config wb_config_0; // config object for WISHBONE BUS
function void set_wishbone_config_params();
// set configuration info
// NOTE The MAC is WISHBONE slave 0, mem_slave_0 is WISHBONE slave 1
// MAC is WISHBONE master 0, wb_master is WISHBONE master 1
wb_config_0 = new();
if (!uvm_config_db #(virtual wb_m_bus_driver_bfm)::get(this, "", "WB_DRV_BFM", wb_config_0.wb_drv_bfm))
if (!uvm_config_db #(virtual wb_bus_monitor_bfm)::get(this, "", "WB_MON_BFM", wb_config_0.wb_mon_bfm))
wb_config_0.m_wb_id = 0; // WISHBONE 0
wb_config_0.m_mac_id = 0; // the ID of the MAC master
wb_config_0.m_mac_eth_addr = 48'h000BC0D0EF00;
wb_config_0.m_mac_wb_base_addr = 32'h00100000;
wb_config_0.m_wb_master_id = 1; // the ID of the wb master
wb_config_0.m_tb_eth_addr = 48'h000203040506;
wb_config_0.m_s_mem_wb_base_addr = 32'h00000000;
wb_config_0.m_mem_slave_size = 32'h00100000; // 1 Mbyte
wb_config_0.m_mem_slave_wb_id = 0; // the ID of slave mem
wb_config_0.m_wb_verbosity = 350;
uvm_config_db #(wb_config)::set(this, "*", "wb_config", wb_config_0);
function void build_phase(uvm_phase);
In the "Task And Functional Call Argument Passing" section some code in the cookbook is using m_ for a function's local variable. What's the rational for this?
function automatic void do_it(ref int q[$], ref string name);
$display("string = %s, value = %0d", m_s, m_i);
This is confusing for me since these are not a member variables.
It seems a lot of the guideline and rules are not followed in the cookbook code examples and for me I get distracted and bogged down by the inconsistencies. Is there a plan to update the examples to align with the guildelines/rules to introduce some consistency?