📄 test.sv
字号:
// $Id: //dvt/vtech/dev/main/ovm/examples/tlm/tlm_fifo/test.sv#2 $//----------------------------------------------------------------------// 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.//----------------------------------------------------------------------module test; `ifdef INCA `include "ovm.svh" `else import ovm_pkg::*; `endif class packet; int i; function new(int v); i=v; endfunction endclass class producer extends ovm_threaded_component; ovm_put_port #(packet) data_out; function new(string name, ovm_component parent); super.new(name,parent); data_out = new("data_out", this); endfunction task run(); packet p, pp; #1 p=new(0); while(data_out.try_put(p)) begin $display("%0t: put data %0d", $time, p.i); #10 p = new(p.i+1); end $display("try_put status return: %0d", p.i); $display("%0t: do a blocking put", $time); data_out.put(p); $display("%0t: blocking put succeeded", $time); endtask endclass class consumer extends ovm_threaded_component; ovm_get_port #(packet) data_in; function new(string name, ovm_component parent); super.new(name,parent); data_in = new("data_in", this); endfunction task run(); packet p; #1000; // fifo will fill up $display("%0t: getting one", $time); data_in.get(p); $display("%0t: recieved data %0d", $time, p.i); #1000; // let the blocking put succeed while(data_in.try_get(p)) begin $display("%0t: recieved data %0d", $time, p.i); #10; end endtask endclass producer prod = new("prod", null); consumer cons = new("cons", null); tlm_fifo #(packet) fifo = new("fifo", null, 10); initial begin prod.data_out.connect(fifo.put_export); cons.data_in.connect(fifo.get_export); fork run_test(); repeat(5) begin $display("%0t: used = %0d : size = %0d", $time, fifo.used(), fifo.size()); #150; end join $display("%0t: used = %0d : size = %0d", $time, fifo.used(), fifo.size()); endendmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -