VMM - (expanded) std_lib/vmm_atomic_gen.sv

Expanded versions of source files are the output of the preprocessor. Lines subject to conditional compilation are not shown and all compiler pragmas have been stripped. Macros have been completely expanded.

std_lib/vmm_atomic_gen.sv unexpanded source

00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: // 
00021: 
00022: 
00023: `define vmm_atomic_gen_(class)           class``_atomic_gen
     : 
00024: `define vmm_atomic_gen_callbacks_(class) class``_atomic_gen_callbacks
     : 
00025: 
00026: 
00027: `define vmm_atomic_gen(class_name, text) \
00028: `vmm_atomic_gen_using(class_name, class_name``_channel, text)
     : 
00029: 
00030: `define vmm_atomic_gen_using(class_name, channel_name, text) \
00031:  \
00032: typedef class `vmm_atomic_gen_(class_name); \
00033: class `vmm_atomic_gen_callbacks_(class_name) extends vmm_xactor_callbacks; \
00034:    virtual task post_inst_gen(`vmm_atomic_gen_(class_name) gen, \
00035:                               class_name                   obj, \
00036:                               ref bit                      drop); \
00037:    endtask \
00038: endclass \
00039:  \
00040:  \
00041: class `vmm_atomic_gen_(class_name) extends `VMM_XACTOR; \
00042:  \
00043:    int unsigned stop_after_n_insts; \
00044:  \
00045:    typedef enum int {GENERATED, \
00046:                      DONE} symbols_e; \
00047:  \
00048:  \
00049:    class_name randomized_obj; \
00050:  \
00051:    channel_name out_chan; \
00052:  \
00053:    local int scenario_count; \
00054:    local int obj_count; \
00055:  \
00056:    function new(string       inst, \
00057:                 int          stream_id = -1, \
00058:                 channel_name out_chan  = null `VMM_XACTOR_NEW_ARGS); \
00059:       super.new({text, " Atomic Generator"}, inst, stream_id `VMM_XACTOR_NEW_CALL); \
00060:  \
00061:       if (out_chan == null) begin \
00062:          out_chan = new({text, " Atomic Generator output channel"}, \
00063:                          inst); \
00064:       end \
00065:       this.out_chan = out_chan; \
00066:       this.log.is_above(this.out_chan.log); \
00067:  \
00068:       this.scenario_count = 0; \
00069:       this.obj_count = 0; \
00070:       this.stop_after_n_insts = 0; \
00071:  \
00072:       this.notify.configure(GENERATED, vmm_notify::ONE_SHOT); \
00073:       this.notify.configure(DONE, vmm_notify::ON_OFF); \
00074:  \
00075:       this.randomized_obj = new; \
00076:    endfunction: new \
00077:  \
00078:    virtual task inject(class_name obj, \
00079:                        ref bit    dropped); \
00080:       dropped = 0; \
00081:  \
00082:       `vmm_callback(`vmm_atomic_gen_callbacks_(class_name), \
00083:                     post_inst_gen(this, obj, dropped)); \
00084:  \
00085:       if (!dropped) begin \
00086:          this.obj_count++; \
00087:          this.notify.indicate(GENERATED, obj); \
00088:          this.out_chan.put(obj); \
00089:       end \
00090:    endtask: inject \
00091:  \
00092:    virtual function void reset_xactor(reset_e rst_typ = SOFT_RST); \
00093:       super.reset_xactor(rst_typ); \
00094:  \
00095:       this.out_chan.flush(); \
00096:       this.scenario_count = 0; \
00097:       this.obj_count = 0; \
00098:  \
00099:       if (rst_typ >= FIRM_RST) begin \
00100:          this.notify.reset( , vmm_notify::HARD); \
00101:       end \
00102:  \
00103:       if (rst_typ >= HARD_RST) begin \
00104:          this.stop_after_n_insts = 0; \
00105:          this.randomized_obj     = new; \
00106:       end \
00107:    endfunction: reset_xactor \
00108:  \
00109:    virtual protected task main(); \
00110:       bit dropped; \
00111:  \
00112:       fork \
00113:          super.main(); \
00114:       join_none \
00115:  \
00116:       while (this.stop_after_n_insts <= 0 || \
00117:              this.obj_count < this.stop_after_n_insts) begin \
00118:  \
00119:          this.wait_if_stopped(); \
00120:  \
00121:          this.randomized_obj.stream_id   = this.stream_id; \
00122:          this.randomized_obj.scenario_id = this.scenario_count; \
00123:          this.randomized_obj.data_id     = this.obj_count; \
00124:  \
00125:          if (!this.randomized_obj.randomize()) begin \
00126:             `vmm_fatal(this.log, "Cannot randomize atomic instance"); \
00127:             continue; \
00128:          end \
00129:  \
00130:          begin \
00131:             class_name obj; \
00132:  \
00133:             $cast(obj, this.randomized_obj.copy()); \
00134:             this.inject(obj, dropped); \
00135:          end \
00136:       end \
00137:  \
00138:       this.notify.indicate(DONE); \
00139:       this.notify.indicate(XACTOR_STOPPED); \
00140:       this.notify.indicate(XACTOR_IDLE); \
00141:       this.notify.reset(XACTOR_BUSY); \
00142:       this.scenario_count++; \
00143:    endtask: main \
00144:  \
00145: endclass
     :