Differences between lock sequence and grab sequence

Hi All,

I am a newbie in OVM and would like to get some insights on locking and grabbing a sequence.

  1. What is the exactly difference between locking and grabing a sequence?? The descriptions
    in the Reference Docs regarding lock() and grab() is same.

    Is the difference concerning “only” the arbitration scheme? Or is there anything more?? If
    yes, please shed some light on that.

  2. Can you site an example showing the practical usage of locking and grabbing a sequence?

  3. Why do we require one more task is_blocked() if we already have is_locked() and
    is_grabbed(). The descriptions of is_blocked and is_locked are same in the Reference Docs.

Thanks,
AD

Hello ashishd:

The difference between lock and grab is only in arbitration. Otherwise, they are the same. A grab will jump ahead of previously queued requests, while a lock will queue behind earlier requests. Unlock and ungrab are synonyms.

A single-level interrupt can be created with grab operations (a multi-level interrupt scheme is easiest done via sequencer arbitration in my view). When an interrupt occurs, the interrupt handler sequence can issue a grab to lock all other sequences out immediately after the interrupt is received.

A processor cache coherency test may need sole access to perform atomic read-write operations. In that case, the arbitration may well be used to add randomness to the test. So a lock will provide access based on the sequencer arbitration.

They are similar, but definitely different funtions. Is_locked indicates that the sequence owns the lock. is_blocked indicates that another sequence owns the lock, and this sequence is blocked.

-Andy

Thanks a lot Andy.

Your explanations helped. :)

Regards,
AD

In reply to ashishd:

Hi,
i used grab and lock in virtual sequence. i used four subsequences in this code. When i execute this code, i am not getting high priority to grab sequence(last parallel thread of fork-join). Can any one tell, where i have done wrong?

[b]class tx_rx_sequence extends ovm_sequence;

eth_bad_crc_seq tx_seq;
eth_bad_crc_rx_seq rx_seq;
eth_good_crc_seq tx_good_seq;
eth_good_crc_rx_seq rx_good_seq;

function new(string name = “tx_rx_sequence”);

super.new(name);

endfunction :new

`ovm_sequence_utils(tx_rx_sequence,mcs_vir_sequencer)

virtual task body();

fork
begin
if(p_sequencer.rx_sequencer !== null)
p_sequencer.rx_sequencer.lock(this);
//ovm_do_on(tx_seq,p_sequencer.tx_sequencer); ovm_do_on(rx_seq,p_sequencer.rx_sequencer);

if(p_sequencer.rx_sequencer !== null)
p_sequencer.rx_sequencer.unlock(this);
end
begin
if(p_sequencer.tx_sequencer !== null)
p_sequencer.tx_sequencer.lock(this);
ovm_do_on(tx_seq,p_sequencer.tx_sequencer); //ovm_do_on(rx_seq,p_sequencer.rx_sequencer);

if(p_sequencer.tx_sequencer !== null)
p_sequencer.tx_sequencer.unlock(this);
end
begin
if(p_sequencer.rx_sequencer !== null)
p_sequencer.rx_sequencer.lock(this);
//ovm_do_on(tx_seq,p_sequencer.tx_sequencer); ovm_do_on(rx_good_seq,p_sequencer.rx_sequencer);

if(p_sequencer.rx_sequencer !== null)
p_sequencer.rx_sequencer.unlock(this);
end
begin
if(p_sequencer.tx_sequencer !== null)
p_sequencer.tx_sequencer.grab(this);
ovm_do_on(tx_good_seq,p_sequencer.tx_sequencer); //ovm_do_on(rx_seq,p_sequencer.rx_sequencer);

if(p_sequencer.tx_sequencer !== null)
p_sequencer.tx_sequencer.ungrab(this);
end

join

endtask

endclass:tx_rx_sequence

THanks & Regards,
sudheer

Hi…
I am beginner of OVM…
I am not getting the exact difference between lock() and garb() methods of OVM sequence.

When I go throgh the example in testbesnc.in, then, both methods are showing same output. So, I am not able to get the difference.

It will be better if somebody can help with example…

Thanx

In reply to Anamika Sharma:

There would only be a difference if there are more than one process requesting a grab or lock.

grab() is the same as lock() except a grab() goes to the front of the queue of processes waiting for exclusive access to a sequencer, and lock() goes to the back of the queue.

In reply to dave_59:

Hi Anamika,

After looking at the example in testbesnc.in. I think it shows an erroneous output for grab().
example link: WWW.TESTBENCH.IN - OVM Tutorial

output of lock() is correct:
0: Driving Instruction PUSH_A
10: Driving Instruction POP_C
20: Driving Instruction PUSH_A
30: Driving Instruction PUSH_B
40: Driving Instruction PUSH_B
50: Driving Instruction PUSH_B
60: Driving Instruction PUSH_B
70: Driving Instruction POP_C
80: Driving Instruction PUSH_A
90: Driving Instruction POP_C
100: Driving Instruction PUSH_A
110: Driving Instruction POP_C

output of grab() should be:
0: Driving Instruction PUSH_B
10: Driving Instruction PUSH_B
20: Driving Instruction PUSH_B
30: Driving Instruction PUSH_B
40: Driving Instruction PUSH_A
50: Driving Instruction POP_C
60: Driving Instruction PUSH_A
70: Driving Instruction POP_C
80: Driving Instruction PUSH_A
90: Driving Instruction POP_C
100: Driving Instruction PUSH_A
110: Driving Instruction POP_C

Regards,

Pengfei