URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [rand_delays_c.sv] - Rev 34
Compare with Previous | Blame | View Log
class rand_delays_c extends uvm_object;//----------------------------------------------------------------------------------------// Group: Types// enum: traffic_type_e// Allows for a variety of delay typestypedef enum {FAST_AS_YOU_CAN,REGULAR,BURSTY} traffic_type_e;typedef int unsigned delay_t;`uvm_object_utils_begin(rand_delays_c)`uvm_field_enum(traffic_type_e, traffic_type, UVM_DEFAULT)`uvm_field_int(min_delay, UVM_DEFAULT | UVM_DEC)`uvm_field_int(max_delay, UVM_DEFAULT | UVM_DEC)`uvm_field_int(burst_on_min, UVM_DEFAULT | UVM_DEC)`uvm_field_int(burst_on_max, UVM_DEFAULT | UVM_DEC)`uvm_field_int(burst_off_min, UVM_DEFAULT | UVM_DEC)`uvm_field_int(burst_off_max, UVM_DEFAULT | UVM_DEC)`uvm_field_int(wait_timescale, UVM_DEFAULT | UVM_DEC)`uvm_object_utils_end//----------------------------------------------------------------------------------------// Group: Random Fields// var: traffic_typerand traffic_type_e traffic_type;// var: min_delay, max_delay// Delays used for REGULAR traffic typesrand delay_t min_delay, max_delay;// var: burst_on_min, burst_on_max// Knobs that control the random length of bursty trafficrand delay_t burst_on_min, burst_on_max;// var: burst_off_min, burst_off_max// Knobs that control how long a burst will be offrand delay_t burst_off_min, burst_off_max;// var: wait_timescale// The timescale to use when wait_next_delay is calledtime wait_timescale = 1ns;//----------------------------------------------------------------------------------------// Group: Local Fields// var: burst_on_time// When non-zero, currently burst mode is on for this many more callsdelay_t burst_on_time = 1;//----------------------------------------------------------------------------------------// Group: Constraints// constraint: delay_L0_cnstr// Keep min knobs <= max knobsconstraint delay_L0_cnstr {traffic_type == REGULAR -> (min_delay <= max_delay);traffic_type == BURSTY -> (burst_on_min <= burst_on_max) && (burst_off_min <= burst_off_max);}// constraint: delay_L1_cnstr// Safe delaysconstraint delay_L1_cnstr {max_delay <= 500;burst_on_max <= 500;burst_off_max <= 500;}//----------------------------------------------------------------------------------------// Group: Methods////////////////////////////////////////////// func: newfunction new(string name="rand_delay");super.new(name);endfunction : new////////////////////////////////////////////// func: get_next_delay// Return the length of the next delayvirtual function delay_t get_next_delay();case(traffic_type)FAST_AS_YOU_CAN: get_next_delay = 0;REGULAR: beginstd::randomize(get_next_delay) with {get_next_delay inside {[min_delay:max_delay]};};endBURSTY: beginif(burst_on_time) beginburst_on_time -= 1;get_next_delay = 0;end else beginstd::randomize(get_next_delay) with {get_next_delay inside {[burst_off_min:burst_off_max]};};std::randomize(burst_on_time) with {burst_on_time inside {[burst_on_min:burst_on_max]};};endendendcaseendfunction : get_next_delay////////////////////////////////////////////// func: wait_next_delay// Wait for the next random period of time, based on the timescale providedvirtual task wait_next_delay();delay_t delay = get_next_delay();#(delay * wait_timescale);endtask : wait_next_delayendclass : rand_delays_c
