VMM OpenSource - sv/std_lib/vmm_subenv_macros.sv

sv/std_lib/vmm_subenv_macros.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 `define vmm_subenv_member_begin(_class) \
00024  \
00025    function void do_all(vmm_subenv::do_what_e do_what, \
00026                         vmm_env::restart_e restart = vmm_env::FIRM); \
00027       super.do_all(do_what, restart);
00028 
00029 
00030 `define vmm_subenv_member_scalar(_name, _do) \
00031   `define vmm_xactor_member_scalar(_name, _do)
00032 
00033 `define vmm_subenv_member_scalar_array(_name, _do) \
00034   `vmm_xactor_member_scalar_array(_name, _do)
00035 
00036 `define vmm_subenv_member_scalar_aa_scalar(_name, _do) \
00037   `vmm_xactor_member_scalar_aa_scalar(_name, _do)
00038 
00039 `define vmm_subenv_member_scalar_aa_string(_name, _do) \
00040   `vmm_xactor_member_scalar_aa_string(_name, _do)
00041 
00042 `define vmm_subenv_member_enum(_name, _do) \
00043   `vmm_xactor_member_enum(_name, _do)
00044 
00045 `define vmm_subenv_member_enum_array(_name, _do) \
00046   `vmm_xactor_member_enum_array(_name, _do)
00047 
00048 `define vmm_subenv_member_enum_aa_scalar(_name, _do) \
00049   `vmm_xactor_member_enum_aa_scalar(_name, _do)
00050 
00051 `define vmm_subenv_member_enum_aa_string(_name, _do) \
00052   `vmm_xactor_member_enum_aa_string(_name, _do)
00053 
00054 `define vmm_subenv_member_string(_name, _do) \
00055   `vmm_xactor_member_string(_name, _do)
00056 
00057 `define vmm_subenv_member_string_array(_name, _do) \
00058   `vmm_xactor_member_string_array(_name, _do)
00059 
00060 `define vmm_subenv_member_string_aa_scalar(_name, _do) \
00061   `vmm_xactor_member_string_aa_scalar(_name, _do)
00062 
00063 `define vmm_subenv_member_string_aa_string(_name, _do) \
00064   `vmm_xactor_member_string_aa_string(_name, _do)
00065 
00066 `define vmm_subenv_member_vmm_data(_name, _do) \
00067   `vmm_xactor_member_vmm_data(_name, _do)
00068 
00069 `define vmm_subenv_member_vmm_data_array(_name, _do) \
00070   `vmm_xactor_member_vmm_data_array(_name, _do)
00071 
00072 `define vmm_subenv_member_vmm_data_aa_scalar(_name, _do) \
00073   `vmm_xactor_member_vmm_data_aa_scalar(_name, _do)
00074 
00075 `define vmm_subenv_member_vmm_data_aa_string(_name, _do) \
00076   `vmm_xactor_member_vmm_data_aa_string(_name, _do)
00077 
00078 
00079 `define vmm_subenv_member_channel(_name, _do) \
00080   \
00081       case (do_what & _do) \
00082         DO_PRINT: begin \
00083            $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00084                     this._name.psdisplay({this.__vmm_prefix, `"_name: `"})); \
00085         end \
00086         DO_RESET: begin \
00087            case (restart) \
00088            vmm_env::FIRM: this._name.flush(); \
00089            vmm_env::HARD: this._name.kill(); \
00090            endcase \
00091         end \
00092         DO_VOTE: begin \
00093            this.end_test.register_channel(this._name); \
00094         end \
00095       endcase
00096 
00097 
00098 `define vmm_subenv_member_channel_array(_name, _do) \
00099   \
00100       case (do_what & _do) \
00101         DO_PRINT: begin \
00102            foreach (this._name[i]) begin \
00103               $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00104                        this._name[i].psdisplay(`vmm_sformatf("%s%s[%0d]: ", \
00105                                                              this.__vmm_prefix, \
00106                                                              `"_name`", i))); \
00107            end \
00108         end \
00109         DO_RESET: begin \
00110            case (restart) \
00111            vmm_env::FIRM: foreach (this._name[i]) begin \
00112               this._name[i].flush(); \
00113            end \
00114            vmm_env::HARD: foreach (this._name[i]) begin \
00115               this._name[i].kill(); \
00116            end \
00117            endcase \
00118         end \
00119         DO_VOTE: begin \
00120            foreach (this._name[i]) begin \
00121               this.end_test.register_channel(this._name[i]); \
00122            end \
00123         end \
00124       endcase
00125 
00126 
00127 `define vmm_subenv_member_channel_aa_scalar(_name, _do) \
00128   \
00129    `vmm_subenv_member_channel_array(_name, _do)
00130 
00131 
00132 `define vmm_subenv_member_channel_aa_string(_name, _do) \
00133   \
00134       case (do_what & _do) \
00135         DO_PRINT: begin \
00136            foreach (this._name[i]) begin \
00137               $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00138                        this._name[i].psdisplay(`vmm_sformatf("%s%s[%s]: ", \
00139                                                              this.__vmm_prefix, \
00140                                                              `"_name`", i))); \
00141            end \
00142         end \
00143         DO_RESET: begin \
00144            case (restart) \
00145            vmm_env::FIRM: foreach (this._name[i]) begin \
00146               this._name[i].flush(); \
00147            end \
00148            vmm_env::HARD: foreach (this._name[i]) begin \
00149               this._name[i].kill(); \
00150            end \
00151            endcase \
00152         end \
00153         DO_VOTE: begin \
00154            foreach (this._name[i]) begin \
00155               this.end_test.register_channel(this._name[i]); \
00156            end \
00157         end \
00158       endcase
00159 
00160 
00161 `define vmm_subenv_member_xactor(_name, _do) \
00162   \
00163       case (do_what & _do) \
00164         DO_PRINT: begin \
00165            string _prefix = this.__vmm_prefix; \
00166            $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00167                     this._name.psdisplay({this.__vmm_prefix, `"_name: `"})); \
00168            this.__vmm_prefix = _prefix; \
00169         end \
00170         DO_START: begin \
00171            this._name.start_xactor(); \
00172         end \
00173         DO_STOP: begin \
00174            this._name.stop_xactor(); \
00175         end \
00176         DO_RESET: begin \
00177            case (restart) \
00178            vmm_env::FIRM: this._name.reset_xactor(vmm_xactor::SOFT_RST); \
00179            vmm_env::HARD: this._name.kill(); \
00180            endcase \
00181         end \
00182         DO_VOTE: begin \
00183            this.end_test.register_xactor(this._name); \
00184         end \
00185       endcase
00186 
00187 
00188 `define vmm_subenv_member_xactor_array(_name, _do) \
00189   \
00190       case (do_what & _do) \
00191         DO_PRINT: begin \
00192            string _prefix = this.__vmm_prefix; \
00193            foreach (this._name[i]) begin \
00194               $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00195                        this._name[i].psdisplay(`vmm_sformatf("%s%s[%0d]: ", \
00196                                                              _prefix, \
00197                                                              `"_name`", i))); \
00198            end \
00199            this.__vmm_prefix = _prefix; \
00200         end \
00201         DO_START: begin \
00202            foreach (this._name[i]) begin \
00203               this._name[i].start_xactor(); \
00204            end \
00205         end \
00206         DO_STOP: begin \
00207            foreach (this._name[i]) begin \
00208               this._name[i].stop_xactor(); \
00209            end \
00210         end \
00211         DO_RESET: begin \
00212            case (restart) \
00213            vmm_env::FIRM: foreach (this._name[i]) begin \
00214               this._name[i].reset_xactor(); \
00215            end \
00216            vmm_env::HARD: foreach (this._name[i]) begin \
00217               this._name[i].kill(); \
00218            end \
00219            endcase \
00220         end \
00221         DO_VOTE: begin \
00222            foreach (this._name[i]) begin \
00223               this.end_test.register_xactor(this._name[i]); \
00224            end \
00225         end \
00226       endcase
00227 
00228 
00229 `define vmm_subenv_member_xactor_aa_scalar(_name, _do) \
00230   `vmm_subenv_member_xactor_array(_name, _do)
00231 
00232 
00233 `define vmm_subenv_member_xactor_aa_string(_name, _do) \
00234   \
00235       case (do_what & _do) \
00236         DO_PRINT: begin \
00237            string _prefix = this.__vmm_prefix; \
00238            foreach (this._name[i]) begin \
00239               $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00240                        this._name[i].psdisplay(`vmm_sformatf("%s%s[%s]: ", \
00241                                                              _prefix, \
00242                                                              `"_name`", i))); \
00243            end \
00244            this.__vmm_prefix = _prefix; \
00245         end \
00246         DO_START: begin \
00247            foreach (this._name[i]) begin \
00248               this._name[i].start_xactor(); \
00249            end \
00250         end \
00251         DO_STOP: begin \
00252            foreach (this._name[i]) begin \
00253               this._name[i].stop_xactor(); \
00254            end \
00255         end \
00256         DO_RESET: begin \
00257            case (restart) \
00258            vmm_env::FIRM: foreach (this._name[i]) begin \
00259               this._name[i].reset_xactor(); \
00260            end \
00261            vmm_env::HARD: foreach (this._name[i]) begin \
00262               this._name[i].kill(); \
00263            end \
00264            endcase \
00265         end \
00266         DO_VOTE: begin \
00267            foreach (this._name[i]) begin \
00268               this.end_test.register_xactor(this._name[i]); \
00269            end \
00270         end \
00271       endcase
00272 
00273 
00274 `define vmm_subenv_member_subenv(_name, _do) \
00275   \
00276       case (do_what & _do) \
00277         DO_PRINT: begin \
00278            string _prefix = this.__vmm_prefix; \
00279            $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00280                     this._name.psdisplay({this.__vmm_prefix, `"_name: `"})); \
00281            this.__vmm_prefix = _prefix; \
00282         end \
00283         DO_START: begin \
00284            this.__vmm_forks++; \
00285            fork \
00286               begin \
00287                  this._name.start(); \
00288                  this.__vmm_forks--; \
00289               end \
00290            join_none \
00291         end \
00292         DO_STOP: begin \
00293            this.__vmm_forks++; \
00294            fork \
00295               begin \
00296                  this._name.stop(); \
00297                  this.__vmm_forks--; \
00298               end \
00299            join_none \
00300         end \
00301         DO_RESET: begin \
00302            this.__vmm_forks++; \
00303            fork \
00304               begin \
00305                  this._name.reset(restart); \
00306                  this.__vmm_forks--; \
00307               end \
00308            join_none \
00309         end \
00310       endcase
00311 
00312 
00313 `define vmm_subenv_member_subenv_array(_name, _do) \
00314   \
00315       case (do_what & _do) \
00316         DO_PRINT: begin \
00317            string _prefix = this.__vmm_prefix; \
00318            foreach (this._name[i]) begin \
00319               $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00320                        this._name[i].psdisplay(`vmm_sformatf("%s%s[%0d]: ", \
00321                                                              _prefix, \
00322                                                              `"_name`", i))); \
00323            end \
00324            this.__vmm_prefix = _prefix; \
00325         end \
00326         DO_START: begin \
00327            this.__vmm_forks++; \
00328            foreach (this._name[i]) begin \
00329               automatic int j = i; \
00330               fork \
00331                  begin \
00332                     this._name[j].start(); \
00333                     this.__vmm_forks--; \
00334                  end \
00335               join_none \
00336            end \
00337         end \
00338         DO_STOP: begin \
00339            this.__vmm_forks++; \
00340            foreach (this._name[i]) begin \
00341               automatic int j = i; \
00342               fork \
00343                  begin \
00344                     this._name[j].stop(); \
00345                     this.__vmm_forks--; \
00346                  end \
00347               join_none \
00348            end \
00349         end \
00350         DO_RESET: begin \
00351            this.__vmm_forks++; \
00352            foreach (this._name[i]) begin \
00353               automatic int j = i; \
00354               fork \
00355                  begin \
00356                     this._name[j].reset(restart); \
00357                     this.__vmm_forks--; \
00358                  end \
00359               join_none \
00360            end \
00361         end \
00362       endcase
00363 
00364 
00365 `define vmm_subenv_member_subenv_aa_scalar(_name, _do) \
00366   `vmm_subenv_member_subenv_array(_name, _do)
00367 
00368 
00369 `define vmm_subenv_member_subenv_aa_string(_name, _do) \
00370   \
00371       case (do_what & _do) \
00372         DO_PRINT: begin \
00373            string _prefix = this.__vmm_prefix; \
00374            foreach (this._name[i]) begin \
00375               $sformat(this.__vmm_image, `"%s\n%s`", this.__vmm_image, \
00376                        this._name[i].psdisplay(`vmm_sformatf("%s%s[%s]: ", \
00377                                                              _prefix, \
00378                                                              `"_name`", i))); \
00379            end \
00380            this.__vmm_prefix = _prefix; \
00381         end \
00382         DO_START: begin \
00383            this.__vmm_forks++; \
00384            foreach (this._name[i]) begin \
00385               automatic string j = i; \
00386               fork \
00387                  begin \
00388                     this._name[j].start(); \
00389                     this.__vmm_forks--; \
00390                  end \
00391               join_none \
00392            end \
00393         end \
00394         DO_STOP: begin \
00395            this.__vmm_forks++; \
00396            foreach (this._name[i]) begin \
00397               automatic string j = i; \
00398               fork \
00399                  begin \
00400                     this._name[j].stop(); \
00401                     this.__vmm_forks--; \
00402                  end \
00403               join_none \
00404            end \
00405         end \
00406         DO_RESET: begin \
00407            this.__vmm_forks++; \
00408            foreach (this._name[i]) begin \
00409               automatic int j = i; \
00410               fork \
00411                  begin \
00412                     this._name[j].reset(restart); \
00413                     this.__vmm_forks--; \
00414                  end \
00415               join_none \
00416            end \
00417         end \
00418       endcase
00419 
00420 
00421 `define vmm_subenv_member_user_defined(_name) \
00422  \
00423       this.__vmm_restart = restart; \
00424       void'(this.do_``_name(do_what));
00425 
00426 
00427 `define vmm_subenv_member_end(_class) \
00428    endfunction \
00429  \
00430    virtual function string psdisplay(string prefix = `"`"); \
00431       this.__vmm_done_user = 1; \
00432       psdisplay = this.do_psdisplay(prefix); \
00433       if (this.__vmm_done_user) return psdisplay; \
00434  \
00435       this.__vmm_image = super.psdisplay(prefix); \
00436       this.__vmm_prefix = prefix; \
00437       if (`vmm_str_match(prefix, ": $")) begin \
00438          this.__vmm_prefix = {`vmm_str_prematch(prefix), "."}; \
00439       end \
00440       this.do_all(DO_PRINT); \
00441       return this.__vmm_image; \
00442    endfunction \
00443  \
00444    virtual task start(); \
00445       super.start(); \
00446       this.__vmm_done_user = 1; \
00447       this.do_vote(); \
00448       if (!this.__vmm_done_user) begin \
00449          this.do_all(DO_VOTE); \
00450       end \
00451  \
00452       this.__vmm_done_user = 1; \
00453       this.do_start(); \
00454       if (this.__vmm_done_user) return; \
00455  \
00456       this.__vmm_forks = 0; \
00457       this.do_all(DO_START); \
00458       wait (this.__vmm_forks == 0); \
00459    endtask \
00460  \
00461    virtual task stop(); \
00462       super.stop(); \
00463       this.__vmm_done_user = 1; \
00464       this.do_stop(); \
00465       if (this.__vmm_done_user) return; \
00466  \
00467       this.__vmm_forks = 0; \
00468       this.do_all(DO_STOP); \
00469       wait (this.__vmm_forks == 0); \
00470    endtask \
00471  \
00472    virtual task reset(vmm_env::restart_e kind = vmm_env::FIRM); \
00473       super.stop(); \
00474       this.__vmm_done_user = 1; \
00475       this.do_reset(kind); \
00476       if (this.__vmm_done_user) return; \
00477  \
00478       this.__vmm_forks = 0; \
00479       this.do_all(DO_RESET, kind); \
00480       wait (this.__vmm_forks == 0); \
00481    endtask \