vmm_hw_rtl.sv

Go to the documentation of this file.
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 `ifdef VMM_HW_RTL__SV
00024 `else
00025 `define VMM_HW_RTL__SV
00026 
00027 
00028 //
00029 // Select the target architecture
00030 //
00031 `undef VMM_HW_ARCH
00032 
00033 `ifdef VMM_HW_ARCH_SCEMI
00034    // Throw a syntax error if more than one architecture was selected
00035    `ifdef VMM_HW_ARCH
00036       `VMM_HW_More_than_one_HW_platform_architecture_selected
00037    `endif
00038    `define VMM_HW_ARCH
00039    `define VMM_HW_RTL_USE_MODULE
00040 `endif
00041 
00042 
00043 `ifdef VMM_HW_ARCH_NULL
00044    // Throw a syntax error if more than one architecture was selected
00045    `ifdef VMM_HW_ARCH
00046       `VMM_HW_More_than_one_HW_platform_architecture_selected
00047    `endif
00048    `include "vmm.sv"
00049    `define VMM_HW_ARCH
00050    `undef VMM_HW_RTL_USE_MODULE
00051 `endif
00052 
00053 
00054 // Throw a syntax error if no architecture was selected
00055 `ifdef VMM_HW_ARCH
00056 `else
00057    `VMM_HW_No_HW_platform_architecture_selected
00058 `endif
00059 
00060 
00061 // If for simulation, always use an interface
00062 `ifdef VMM_HW_SYNTHESIS_ON
00063 `else
00064    `undef VMM_HW_RTL_USE_MODULE
00065 `endif
00066 
00067 
00068 // Include the DUT if mapping to hardware platform (ie. synthesis)
00069 // or using the NULL architecture
00070 `ifdef VMM_HW_SYNTHESIS_ON
00071    `define VMM_HW_INCL_DUT
00072 `endif
00073 `ifdef VMM_HW_ARCH_NULL
00074    `define VMM_HW_INCL_DUT
00075 `endif
00076 
00077 
00078 `ifdef VMM_HW_RTL_USE_MODULE
00079    `define VMM_HW_RTL_COMPONENT_START module
00080    `define VMM_HW_RTL_COMPONENT_END   endmodule
00081 `else
00082    `define VMM_HW_RTL_COMPONENT_START interface
00083    `define VMM_HW_RTL_COMPONENT_END   endinterface
00084 `endif
00085 
00086 //
00087 //------------------------------------------------------------------
00088 //
00089 
00090 
00091 `VMM_HW_RTL_COMPONENT_START vmm_hw_in_if(rx_rdy, tx_rdy, msg, uclk, urst);
00092 
00093    parameter width = 1;
00094 
00095    input              rx_rdy;
00096    output             tx_rdy;
00097    output [width-1:0] msg;
00098    input              uclk;
00099    input              urst;
00100 
00101 `ifdef VMM_HW_SYNTHESIS_ON
00102 `else
00103    integer size = width;
00104    string  path  = $psprintf("%m");
00105    reg [1024*8-1:0] ovpath = $psprintf("%m"); // For OV
00106 `endif
00107 
00108 `ifdef VMM_HW_ARCH_NULL
00109    // synthesis translate_off
00110    vmm_log log = new("vmm_hw_in_if", $psprintf("%m"));
00111    bit in_use = 0;
00112 
00113    reg             tx_rdy;
00114    reg [width-1:0] msg;
00115 
00116    clocking ck @(posedge uclk);
00117       input rx_rdy;
00118    endclocking
00119 
00120    // synthesis translate_on
00121 `endif
00122 
00123 `ifdef VMM_HW_SYNTHESIS_ON
00124 
00125    `ifdef VMM_HW_ARCH_SCEMI
00126       SceMiMessageInPort #(width) scemi(rx_rdy, tx_rdy, msg);
00127    `endif
00128 
00129 `endif
00130 
00131 `VMM_HW_RTL_COMPONENT_END
00132 
00133 
00134 
00135 //
00136 //------------------------------------------------------------------
00137 //  
00138 `VMM_HW_RTL_COMPONENT_START vmm_hw_out_if(tx_rdy, rx_rdy, msg, uclk, urst);
00139    parameter width = 1;
00140    parameter pri = 10;
00141 
00142    input               tx_rdy;
00143    output              rx_rdy;
00144    input  [width-1:0]  msg;
00145    input               uclk;
00146    input               urst;
00147 
00148 
00149 `ifdef VMM_HW_SYNTHESIS_ON
00150 `else
00151    integer size = width;
00152    string  path  = $psprintf("%m");
00153 `endif
00154 
00155 `ifdef VMM_HW_ARCH_NULL
00156    // synthesis translate_off
00157    vmm_log log = new("vmm_hw_out_if", $psprintf("%m"));
00158    bit in_use = 0;
00159 
00160    reg             rx_rdy;
00161 
00162    clocking ck @(posedge uclk);
00163       input tx_rdy;
00164       input msg;
00165    endclocking
00166 
00167    // synthesis translate_on
00168 `endif
00169 
00170 
00171 `ifdef VMM_HW_SYNTHESIS_ON
00172 
00173    `ifdef VMM_HW_ARCH_SCEMI
00174       SceMiMessageOutPort #(width, pri) scemi(tx_rdy, rx_rdy, msg);
00175    `endif
00176 
00177 `endif
00178 
00179 `VMM_HW_RTL_COMPONENT_END
00180 
00181 
00182 
00183 //
00184 //------------------------------------------------------------------
00185 //  
00186 `VMM_HW_RTL_COMPONENT_START vmm_hw_clock_control(uclk, urst,
00187                                                  rdy_for_cclk, cclk_en,
00188                                                  rdy_for_cclk_neg, cclk_neg_en);
00189    parameter clock_num = 1;
00190 
00191    output uclk;
00192    output urst;
00193    input  rdy_for_cclk;
00194    output cclk_en;
00195    input  rdy_for_cclk_neg;
00196    output cclk_neg_en;
00197 
00198 `ifdef VMM_HW_ARCH_NULL
00199    // synthesis translate_off
00200    // Make sure uclk and cclk are delta-cycle aligned
00201    reg uclk, urst;
00202    always @(vmm_hw.uclk) uclk <= vmm_hw.uclk;
00203    always @(vmm_hw.urst) urst <= vmm_hw.urst;
00204    // synthesis translate_on
00205 
00206    reg cclk_en;
00207    reg cclk_neg_en;
00208    string path = $psprintf("%M");
00209 
00210    initial
00211    begin
00212       repeat (2) @ (posedge uclk);
00213       if (cclk_en === 1'bx || cclk_neg_en === 1'bx) begin
00214          $write("ERROR: clock controller %m is not associated with a clock source\n");
00215          $finish();
00216       end
00217    end
00218 `endif
00219 
00220 `ifdef VMM_HW_SYNTHESIS_ON
00221    `ifdef VMM_HW_ARCH_SCEMI
00222       SceMiClockControl #(clock_num) scemi(uclk, urst,
00223                                            rdy_for_cclk, cclk_en,
00224                                            rdy_for_cclk_neg, cclk_neg_en);
00225    `endif
00226 
00227 `endif
00228 
00229 `VMM_HW_RTL_COMPONENT_END
00230 
00231 
00232 
00233 //
00234 //------------------------------------------------------------------
00235 //  
00236 `ifdef VMM_HW_ARCH_NULL
00237 module vmm_hw();
00238 
00239 reg uclk;
00240 reg urst;
00241 reg crst;
00242 time stamp;
00243 
00244 int reset_cycles = 8;
00245 
00246 initial
00247 begin
00248    stamp    = 0;
00249    uclk     = 0;
00250 
00251    forever begin
00252       #1 uclk = 1;
00253       stamp = stamp + 1;
00254       #1 uclk = 0;
00255    end
00256 end
00257 
00258 initial
00259 begin
00260    urst = 1;
00261    crst = 0;
00262    repeat (5) @ (posedge uclk);
00263    crst <= 1'b1;
00264    repeat (5) @ (posedge uclk);
00265    urst <= 0;
00266    repeat (reset_cycles * 2) @ (posedge uclk);
00267    crst <= 1'b0;
00268 end
00269 
00270 initial
00271 begin
00272 end
00273 
00274 endmodule
00275 `endif
00276 
00277 
00278 //
00279 //------------------------------------------------------------------
00280 //  
00281 `VMM_HW_RTL_COMPONENT_START vmm_hw_clock(cclk, crst, crstn);
00282    parameter clock_num         = 1;
00283 
00284    parameter ratio_numerator   = 1;
00285    parameter ratio_denominator = 1;
00286    parameter duty_hi           = 0;
00287    parameter duty_lo           = 100;
00288    parameter phase             = 0;
00289    parameter reset_cycles      = 8;
00290 
00291    output cclk;
00292    output crst, crstn;
00293 
00294 
00295 `ifdef VMM_HW_ARCH_NULL
00296    assign crst  = vmm_hw.crst;
00297    assign crstn = ~vmm_hw.crst;
00298 
00299    int no_pos = 0; // For SV
00300    int no_neg = 0; // For SV
00301    wor no_posw;   // For Openvera
00302    wor no_negw;   // For Openvera
00303 
00304    bit ck_en;
00305    bit ckn_en;
00306 
00307    reg cclk = 0;
00308 
00309    // Controlled clocks must run while ccrst is asserted
00310    assign ck_en  = (vmm_hw.urst === 1'b0) && (cclk == 1'b0) &&
00311                    ((no_pos == 0 && no_posw === 1'bz) || crst);
00312    assign ckn_en = (vmm_hw.urst === 1'b0) && (cclk == 1'b1) &&
00313                    ((no_neg == 0 && no_negw === 1'bz) || crst);
00314 
00315    initial
00316    begin
00317       if (vmm_hw.reset_cycles < reset_cycles) begin
00318          vmm_hw.reset_cycles = reset_cycles;
00319       end
00320 
00321       if (ratio_numerator != ratio_denominator) begin
00322          $write("WARNING: Unsupported ratio for clock source %M: %0d/%0d (must be 1/1)\n",
00323                 ratio_numerator, ratio_denominator);
00324       end
00325       if (duty_hi != 0 && duty_lo != 0) begin
00326          $write("WARNING: Unsupported duty cycle for clock source %M: %0d/%0d (must be 0/x or x/0)\n",
00327                 duty_hi, duty_lo);
00328       end
00329       if (phase != 0) begin
00330          $write("WARNING: Unsupported phase for clock source %M: %0d (must be 0)\n",
00331                 phase);
00332       end
00333    end
00334 
00335    always @ (posedge vmm_hw.uclk)
00336    begin
00337       if (vmm_hw.urst) cclk <= 1'b0;
00338       else begin
00339          if (ck_en)  cclk <= 1'b1;
00340          if (ckn_en) cclk <= 1'b0;
00341       end
00342    end
00343 
00344    string controller[$];
00345    logic rdy_pos[$];
00346    logic rdy_neg[$];
00347 
00348    function void why();
00349       if (controller.size() == 0) begin
00350          $write("Clock source %M does not have any associated controllers\n");
00351          return;
00352       end
00353       $write("State of controllers associated with %M:\n");
00354       $write("  Pos Neg :: Instance\n");
00355       foreach(controller[i]) begin
00356          $write("   %b   %b :: %s\n", rdy_pos[i], rdy_neg[i], controller[i]);
00357       end
00358    endfunction: why
00359 
00360 `endif
00361 
00362 
00363 `ifdef VMM_HW_SYNTHESIS_ON
00364 
00365    `ifdef VMM_HW_ARCH_SCEMI
00366       SceMiClockPort #(clock_num,
00367                        ratio_numerator, ratio_denominator,
00368                        duty_hi, duty_lo, phase, reset_cycles) scemi(cclk, crst);
00369    `endif
00370 
00371 `endif
00372 
00373 `VMM_HW_RTL_COMPONENT_END
00374 
00375 `endif // VMM_HW_RTL__SV

Intelligent Design Verification
Intelligent Design Verification
Project: VMM, Revision: 1.0.1
Copyright (c) 2008 Intelligent Design Verification.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included here:
http://www.intelligentdv.com/licenses/fdl.txt
doxygen
Doxygen Version: 1.5.6
Sat Oct 18 11:32:18 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV