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

systemverilog:interface中的modport用法

        使用modport可以将interface中的信号分组并指定方向,方向是从modport连接的模块看过来的。简单示例如下:

interface cnt_if (input bit clk);logic rstn;logic load_en;logic [3:0] load;logic [7:0] count;modport TEST (input  clk, count,output rstn,load_en,load);modport  DUT  (input clk,rstn,load_en,load,output count);endinterfacemodule Design(clk,rstn,load_en,load,count );input clk,rstn,load_en,load;
output reg [7:0] count;always @(posedge clk or negedge rstn)if(!rstn)count<=0;else count<=count+1;endmoduleclass  AA;virtual cnt_if.DUT this_s;function new(virtual cnt_if.DUT if_inst);this_s=if_inst;
endfunctiontask assig();this_s.rstn=0;repeat(100) @(posedge this_s.clk);this_s.rstn=1;this_s.load_en=0; this_s.load=1; this_s.count='d56;repeat(100) @(posedge this_s.clk);this_s.rstn=0; this_s.load_en=1; this_s.load=0; this_s.count='d34;endtaskendclass module tb;logic clk;initial begin clk=0; endalways #5 clk=~clk;//cnt_if.DUT if_instance (clk);cnt_if if_instance (clk);AA ainstance=new(if_instance.DUT);//Design(clk,rstn,load_en,load,count );Design design_inst(.clk(if_instance.DUT.clk), .rstn(if_instance.DUT.rstn) ,.load_en(if_instance.DUT.load_en ), .load(if_instance.DUT.load) ,.count(if_instance.DUT.count)  );initial beginainstance.assig;endendmodule

注意:
(1)在interface中使用modport将信号分组后,在tb中例化时,直接例化interface的实例,不能例化interface中modport的实例;
(2)在calss中直接例化interface中modport的实例;
(3)在tb中实例化interface的实例后,将interface的实例的modport通过点运算符传递给DUT。

仿真波形如下:

http://www.lryc.cn/news/231189.html

相关文章:

  • VR建筑仿真场景编辑软件有助于激发创作者的灵感和创造力
  • 8.查询数据
  • VB.NET—Bug调试(参数话查询、附近语法错误)
  • 武汉凯迪正大—锂电池均衡维护仪
  • 解决服务器中的mysql连接不上Navicat的问题脚本
  • Git Flow的简单使用
  • LOWORD, HIWORD, LOBYTE, HIBYTE的解释
  • Centos7.9用rancher来快速部署K8S
  • NSSCTF第12页(2)
  • 基于单片机的电源切换控制器设计(论文+源码)
  • 机器学习-特征选择:使用Lassco回归精确选择最佳特征
  • uniapp开发ios上线(在win环境下使用三方)
  • 【深度学习 | 核心概念】那些深度学习路上必经的核心概念,确定不来看看? (六)
  • 景联文科技:驾驭数据浪潮,赋能AI产业——全球领先的数据标注解决方案供应商
  • OpenCV+特征检测
  • Excel-lookup函数核对两个表格的数据匹配
  • Vue 简单的语法
  • 华为ensp:vrrp双机热备负载均衡
  • postswigger 靶场(CSRF)攻略-- 1.没有防御措施的 CSRF 漏洞
  • Langchain知识点(下)
  • 百度飞浆环境安装
  • 云效流水线docker部署 :node.js镜像部署VUE项目
  • 软件工程理论与实践 (吕云翔) 第五章 面向对象方法与UML课后习题及其答案解析
  • 三层架构java _web
  • 微信小程序项目——基本目录构成
  • python 基础语法 (常常容易漏掉)
  • servlet 的XML Schema从哪边获取
  • CPU vs GPU:谁更适合进行图像处理?
  • 基于flask+bootstrap4实现的注重创作的轻博客系统项目源码
  • 手把手教你实现贪吃蛇