karandeep963 Posted August 29, 2014 Report Share Posted August 29, 2014 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 Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 29, 2014 Report Share Posted August 29, 2014 Are you sure it isn't supposed to be "delay_p" everywhere you used "delay_t" in constraints, because "delay_t" is the type, whereas "delay_p" is the name of the variable. I hope it's a type, otherwise I wouldn't expect it to compile. Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 29, 2014 Author Report Share Posted August 29, 2014 It is : rand enum {ZERO,SHORT,MEDIUM,LONG,CRITICAL} delay_t; rand int delay; /// random variableint delay_p; // static variable // Contraint on delayconstraint 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 Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 29, 2014 Report Share Posted August 29, 2014 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. Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 29, 2014 Author Report Share Posted August 29, 2014 Many Thanks Tudor for your time, But timescale I am using is 1ns/1ns. I have constrained the random values to in thousands{1000:10000} as well, but it doesn't help. -Karandeep Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 29, 2014 Report Share Posted August 29, 2014 What is the exact symptom then? If you print the time after the delay do you see it advance? Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 29, 2014 Author Report Share Posted August 29, 2014 Indeed, yes I can see the time advancement from the print , but the sequence is unable to reach driver . I think I shud debug the problem somewhere else, since it must not b in this code ,, - Thanks Karandeep Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 30, 2014 Author Report Share Posted August 30, 2014 Well the issue caught with tool , moving to other version makes it run Thanks for replies. -Karandeep Quote Link to comment Share on other sites More sharing options...
tudor.timi Posted August 30, 2014 Report Share Posted August 30, 2014 So it was a tool bug? The code at first glance seemed fine to me. Quote Link to comment Share on other sites More sharing options...
karandeep963 Posted August 30, 2014 Author Report Share Posted August 30, 2014 Yupp , it was . Thanks for your help. -Karandeep Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.