Systemverilog中使用interface连接testbench和dut的端口

news/2024/5/19 20:29:41 标签: systemverilog

1.dut的端口声明如下,文件名为top.v:

module top
(
	input 				clk			,
	input 				rst_n		,
	
	input 				wr_n		,
	input 				rd_n		,
	input 				cs0_n		,
	input 				cs7_n		,
	input [15 : 0] 		bus_addr_in	,
	//UART淇″彿
	input 				rx0_d		,
	output 				tx0_d		,		
    );

2.定义interface接口,文件名为top_if.sv;

interface  top_if(  input bit 				clk );


	logic 				rst_n		;
		                    
	logic 				wr_n		;
	logic 				rd_n		;
	logic 				cs0_n		;
	logic 				cs7_n		;
	logic [15 : 0] 		bus_addr_in	;
	//UART信号                      
	logic 				rx0_d		;
	logic 				tx0_d		;
   );

3.在testbench模块中连接interface接口与dut的端口,interface与dut的端口连接时,只能按照信号名称一个一个的绑定。接下来就可以在testbench中通过interface的实例引用信号名,来对其进行赋值。这里通过`include "top_if.sv"将接口引进来。

`include "top_if.sv"
module tb;
	 bit 				clk			;

	 top_if topif(clk);    //实例化top_if对象,将clk传递给interface
	
	 top   top_inst( .clk(topif.clk),               //将topif接口对象与DUT端口绑定,这里直接按照位置绑定
	                                   .rst_n( topif.rst_n    ),
	                                   .wr_n(topif.wr_n),
                                        .rst_n(topif.rst_n)		,
	                                      .wr_n	(topif.wr_n	)	,
	                                    .rd_n(topif.rd_n)		,
                                        .cs0_n(topif.cs0_n)		,
	                                    .cs7_n	(topif.cs7_n)	,
	                                   . bus_addr_in(topif.bus_addr_in)	,
	                
	                                    .rx0_d (topif.rx0_d)		,
	                                    .tx0_d(topif.tx0_d)			
        );
	initial
		begin
			clk=0; 
			topif.rst_n=0;
			#100 topif.rst_n=1;
			
		end
	
	always #12.5 clk=~clk;
	
	endmodule




 


http://www.niftyadmin.cn/n/5128361.html

相关文章

mysql经典问题(可用于面试提问)

mysql经典问题(可用于面试提问) 1.Where 后面的列顺序是不是要符合最左原则? Where a1 and b2 等价于 Where b2 and a1 最左原则指的是索引顺序,不是谓词顺序,以上两个条件都匹配(a,b) 复合索引。 2.Join 的顺序是…

K8s概念汇总-笔记

目录 1.Master 1.1在Master上运⾏着以下关键进程 2.什么是Node? 1.2在每个Node上都运⾏着以下关键进程 3.什么是 Pod ? 4. 什么是Label ? 5.Replication Controller 6.Deployment 6.1Deployment的典型场景: 7.Horizontal Pod Autoscaler TODO…

node(三)express框架

文章目录 1.express介绍2.express初体验3.express路由3.1什么是路由?3.2路由的使用 1.express介绍 是一个基于Node平台的极简、灵活的WEB应用开发框架,官网地址:https://www.expressjs.com.cn/ 简单来说,express是一个封装好的工…

强化学习------PPO算法

目录 简介一、PPO原理1、由On-policy 转化为Off-policy2、Importance Sampling(重要性采样)3、off-policy下的梯度公式推导 二、PPO算法两种形式1、PPO-Penalty2、PPO-Clip 三、PPO算法实战四、参考 简介 PPO 算法之所以被提出,根本原因在于…

P7473 重力球

P7473 重力球 Solution 考虑 Brute Force:对于每一次询问,通过 BFS 处理出最近的交汇点,输出答案。 很显然,会 TLE \colorbox{navy}{\color{white}{TLE}} TLE​。 故,考虑 优化: 观察发现障碍物数量非…

Arduino驱动ME007-ULS防水测距模组(超声波传感器)

目录 1、传感器特性 2、控制器和传感器连线图 3、驱动程序 ULS型超声波传感器,是采用一体化防水探头设计而成的一款高性能的测距传感器,采用超声波回拨测距原理,运用精准的时差测量技术测量非接触式传感器与目标物体的之间的距离。对于透明物体或有色物体,金属物体,非金…

【Spring】快速入门Spring Web MVC

文章目录 1. 什么是Spring Web MVC1.1 MVC1.2 Spring MVC 2. 使用Spring MVC2.1 项目创建2.2 建立连接2.2.1 RequestMapping 注解2.2.2 RestController 注解2.2.3 RequestMapping 使⽤2.2.4 RequestMapping 是什么请求?POST?GET?…&#xff1…

netcore webapi action 同时支持 get 和 post 请求

最近在项目开发过程中,有个别接口需要同时支持GET和POST请求,经过一番测试,貌似NetCore只能接收指定的FromBody、FromQuery等参数,经过一番查找后发现文章:为ASP.NET Core实现一个自适应ModelBinder,让Acti…