I want to create a clock in my top level testbench whose period can be controlled from the test. What I did was set the period into the uvm_config_db and get it back in the testbench. I had to put in a #1 to make sure that the build phase was finished, otherwise the get returned the wrong value:
module testbench_top;
int clk_period;
bit clk = 0;
initial begin
#1;
void'(uvm_config_db #(int) ::get(null, "uvm_test_top.env", "clk_period", clk_period));
// Create clk
forever begin
#(clk_period/2) clk = !clk;
end
end
I am annoyed by the #1. Is there a better way to check that the config has been set? Can I somehow block until start_of_simulation_phase?