Jump to content

Is there any obligation in using dynamic delay while starting the sequences


Recommended Posts

Hello All ,

 

I am wandering that why virtual sequence not allowing me to implement delays :

 

Consider the following three cases -

 

1 .

//-------------------------------------------------------------
// This virtual sequence does SPI boot default 
// ------------------------------------------------------------
class sfc_default_boot_vseq extends sfc_seq_base;

`uvm_object_utils(sfc_default_boot_vseq)
//----------------------------------------//
//        Data Members                    //
//----------------------------------------//
rand int delay;
int delay_p;
//----------------------------------------//
//        Typedef                         //
//----------------------------------------//
rand enum {ZERO,SHORT,MEDIUM,LONG,CRITICAL} delay_t;
//----------------------------------------//
//        Contraining the delay           //
//----------------------------------------//
// Contraint on delay 
constraint c_delay{
    (delay_t == ZERO)       ->  {delay == 0};
    (delay_t == SHORT)      ->  {delay inside {[1:500]}};
    (delay_t == MEDIUM)     ->  {delay inside {[1000:2000]}};
    (delay_t == LONG)       ->  {delay inside {[2000:50000]}};
    (delay_t == CRITICAL)   ->  {delay inside {[19000:22000]}};

}
// Contraint on weightage 
constraint c_dist{
    delay_t dist { ZERO := 4, SHORT := 1, MEDIUM := 1, LONG := 1, CRITICAL := 2};
}
////----------------------------------------//
////        Post Randomize                  //
////----------------------------------------//
function post_randomize();
    delay_p = delay;
    // Coverage generation
    default_boot_delay_cov.sample();
endfunction


function new(string name = "sfc_default_boot_vseq");
  super.new(name);
endfunction



task body;
  // Sequences to be used
  sfc_default_boot_seq default_boot_seq = sfc_default_boot_seq::type_id::create("default_boot_seq");
  super.body;

   begin
     
       repeat(10)begin
            if(!this.randomize() with {delay_t == SHORT;})begin
                 `uvm_error("VIRTUAL SEQ", $sformatf("Randomization error for CDM seq selection"))
            end

            default_boot_seq.start(m_t3_sequencer);
            $display ("JUST_CHECK: value of delay_p in default_boot = %d",delay_p);
            #(delay_p*1ns);
       end
  end
  
endtask
 
endclass: sfc_default_boot_vseq

2. Making all this delay processing as a seq_item class and randomizing that class here only and getting its delay variable.

repeat(10)begin
            if(!system_delay.randomize() with {delay_t == SHORT;})begin
                 `uvm_error("VIRTUAL SEQ", $sformatf("Randomization error for CDM seq selection"))
            end

            default_boot_seq.start(m_t3_sequencer);
            $display ("JUST_CHECK: value of delay_p in default_boot = %d",delay_p);
            #(system_delay.value*1ns);
            
       end

3. Using static delay #1000ns

repeat(10)begin
            if(!this.randomize() with {delay_t == SHORT;})begin
                 `uvm_error("VIRTUAL SEQ", $sformatf("Randomization error for CDM seq selection"))
            end

            default_boot_seq.start(m_t3_sequencer);
            $display ("JUST_CHECK: value of delay_p in default_boot = %d",delay_p);
            ///#(delay_p*1ns);
            #1000ns;
       end

No. 3 works only for me , can you please tell where is problem in others , since getting the printed value of delay fine in case of 1 and 2. Why can't I use dynamic or constrained random delay over here. What can be the possible alternative.

 

Thanks ,

Karandeep

Link to comment
Share on other sites

It is :

 

rand enum {ZERO,SHORT,MEDIUM,LONG,CRITICAL} delay_t;

rand int delay;  /// random variable
int delay_p;  // static variable

 

// Contraint on delay
constraint c_delay{
(delay_t == ZERO) -> {delay == 0};
(delay_t == SHORT) -> {delay inside {[1:500]}};

 

function post_randomize();

delay_p = delay;

////

 

This was done just make iteration on the believe that may rand variables not interfere anything.

 

delay_t enum used to constraint the values of delay which in post randomize function assigned to delay_p.

 

Hope I am able to answer what you ask. 

 

It is compiling well and printing the delay_p value as expected but the sequences are unable to start

 

Thanks ,

Karandeep

Link to comment
Share on other sites

I misread your code, sorry, now I see it should work. What I would check are the time scale settings. If you have a time unit of 10 NS and you're just trying to delay for 1 NS, then you won't see anything. Here's an example of what I mean:

module top;
  timeunit 10ns;

  initial begin
    $display("Time is ", $time);
    #20ns;
    $display("Time is ", $time);
    #1ns;
    $display("Time is ", $time);
    $finish();
  end

endmodule // top

You'll see that the last delay does not advance time, because the simulator only "understands" steps of 10 nano-seconds. The value "1000 ns" that you have is pretty large, but your delays might be getting randomized to smaller values that are under the tmeunit of the package your class is in.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...