Interrupt a driver in a middle of transaction

Hello,

How can I stop a driver that is in a middle of a task if a sequence sends a new transaction request with an higher priority?
In this case I would like to stop the current item transaction and start the new one immidietly. after that I want to restart the last item transaction.
I would like to enable this behavior recursively (the new request can also be interrupted).

Thanks

It sounds to me like your driver needs to accept request transactions from the sequence and store them in a buffer according to priority, then when each one is completed it is removed from the data-structure. When a higher priority transaction comes along, then you override the one currently executing. Once that completes then the driver works down the list of outstanding requests according to priority.

In reply to mperyer:

Thank you,
The buffer in your solution sounds to me like the fifo in the sequencer - what is the difference?
I have an idea but I don’t know how to write it:
my driver return a response using get() and put() (put is after the transaction is over - takes some time).
After the first transaction gets in, Is it possible to use peek (or any other function I don’t know) in order to see if a new request has come? and when the new request would come to insert the current item into the sequencer’s fifo and to start over the transaction with the new item using disable fork to break the current transaction?

What I mean:

forever
begin
get();
fork
start_transaction();
wait_for_new_request_with_higher_priority();
join any
if(new_request_item_priority > current_priority)
insert_current_item_to_sequencer_fifo();
end

I recommend that you keep away from trying to do anything with FIFOs in the sequencer.

What I am suggesting is that you implement a prioritised buffered transaction handling system in your driver:

task run_phase(uvm_phase phase); fork send_transactions_according_to_priority; forever begin get(item); put_item_into_queue_according_to_priority(item); end join endtask

task send_transactions_according_to_priority;
fork
begin
if(current_transaction_priority < highest_priority) begin
set_transaction_stop(1);
end
end
forever begin
get_highest_priority_item(item);
while(transaction_stop == 0) begin
move_to_next_state;
if(state = end_state) begin
put(item); // Returning response
clear_item_from_prioritised_queue(item);
break;
end
end
end
join
endtask

This is unlikely to be straight-forward, so are you actually trying to address a realistic requirement?

It is usually very disruptive to abort a real protocol transfer. For instance with a bus protocol you allow the current transaction to complete before starting a higher priority transfer. If this seems to match the scenario, then you should look at sequence locking and priorities as per:

https://verificationacademy.com/cookbook/Sequences/LockGrab
https://verificationacademy.com/cookbook/Sequences/Priority