VMM OpenSource - sv/std_lib/vmm_scenario.sv

sv/std_lib/vmm_scenario.sv expanded 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 
00024 
00025 function vmm_scenario::new(`VMM_LOG log `VMM_SCENARIO_NEW_ARGS);
00026    super.new(log `VMM_SCENARIO_NEW_CALL);
00027 endfunction: new
00028 
00029 
00030 function string vmm_scenario::psdisplay(string prefix);
00031    int i;
00032 
00033    $sformat(psdisplay,
00034             "%sScenario \"%s\": kind=%0d, length=%0d (max=%0d), repeated=%0d",
00035             prefix, this.scenario_name(this.scenario_kind),
00036             this.scenario_kind, this.length, this.max_length,
00037             this.repeated);
00038 endfunction: psdisplay
00039 
00040 
00041 function int unsigned vmm_scenario::define_scenario(string name,
00042                                                     int unsigned max_len);
00043    define_scenario = this.next_scenario_kind++;
00044    this.scenario_names[define_scenario] = name;
00045 
00046    if (max_len > this.max_length) this.max_length = max_len;
00047 endfunction: define_scenario
00048 
00049 
00050 function void vmm_scenario::redefine_scenario(int unsigned scenario_kind,
00051                                               string       name,
00052                                               int unsigned max_len);
00053    this.scenario_names[scenario_kind] = name;
00054     if (max_len > this.max_length) this.max_length = max_len;
00055 endfunction: redefine_scenario
00056 
00057 
00058 function string vmm_scenario::scenario_name(int unsigned scenario_kind);
00059    if (!this.scenario_names.exists(scenario_kind)) begin
00060       `vmm_error(super.notify.log, `vmm_sformatf("Cannot find scenario name: undefined scenario kind %0d",
00061                                          scenario_kind));
00062       return "?";
00063    end
00064 
00065    scenario_name = this.scenario_names[scenario_kind];
00066 endfunction: scenario_name
00067 
00068 
00069 function int unsigned vmm_scenario::get_max_length();
00070    return this.max_length;
00071 endfunction: get_max_length
00072 
00073 function void vmm_scenario::set_parent_scenario(vmm_scenario parent);
00074    this.parent = parent;
00075    if(parent == null) return;
00076 endfunction: set_parent_scenario
00077 
00078 function vmm_scenario vmm_scenario::get_parent_scenario();
00079    get_parent_scenario = this.parent;
00080 endfunction: get_parent_scenario
00081 
00082 task vmm_scenario::execute(ref int n);
00083 endtask: execute