Hi,
I am getting a bit confused or stuck in this scenario on how to execute this?
I want two threads to run parallely, first one is just number of cycles (~20) and second one is checking expected and actual value. If within 20 cycles, these values match, I want to print uvm info, else give out uvm_error, I tried something like this:
fork
// First thread to run for 20 cycles
begin
#20
end
// Second thread to do comparison
begin
if(a==0) assert (x==y)
`uvm_info(get_name() .....................);
end
join_any
`uvm_error(Check condition failed);
If second thread finishes first, I would still get uvm_error, what’s the best approach to solve this? I want to disable fork as soon as uvm_info is done.
Thanks
You need to provide more details. Your second thread lacks a timing mechanism, which means it executes immediately and potentially completes before the first thread even begins. Do you want the second thread to wait for the condition to be true? If so, then if, by the end of the 20 cycles, it hasn’t found a match, you issue an error.
Additionally, what do you want to happen with the first thread once the second thread finds a match?
Yes, second thread is getting checked at every clock cycle, and within 20 cycles if assert is true, I want to print uvm info (“condition matched”), else after 20 cycles, I want uvm_error.
If second thread is successful, I want to disable the fork
Basically, I am checking condition for 20 cycles, if it matches, stop and print uvm_info else $uvm_error
Maybe this would work:
fork
// First thread to run for 20 cycles
begin
repeat (20) @(posedge clk);
`uvm_error(Check condition failed);
end
// Second thread to do comparison
begin
forever @(posedge clk)
if ((a==0) && (x==y)) begin
`uvm_info(get_name() .....................);
break;
end
join_any
disable fork;
I have one concern here:
forever begin
@(posedge clk)
fork
// First thread to run for 20 cycles
begin
repeat (20)
`uvm_error(Check condition failed);
end
// Second thread to do comparison
begin
if ((a==0) && (x==y)) begin
`uvm_info(get_name() .....................);
break;
end
join_any
disable fork;
In this case, break statement is not allowed, how can I exit from the second thread?
I think I can use disable_fork inside second thread after comparison is done, does that sound right?
No, disable fork
only kills the child threads of the parent thread where the disable is located. You probably want:
forever begin
fork
// First thread to run for 20 cycles
begin
repeat (20) @(posedge clk);
`uvm_error(Check condition failed);
end
// Second thread to do comparison
begin
forever @(posedge clk)
if ((a==0) && (x==y)) begin
`uvm_info(get_name() .....................);
break;
end
join_any
disable fork;
end