Quantcast
Channel: UVM Forums RSS Feed
Viewing all articles
Browse latest Browse all 756

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

$
0
0

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


Viewing all articles
Browse latest Browse all 756

Trending Articles