Usage of Grab/Lock Sequence

Hi All,

I have a question of implementation and usage of grab sequence. I did some experiments with the available in-built ovm example at the following directory :
…/ovm-2.0/examples/sequence/simple

We have 7 sequences in all along with 4 user-defined sequences. In the test.sv i did the following modification:


sequencer.print();
driver.print();

fork
begin
#300;
if(sequencer.is_grabbed())
$display(“@%0t simple_seq_sub_seqs_obj grabed”,$time);
else
$display(“@%0t simple_seq_sub_seqs_obj Fail for grabed”,$time);

 sequencer.grab(simple_seq_sub_seqs_obj);
                
 if(sequencer.is_grabbed())
   $display("@%0t simple_seq_sub_seqs_obj grabed",$time);            
 else        
   $display("@%0t simple_seq_sub_seqs_obj Fail for grabed",$time);            

end
join

fork
begin
run_test();
#1500 global_stop_request();
end
join


The default sequence is ovm_random_sequence. Also I have overwritten the value of “count” variable to 3.

As a result, in absence of the above code, the output shows execution of 3 sequences in random order. When I put the above code in place I expect simple_seq_sub_seqs sequence(simple_seq_sub_seqs_obj is object of simple_seq_sub_seqs) to be grabbed. Hence as a result, I expect this sequence to be executed first. However what I see is no sequence is called. The simulation ends without executing any sequence.

Can anyone tell me what’s wrong over here??

Thanks,
AD

Hello ashishd:

From your description, I can’t tell what part is failing. There are several possible things that could be going wrong. I would check a couple of things:

First, I’m assuming that the test code you show actually gets executed and gets the lock for the specific sequence. You might want to print out the object id of both the reference and the actual sequence to make sure they match - that is, the sequence you are requesting the lock for is actually the sequence that you are running.

Assuming that is so, the reference you are using must point to a sequence that is actually requesting an operation. Has that sequence already issued a request? Can you have it fork a process that just prints the result of is_locked() - that will show you if it thinks it actually has the lock. Finally, make sure that it is actually requesting an operation.

-Andy

Hi Andy,

Can you please elaborate?
I am not getting your point. I would appreciate if you can show me the code as well.

Thanks,
AD

Unfortunately, you haven’t shown enough code for me to see what might be wrong.
From your post, it sounds like the sequence itself may be stuck (is it running?) Since you don’t show your sequence code, I can’t tell what is happening there.

Here are some more specific questions that might help determine what went wrong:

When you run, what messages do you see from your $display statements?

In your sequence, can you also call $display immediately before and after you issue a request (either your `ovm_do, wait_for_grant(), or start_item() call)

  1. Can you add the following to each display statement in both the grab code and the sequence. This will show that the two code segments are referring to the same object:
    object_id: %0d - matched with - simple_seq_sub_seqs_obj.get_inst_id()

  2. Can you add the following to each display statement: - show the sequence locked state:
    seq is_locked: %0d is_blocked: %0d - matched with - is_blocked(), is_locked()

With that information, it might be possible to determine what is going wrong without seeing your code

-Andy

Thanks a lot Andy.

I apologize for not providing the code earlier. I thought the piece of code that i gave should be enough.

OK. So i have implemented all your feedback points. However the problem is not a single $display statement embedded in the sequence gets displayed. Only the $display of test.sv gets displayed in which it says that the sequence is grabbed. So its clear that the sequence is not executed at all.

For your reference, I have attached entire simple directory in the zip format. The files that I have modified are test.sv and simple_seq_lib.sv.

Here is the code of test.sv

fork
begin
  #300;
  if(sequencer.is_grabbed())
    $display("@%0t simple_seq_sub_seqs_obj grabed Instance ID = %0d",$time,simple_seq_sub_seqs_obj.get_inst_id());              else        
    $display("@%0t simple_seq_sub_seqs_obj Fail for grabed. Instance ID = %0d",$time,simple_seq_sub_seqs_obj.get_inst_id());            

  sequencer.grab(simple_seq_sub_seqs_obj);
                
  if(sequencer.is_grabbed())
    $display("@%0t simple_seq_sub_seqs_obj grabed Instance ID = %0d",$time,simple_seq_sub_seqs_obj.get_inst_id());              else        
    $display("@%0t simple_seq_sub_seqs_obj Fail for grabed Instance ID = %0d",$time,simple_seq_sub_seqs_obj.get_inst_id());            
      
  $display("Instance ID : %0d",simple_seq_sub_seqs_obj.get_inst_id());
  sequencer.stop_sequences();
  sequencer.start_default_sequence();

  //$display("has_do_available=%0d",sequencer.has_do_available());   
     
  if(sequencer.is_blocked(simple_seq_sub_seqs_obj))
    $display("@%0t simple_seq_sub_seqs_obj blocked Instance ID = %0d",$time,simple_seq_sub_seqs_obj.get_inst_id());    
  else        
    $display("@%0t simple_seq_sub_seqs_obj Fail for blocking Instance ID = %0d",$time,simple_seq_sub_seqs_obj.get_inst_id());            
end                    
join

Here is the code of seq_lib.sv specifically only simple_seq_sub_seqs

class simple_seq_sub_seqs extends ovm_sequence #(simple_item);

  function new(string name="simple_seq_sub_seqs");
    super.new(name);
  endfunction
  
  `ovm_sequence_utils(simple_seq_sub_seqs, simple_sequencer)    

  simple_seq_do seq_do;
  simple_seq_do_with seq_do_with;
  simple_seq_do_with_vars seq_do_with_vars;



  virtual task body();
    ovm_report_info(get_name(), $psprintf("In body() of %s", get_name()),1000);
    #100;
    $display("Now Starting to call a sequence seq_do. Instance ID is %0d",get_inst_id());
    `ovm_do(seq_do)
    #100;
    $display("Now Starting to call a sequence seq_do_with. Instance ID is %0d",get_inst_id());
    `ovm_do(seq_do_with)
    #100;
    `ovm_do_with(seq_do_with_vars, { seq_do_with_vars.start_addr == 16'h0003; seq_do_with_vars.start_data == 16'h0009; } )
  endtask
  
endclass : simple_seq_sub_seqs

Here is the output:

# @300 simple_seq_sub_seqs_obj Fail for grabed. Instance ID = 35
# @300 simple_seq_sub_seqs_obj grabed Instance ID = 35
# Instance ID : 35
# @300 simple_seq_sub_seqs_obj Fail for blocking Instance ID = 35
# OVM_INFO @ 300 [RNTST] Running test ...
# OVM_ERROR @ 9200000000000 [TIMOUT] Watchdog timeout of '85e0abb5ed4' expired.

Attached are the same files.
Please provide your inputs on where I am wrong.

Thanks,
Ashish

Hi Ashish,

In test.sv file,
You have added all your logic of grabbing before the run_test is triggered.
(b’coz run_test and the grabbing logic are in diff. fork-join loops which is not needed at all)
So this logic will make no diff. to sequencer.

Modify this logic by invoking run_test() first and then adding a logic of grabbing any seq.
Happy learning.

-Shunty :D