⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mii_phy.sv

📁 VMM 文档加源码, synopsys公司很好的验证资料
💻 SV
📖 第 1 页 / 共 2 页
字号:
// // -------------------------------------------------------------//    Copyright 2004-2008 Synopsys, Inc.//    All Rights Reserved Worldwide// //    Licensed under the Apache License, Version 2.0 (the//    "License"); you may not use this file except in//    compliance with the License.  You may obtain a copy of//    the License at// //        http://www.apache.org/licenses/LICENSE-2.0// //    Unless required by applicable law or agreed to in//    writing, software distributed under the License is//    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR//    CONDITIONS OF ANY KIND, either express or implied.  See//    the License for the specific language governing//    permissions and limitations under the License.// -------------------------------------------------------------// typedef class mii_phy_layer;// Example 5-15class mii_phy_collision;   typedef enum {NONE, EARLY, LATE} kind_e;   rand kind_e       kind;   rand int unsigned on_symbol;     // Example 5-16   eth_frame    frame;   constraint mii_phy_collision_valid {      on_symbol < 1500 * 2 + 16;   }   constraint early_collision {      if (kind == EARLY) on_symbol < 112;   }   constraint late_collision {      if (kind == LATE) {         on_symbol >= 112;      }   }   constraint no_collision {      kind == NONE;   }endclass: mii_phy_collisionvirtual class mii_phy_layer_callbacks extends vmm_xactor_callbacks;   virtual task pre_frame_tx(mii_phy_layer   xactor,                             /*const*/ eth_frame frame,                             mii_phy_collision col,                             ref logic [7:0] bytes[]);   endtask   virtual task pre_symbol_tx(mii_phy_layer         xactor,                              /*const*/ eth_frame       frame,                              /*const*/ ref logic [7:0] bytes[],                              /*const*/ input int       nibble_no,                              ref logic [3:0]       symbol,                              ref logic             dv,                              ref logic             err,                              ref bit               drop);   endtask   virtual task post_frame_tx(mii_phy_layer         xactor,                              /*const*/ eth_frame       frame,                              /*const*/ ref logic [7:0] bytes[],                              /*const*/ input bit       error);   endtask   virtual task post_symbol_rx(mii_phy_layer      xactor,                               /*const*/ int unsigned nibble_count,                               /*const*/ logic [3:0]  symbol,                               /*const*/ logic        dv,                               /*const*/ logic        err);   endtask   virtual task post_frame_rx(mii_phy_layer            xactor,                              /*const*/ eth_frame          frame,                              /*const*/ ref logic [7:0]    bytes[],                              /*const*/ input int unsigned n_bytes);   endtaskendclass: mii_phy_layer_callbacks// Example 4-1// Example 4-32// Example 4-48class mii_phy_layer extends vmm_xactor;   virtual mii_if.phy_layer sigs;   eth_frame_channel   tx_chan;   eth_frame_channel   rx_chan;   eth_pls_indications indications;   // Example 5-18   mii_phy_collision randomized_col;   local eth_utils utils;   local mii_cfg   cfg;   // Example 4-62   local eth_frame rx_factory;   local mii_cfg   hard_rst_cfg;   local eth_frame hard_rst_rx_factory;   local int frame_count;   local bit txing;   local bit rxing;   // Example 4-62   function new(string                   instance,                int unsigned             stream_id = -1,                mii_cfg                  cfg,                virtual mii_if.phy_layer sigs,                eth_frame_channel        tx_chan     = null,                eth_frame_channel        rx_chan     = null,                eth_pls_indications      indications = null,                eth_frame                rx_factory  = null);      super.new("MII PHY Layer", instance, stream_id);      this.cfg = cfg;      this.sigs = sigs;      if (tx_chan == null) tx_chan = new({this.log.get_name(), " PHY->MAC frames"}, instance);      this.tx_chan = tx_chan;      if (rx_chan == null) rx_chan = new({this.log.get_name(), " MAC->PHY frames"}, instance);      this.rx_chan = rx_chan;      this.log.is_above(this.tx_chan.log);      this.log.is_above(this.rx_chan.log);      if (indications == null) indications = new(this.log);      this.indications = indications;      // Example 4-62      if (rx_factory == null) rx_factory = new;      this.rx_factory = rx_factory;             this.hard_rst_cfg        = cfg;      this.hard_rst_rx_factory = rx_factory;      this.randomized_col = new;      this.frame_count = 0;      this.txing = 0;      this.rxing = 0;      this.utils = new;      this.sigs.prx.rxd    <= 4'h0;      this.sigs.prx.rx_dv  <= 1'b0;      this.sigs.prx.rx_err <= 1'b0;      this.sigs.crs        <= 1'b0;      this.sigs.col        <= 1'b0;   endfunction: new   extern virtual function void reconfigure(mii_cfg   cfg        = null,                                            eth_frame rx_factory = null);   extern virtual function void reset_xactor(reset_e typ = SOFT_RST);   extern protected virtual task main();      extern local task tx_driver();   extern local task rx_monitor();   extern local task crs_driver();   extern local task col_driver();endclass: mii_phy_layerfunction void mii_phy_layer::reconfigure(mii_cfg   cfg,                                         eth_frame rx_factory);   if (cfg != null) this.cfg = cfg;   if (rx_factory != null) this.rx_factory = rx_factory;endfunction: reconfigure   function void mii_phy_layer::reset_xactor(reset_e typ);   super.reset_xactor(typ);   this.sigs.prx.rxd    <= 4'h0;   this.sigs.prx.rx_dv  <= 1'b0;   this.sigs.prx.rx_err <= 1'b0;   this.sigs.crs    <= 1'b0;   this.sigs.col    <= 1'b0;   this.tx_chan.flush();   this.rx_chan.flush();   this.indications.reset();   this.frame_count = 0;   this.txing = 0;   this.rxing = 0;   if (typ >= FIRM_RST) begin      this.indications.reset(, vmm_notify::HARD );   end   if (typ >= HARD_RST) begin      this.cfg        = this.hard_rst_cfg;      this.rx_factory = this.hard_rst_rx_factory;   endendfunction: reset_xactortask mii_phy_layer::main();   fork      super.main();      this.tx_driver();      this.rx_monitor();      this.crs_driver();      this.col_driver();         join_noneendtask: maintask mii_phy_layer::tx_driver();   logic [7:0] bytes[];   while (1) begin      eth_frame fr;      bit         error = 0;      bit         col   = 0;            this.wait_if_stopped_or_empty(this.tx_chan);      this.tx_chan.activate(fr);      this.utils.frame_to_bytes(fr, bytes);      // Example 5-18      this.randomized_col.frame = fr;      if (!this.randomized_col.randomize()) begin         `vmm_fatal(this.log, "Cannot find solution for collision descriptor");         this.randomized_col.kind = mii_phy_collision::NONE;      end      `vmm_callback(mii_phy_layer_callbacks,                    pre_frame_tx(this,                                 fr,                                 this.randomized_col,                                 bytes));      if (log.start_msg(vmm_log::DEBUG_TYP , vmm_log::TRACE_SEV )) begin         log.text("Transmitting frame...");         log.text(fr.psdisplay("   "));         log.end_msg();      end      // Wait for a frame to be received to force a collision      if (this.randomized_col.kind != mii_phy_collision::NONE) begin         `vmm_trace(this.log, $psprintf("Forcing a collision on symbol #%0d...",                                        this.randomized_col.on_symbol));         @ (posedge this.sigs.crs);         repeat (this.randomized_col.on_symbol) @ (this.sigs.ptx);      end      this.tx_chan.start();      this.indications.indicate(eth_pls_indications::CARRIER);      this.txing = 1;      foreach (bytes[i]) begin         logic [3:0] nibble0, nibble1;         logic       en;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -