How long is get_next_item() thread active?

Hi,

For the following code:

fork 
  @negedge(RESETn);
  seq_item_port.get_next_item(item);
join_any 
disable_fork;

drive_tr();
item_done();

If both the threads of fork start at the same time and disable_fork is called, the item_done would not have an outstanding request?

Thanks,
Pushkar

In reply to pushkar111:

In driver, get _next_item will Send a request to the sequencer to get the sequence item and wait for the sequence item.
On the other side in sequence, start_item(req) will wait for the grant from the sequencer. The sequencer will grant the sequence once the driver sends the request(get_next_item). Once it gets the grant the req will be randomized & finish_item will give the sequence item to the driver and wait for the driver-sequencer handshake(item_done)


task body();
  
     start_item(req);// will wait for get_next_item from driver
     assert(req.randomize());
     finish_item(req);// delivers the sequence_item to driver & waits for item_done from driver
 
endtask 

In driver,

seq_item_port.get_next_item(req);// wait for finish_item from the sequnce
         
seq_item_port.item_done();// completes the driver-sequencer handshake and it should be called after get_next_item() 


item_done can not be called until get_next_item is unblocked. In your code, there are chances that item_done can be called before get_next_item is unblocked. So it’s not the proper way of writing the code.
And can you explain how negedge of reset & get_next_item are related in your code

Regards,
Shanthi

In reply to shanthi:

Shanthi,

Thanks for the explanation. I wanted to understand that will disable_fork affect get_next_item().
My understanding of handshaking is :

  1. get_next_item thread is blocked until we get a transaction from the sequencer.
  2. get_next_item will block the driver to get another transaction before item_done.

I know this is not the proper way of writing driver code. I am seeing some issues in my driver code. This snippet just simplifies the problem. I wanted to understand what will happen to get_next_item due to disable_fork. How item_done is affected?

In reply to pushkar111:

Suppose sequence is not started or not able to generate sequence item till the event negedge of reset is triggered, get_next_item will get disabled due to disabling fork but item_done will be called due to which run time error as below will be generated.
Item_done() called with no outstanding requests. Each call to item_done() must be paired with a previous call to get_next_item().

Regards,
Shanthi

In reply to shanthi:

Your construct

fork 
  @negedge(RESETn);
  seq_item_port.get_next_item(item);
join_any 
disable_fork;
 
drive_tr();
item_done();

is not really useful because it depends on the timing of your reset and it violates the rule that get_next_item and item_done has to be called as a pair.
It is legal what you want to do, but it is useless and might cause problems.