OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [rand_delays_c.sv] - Blame information for rev 49

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
class rand_delays_c extends uvm_object;
2
   //----------------------------------------------------------------------------------------
3
   // Group: Types
4
 
5
   // enum: traffic_type_e
6
   // Allows for a variety of delay types
7
   typedef enum {
8
      FAST_AS_YOU_CAN,
9
      REGULAR,
10
      BURSTY
11
   } traffic_type_e;
12
 
13
   typedef int unsigned delay_t;
14
 
15
   `uvm_object_utils_begin(rand_delays_c)
16
      `uvm_field_enum(traffic_type_e, traffic_type, UVM_DEFAULT)
17
      `uvm_field_int(min_delay,                     UVM_DEFAULT | UVM_DEC)
18
      `uvm_field_int(max_delay,                     UVM_DEFAULT | UVM_DEC)
19
      `uvm_field_int(burst_on_min,                  UVM_DEFAULT | UVM_DEC)
20
      `uvm_field_int(burst_on_max,                  UVM_DEFAULT | UVM_DEC)
21
      `uvm_field_int(burst_off_min,                 UVM_DEFAULT | UVM_DEC)
22
      `uvm_field_int(burst_off_max,                 UVM_DEFAULT | UVM_DEC)
23
      `uvm_field_int(wait_timescale,                UVM_DEFAULT | UVM_DEC)
24
   `uvm_object_utils_end
25
 
26
   //----------------------------------------------------------------------------------------
27
   // Group: Random Fields
28
 
29
   // var: traffic_type
30
   rand traffic_type_e traffic_type;
31
 
32
   // var: min_delay, max_delay
33
   // Delays used for REGULAR traffic types
34
   rand delay_t min_delay, max_delay;
35
 
36
   // var: burst_on_min, burst_on_max
37
   // Knobs that control the random length of bursty traffic
38
   rand delay_t burst_on_min, burst_on_max;
39
 
40
   // var: burst_off_min, burst_off_max
41
   // Knobs that control how long a burst will be off
42
   rand delay_t burst_off_min, burst_off_max;
43
 
44
   // var: wait_timescale
45
   // The timescale to use when wait_next_delay is called
46
   time wait_timescale = 1ns;
47
 
48
   //----------------------------------------------------------------------------------------
49
   // Group: Local Fields
50
 
51
   // var: burst_on_time
52
   // When non-zero, currently burst mode is on for this many more calls
53
   delay_t burst_on_time = 1;
54
 
55
   //----------------------------------------------------------------------------------------
56
   // Group: Constraints
57
 
58
   // constraint: delay_L0_cnstr
59
   // Keep min knobs <= max knobs
60
   constraint delay_L0_cnstr {
61
      traffic_type == REGULAR -> (min_delay <= max_delay);
62
      traffic_type == BURSTY -> (burst_on_min <= burst_on_max) && (burst_off_min <= burst_off_max);
63
   }
64
 
65
   // constraint: delay_L1_cnstr
66
   // Safe delays
67
   constraint delay_L1_cnstr {
68
      max_delay <= 500;
69
      burst_on_max <= 500;
70
      burst_off_max <= 500;
71
   }
72
 
73
   //----------------------------------------------------------------------------------------
74
   // Group: Methods
75
 
76
   ////////////////////////////////////////////
77
   // func: new
78
   function new(string name="rand_delay");
79
      super.new(name);
80
   endfunction : new
81
 
82
   ////////////////////////////////////////////
83
   // func: get_next_delay
84
   // Return the length of the next delay
85
   virtual function delay_t get_next_delay();
86
      case(traffic_type)
87
         FAST_AS_YOU_CAN: get_next_delay = 0;
88
         REGULAR: begin
89
            std::randomize(get_next_delay) with {
90
               get_next_delay inside {[min_delay:max_delay]};
91
            };
92
         end
93
         BURSTY: begin
94
            if(burst_on_time) begin
95
               burst_on_time -= 1;
96
               get_next_delay = 0;
97
            end else begin
98
               std::randomize(get_next_delay) with {
99
                  get_next_delay inside {[burst_off_min:burst_off_max]};
100
               };
101
               std::randomize(burst_on_time) with {
102
                  burst_on_time inside {[burst_on_min:burst_on_max]};
103
               };
104
            end
105
         end
106
      endcase
107
   endfunction : get_next_delay
108
 
109
   ////////////////////////////////////////////
110
   // func: wait_next_delay
111
   // Wait for the next random period of time, based on the timescale provided
112
   virtual task wait_next_delay();
113
      delay_t delay = get_next_delay();
114
      #(delay * wait_timescale);
115
   endtask : wait_next_delay
116
endclass : rand_delays_c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.