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

📄 fifo.sv

📁 Open Verification Methodology
💻 SV
字号:
// $Id: fifo.sv,v 1.2 2008/01/02 09:22:50 jlrose Exp $//----------------------------------------------------------------------//   Copyright 2007-2008 Mentor Graphics Corporation//   Copyright 2007-2008 Cadence Design Systems, 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.//----------------------------------------------------------------------//----------------------------------------------------------------------// This example illustrates how to create a producer and consumer which// are completely independent.  Communicate is sent through a channel,// in this case a fifo.  The fifo throttles the communication.  This is// also the first example to use the OVM library.  The fifo channel,// transaction-level ports, and the messsagngin facilities are part of// the OVM library.//----------------------------------------------------------------------package user_pkg;  import ovm_pkg::*;    //----------------------------------------------------------------------  // CLASS producer  //----------------------------------------------------------------------  class producer extends ovm_threaded_component;      ovm_blocking_put_port #(int) put_port;      function new(string name, ovm_component p = null);      super.new(name,p);      put_port = new("put_port", this);    endfunction      task run;                int randval;      string s;            for(int i = 0; i < 10; i++)        begin          randval = $random % 100;          //randval = i;          $sformat(s, "sending     %4d", randval);          ovm_report_info("producer", s);          put_port.put(randval);        end    endtask        endclass : producer    //----------------------------------------------------------------------  // CLASS consumer  //----------------------------------------------------------------------  class consumer extends ovm_threaded_component;      ovm_blocking_get_port #(int) get_port;      function new(string name, ovm_component p = null);      super.new(name,p);      get_port = new("get_port", this);    endfunction      task run;        int val;      string s;        forever        begin          get_port.get(val);          $sformat(s, "receiving   %4d", val);          ovm_report_info("consumer", s);        end      endtask        endclass : consumer    //----------------------------------------------------------------------  // CLASS env  //----------------------------------------------------------------------  class env extends ovm_env;      producer p;    consumer c;    tlm_fifo #(int) f;      function new(string name, ovm_component parent);      super.new(name);      p = new("producer", this);      c = new("consumer", this);      f = new("fifo", this);    endfunction      function void connect();      p.put_port.connect(f.blocking_put_export);      c.get_port.connect(f.blocking_get_export);    endfunction      task run();      #100;    endtask  endclass  endpackage//----------------------------------------------------------------------// MODULE top//----------------------------------------------------------------------module top;  import user_pkg::*;  env e;  initial begin    e = new("env", null);    e.do_test();    $finish;  endendmodule : top

⌨️ 快捷键说明

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