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

Intelligent Design Verification
Intelligent Design Verification
Project: VMM, Revision: 1.0.0
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:38:21 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV