当前位置: 首页 > article >正文

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

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.kler.cn/news/107480.html

相关文章:

  • 铁轨(Rails, ACM/ICPC CERC 1997, UVa 514)rust解法
  • Kubernetes - Ingress HTTP 负载搭建部署解决方案(新版本v1.21+)
  • [双指针] Leetcode 283.移动零和1089.复习零
  • 设计模式:访问者模式(C#、JAVA、JavaScript、C++、Python、Go、PHP)
  • AT32固件库外设使用,ArduinoAPI接口移植,模块化
  • windows服务器环境下使用php调用com组件
  • 【springBoot】博客系统
  • 10000字!图解机器学习特征工程
  • Vmware下的虚拟机NAT连接后仍然木有网络
  • Redis的过期键删除策略看这一篇就足够了
  • Could not update Flowable database schema: unknown version from database:
  • C++——类和对象(中)(2)尚未完结
  • Angular-02:环境等说明
  • Crawler4j实例爬取爱奇艺热播剧案例
  • 技术栈 业务架构 插件库
  • mac电脑怎么永久性彻底删除文件?
  • AI与Prompt:解锁软件开发团队的魔法咒语,在复杂任务上生成正确率更高的代码
  • 如何能在项目具体编码实现之前能尽可能早的发现问题并解决问题
  • jenkins自动化操作步骤(gitblit)
  • SDK 资源
  • 文本处理方法及其在NLP中的应用
  • 获取IEEE会议论文的标题和摘要
  • Maven - 国内 Maven 镜像仓库(加速包,冲冲冲~)
  • 设计模式(15)组合模式
  • Ubuntu安装pyenv,配置虚拟环境
  • 二维码智慧门牌管理系统升级解决方案:采集项目的建立与运用
  • 构造函数。
  • LangChain+LLM实战---模拟实现假的LLM
  • 基于Ubuntu20.04安装ROS系统
  • ROS自学笔记十六:URDF优化_xacro文件