📄 interface.sv
字号:
// $Id: interface.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.//----------------------------------------------------------------------//----------------------------------------------------------------------// INTERFACE mem_pins_if//----------------------------------------------------------------------interface pin_if (input clk); bit [15:0] address; bit [7:0] wr_data; bit [7:0] rd_data; bit rst; bit rw; bit req; bit ack; bit err; modport master_mp( input clk, input rst, output address, output wr_data, input rd_data, output req, output rw, input ack, input err ); modport slave_mp( input clk, input rst, input address, input wr_data, output rd_data, input req, input rw, output ack, output err ); modport monitor_mp( input clk, input rst, input address, input wr_data, input rd_data, input req, input rw , input ack, input err );endinterfaceimport ovm_pkg::*;package user_pkg;//----------------------------------------------------------------------// COMPONENT driver//----------------------------------------------------------------------class driver extends ovm_threaded_component; virtual pin_if pif; function new(string name, ovm_component parent = null); super.new(name, parent); endfunction task run; forever begin @(posedge pif.clk); ovm_report_info("driver", "posedge clk"); //... end endtaskendclass//----------------------------------------------------------------------// ENVIRONMENT env//----------------------------------------------------------------------class env extends ovm_env; local virtual pin_if pif; driver d; function new(string name, virtual pin_if _p); super.new(name); pif = _p; d = new("driver", this); d.pif = pif; endfunction task run(); #100; endtaskendclassendpackageimport user_pkg::*;//----------------------------------------------------------------------// MODULE dut//----------------------------------------------------------------------module dut(pin_if pif); always @(posedge pif.clk) begin ovm_report_info("dut", "posedge clk"); //... endendmodule//----------------------------------------------------------------------// MODULE clkgen//----------------------------------------------------------------------module clkgen(output bit clk); initial begin forever begin #5 clk = 1; #5 clk = 0; end endendmodule//----------------------------------------------------------------------// MODULE top//----------------------------------------------------------------------module top; clkgen ck(clk); pin_if pif(clk); env e; dut d(pif.slave_mp); initial begin e = new("env", pif); e.do_test(); $finish; end endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -