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 function xvc_manager::new(string inst); 00025 this.log = new("XVC Manager", inst); 00026 this.trace = new("XVC Manager Trace", inst); 00027 this.notify = new(this.log); 00028 endfunction: new 00029 00030 00031 function bit xvc_manager::add_xvc(xvc_xactor xvc); 00032 // Has it already been added? 00033 foreach (this.xvcQ[i]) begin 00034 if (this.xvcQ[i] == xvc) begin 00035 `vmm_error(this.log, 00036 `vmm_sformatf("XVC %s(%s) has already been added", 00037 xvc.get_name(), 00038 xvc.get_instance()) 00039 ); 00040 return 0; 00041 end 00042 end 00043 00044 this.xvcQ.push_back(xvc); 00045 add_xvc = 1; 00046 endfunction: add_xvc 00047 00048 00049 function bit xvc_manager::remove_xvc(xvc_xactor xvc); 00050 foreach (this.xvcQ[i]) begin 00051 if (this.xvcQ[i] == xvc) begin 00052 this.xvcQ.delete(i); 00053 return 1; 00054 end 00055 end 00056 00057 `vmm_error(this.log, 00058 `vmm_sformatf("XVC %s(%s) is unknown", 00059 xvc.get_name(), 00060 xvc.get_instance()) 00061 ); 00062 remove_xvc = 0; 00063 endfunction: remove_xvc 00064 00065 00066 function bit xvc_manager::split(string command, 00067 ref string argv[]); 00068 string pre; 00069 string post; 00070 string tok[$]; 00071 00072 split = 1; 00073 00074 //some basic checks on inputs 00075 if (command.len() == 0) begin 00076 argv.delete(); 00077 return 0; 00078 end 00079 00080 post = command; 00081 forever begin 00082 if (`vmm_str_match(post, "[ ]+")) begin 00083 pre = `vmm_str_prematch(post); 00084 post = `vmm_str_postmatch(post); 00085 if (pre.len() != 0) begin 00086 // Only add the token if non-empty to strip leading blanks 00087 tok.push_back(pre); 00088 end 00089 end else begin 00090 //if no further matches, put in the last match if it's non-zero len 00091 if (post.len() > 0) begin 00092 tok.push_back(post); 00093 end 00094 break; 00095 end 00096 end 00097 00098 argv = new [tok.size()]; 00099 foreach (tok[i]) begin 00100 argv[i] = tok[i]; 00101 end 00102 endfunction: split