Basically, I am trying to set up a fork to collect the period of a clock inside a fork block, or to return an error after a delay if the clk is frozen.
int clk_period = 0;
fork
repeat (2) begin
@(posedge env.vif.clk);
clk_period = $time - clk_period;
end
begin
#1us;
end
join_any
disable fork;
if(~clk_period)
`uvm_error("etc", "etc")
With this code my simulation promptly freezes. The question is why?
Without more context, it is hard to know. You need to debug interactively to see where it is hanging, or add lots of messages.
Also, you need to be care using disable fork to make sure it only kills the child processes in the fork/join_any above it. Soemtimes that means encapsulating the code above an isolating fork begin… end join
int clk_period = 0;
// are there any existing child processes of the current thread at this point?
fork begin : isolation_process
fork
repeat (2) begin
@(posedge env.vif.clk);
clk_period = $time - clk_period;
end
begin
#1us;
end
join_any
disable fork; // all children of current process get killed
end : isolation_process
join
if(~clk_period)
`uvm_error("etc", "etc")