1.总线功能模型作用:

总线功能模型可以用来产生激励,也可以监视设计的响应。通常,一个总线功能模型实现这两个操作。

2.CPU transactions

task write_cycle(input bit [23:0] wadd,
input bit [31:0] wdat);
do @ (cb) while (cb.phi != 2);
cb.addr <= wadd;
cb.ads  <= 1’b0;
cb.rw   <= 1’b1;
cb.data <= wdat;
repeat (2) @ (cb);
cb.ads  <= 1’b1;
do @(cb) while (cb.phi != 2 ||
cb.ready != ’0’);
cb.data <= ’z;
endtask: write_cycle

2.1 总线功能程序能包含返回值

All of the abstracted transactions shown so far were unidirectional.Data always flowed from the testbench through the bus-functional task where the data was applied to the design and outputs were checked for correctness. What if determining the correctness of the output required visibility over multiple operations? What if only the relevant output values for this testcase were known and the others were to be ignored?  Bus-functional tasks can just as easily sample output and return it instead of comparing the output against supplied expected responses. The sampled value can then be processed by the testbench where the value can be dealt with according to the needs of the testcase. For example, Sample 5-50 shows the  read operation of the 386SX interface. Notice how the value read is not compared against an expected value. The value read is instead returned through an output argument.

task read_cycle(input  bit [23:0] radd,
output bit [31:0] rdat);
do @(cb) while (phi != 2);
cb.addr <= radd;
cb.ads  <= 1’b0;
cb.rw   <= 1’b0;
repeat (2) @ (cb);
cb.ads  <= 1’b1;
do @(cb) while (cb.phi != 2 ||
cb.ready != 1’b0);
rdat = cb.data;
endtask: read_cycle

2.2 从总线功能任务到总线功能模型

If two or more threads must read from (or write to) the design, the operations must be coordinated. To pipeline concurrent operations,it is necessary to put a semaphore around the entire bus-functional model. Much like a semaphore was used to detect concurrent invocation of a non-re-entrant task, it will be used to detect concurrent
invocation of transactions in a non-re-entrant bus-functional model.Sample 5-53 shows how a bus-functional model can be protected against concurrent transactions using a semaphore. It is up to you to decide, should the semaphore  detect a concurrent transaction,whether to wait for the bus-functional model to become available or
to terminate with an error.

class i386sx;
local semaphore sem;
virtual i386sx_if sigs;
...
virtual task read(input  bit [23:0] radd,
output bit [31:0] rdat);
if (!this.sem.try_get(1)) ...;
this.sigs.cb.addr <= radd;
...
this.sem.put(1);
endtask: read
virtual task write(input bit [23:0] wdd,
input bit [31:0] wdat);
if (!this.sem.try_get(1)) ...;
this.sigs.cb.addr <= wadd;
...
this.sem.put(1);
endtask: write
endclass: i386sx

3.Collect all signals in an interface.

Bus-functional models encapsulated in classes can access physical signals in one of two ways: through hierarchic- al —white-box—references or through a virtual interface. Using hierarchical references would make the bus-functi- onal model class specific to a particular set of interface signals. It would not be possible to reuse the model in a diff- erent testbench or instantiate it more than once in the same testbench without copying it and modifying the referenc- es. The only mechanism that will make bus-functional models reusable within or across  testbenches is the  virtual interface. This implies that all physical-level signals required by the bus-functional model be encapsulated in an interface .

Specify virtual interface to connect to via the constructor.

All class-encapsulated bus-functional model examples so far had avirtual interface data member that was used to access the physical interface of the bus-functional model. This data member must be set somehow. Module pins are connected when the module is instantiated. This way, the same module may be used more than
once but connected to different signals. Similarly, a virtual interface in a bus-functional model is connected when the bus-functional model is instantiated. Because the bus-functional model is encapsulated in a  class, it is instantiated when its constructor is invoked.Therefore, the  virtual interface connection is specified as a constructor  argument, as shown in Sample 5-60. The virtual interface is connected when a new instance of the bus-functional model is created by calling the constructor and specifying an interface instance it is bound to via a cross-module reference, as shown in Sample 5-61.

//5-60Virtual interface as constructor argument.
class mii_mac_bfm;
virtual mii_if sigs;
...
function new(virtual mii_if sigs);
this.sigs = sigs;
endfunction: new
endclass: mii_mac_bfm
//Sample 5-61.Binding a virtual interface in a class instance.
module tb_top;
mii_if if0();
...
endmodule
program test;
mii_mac_bfm mac = new(tb_top.if0);
...
endprogram: test

4. Configurable Bus-Functional Models

Configuration parameters should be implemented as properties in a configurationclass. An instance of the configuration class would be passed to the bus-functional model via its constructor, alongside the interface binding. Using a separate configuration class will make it easier to create random configurations and to ensure that
multiple instances of the bus-functional model have an identical configuration. The current configuration should be kept in a local class property to prevent it from being modified without the busfunctional model knowing about it or at the wrong time. If it is possible for a bus-functional model to be reconfigured during a simulation—such as the RS-232 model—a reconfigure method should be provided. That method can check that the configuration is valid,that it is an appropriate time for the bus functional model to be reconfigured—e.g. it is idle—and to perform the necessary operations to notify the bus-functional model tasks of the new configuration. What important safety measure is missing from Sample 5-62?1  (1.The entire bus-functional model should be protected using a semaphore to prevent concurrent access to the interface signals. )

class rs232_cfg;
int unsigned baud_rate;
enum {NONE, ODD, EVEN, MARK, SPACE} parity;
bit data8;
bit stop2;
endclass: rs232_cfg
class rs232;
virtual rs232_if sigs;
local rs232_cfg  cfg;
function new(virtual rs232_if sigs,
rs232_cfg cfg);
this.sigs = sigs;
this.cfg  = cfg;
endfunction: new
function void reconfigure(rs232_cfg cfg);
...
this.cfg = cfg;
endfunction: reconfigure
task send(bit [7:0] data);
time duration = 1s / this.cfg.baud_rate;
int i;
this.sigs.tx <= 1’b0;
#(duration);
i = (this.sigs.data8) ? 8 : 7;
while (i-- > 0) begin
this.sigs.tx <= data[i];
#(duration);
end
...
this.sigs.tx <= 1’b1;
#(duration * (this.sigs.stop2+1));
endtask: send
...
endclass: rs232

BFM-总线功能模型相关推荐

  1. 点对点信道互连以太网实验_汽车以太网 – 引领汽车IVN向多速以太网过渡

    1.概述 汽车行业已经成功地基于开放IEEE标准引入了用于车载网络(IVN)的以太网. 在OPEN联盟SIG和IEEE 802.3工作组的推动下,这些标准旨在开发一种更简单但功能更强大的汽车电气/电子 ...

  2. verilog经验谈

    规范很重要 工作过的朋友肯定知道,公司里是很强调规范的,特别是对于大的设计(无论软件 还是硬件),不按照规范走几乎是不可实现的.逻辑设计也是这样:如果不按规范做的 话,过一个月后调试时发现有错,回头再 ...

  3. 这是一篇很好的文章,学verilog的可以好好看看

    规范很重要 工作过的朋友肯定知道,公司里是很强调规范的,特别是对于大的设计(无论软件 还是硬件),不按照规范走几乎是不可实现的.逻辑设计也是这样:如果不按规范做的 话,过一个月后调试时发现有错,回头再 ...

  4. HLS(一)Vivado高层次综合概述

    目录 1.什么是FPGA? 1.1 简介 1.2 架构 1.3 FPGA并行方式与处理器对比 2.硬件设计基本概念 2.1 时钟频率 2.2 延迟 2.3 吞吐率 2.4 存储布局 3.高层次综合 3 ...

  5. Josh‘s Notes: SystemVerilog 验证 (Part 1 — 验证导论)

    文章目录 1. 验证流程 1.1. 不同层次上的测试 1.2. 验证计划 2. Testbench 的基本功能 3. 定向测试 4. 方法学基础 5. 约束下的随机激励 6. 我们的随机化对象是什么 ...

  6. SystemVerilog学习-02-数据类型

    Verilog数据类型 Verilog语言提供两种基本的数据类型,即变量类型(variables)和线网类型(nets),这两种类型都是四值逻辑,即可表示0.1.X和Z值. reg,integer和t ...

  7. 荐读:Xilinx ZYNQ 动手实操演练

    今天给大侠带来Xilinx ZYNQ 动手实操演练,话不多说,上货.当我们一提到 Xilinx ZYNQ,大家脑海大多数就会浮现一个描述的词汇,高端,其实这个词很贴切的形容了Zynq系列产品,Xili ...

  8. verilog学习五点经验分享 http://bbs.21ic.com/icview-402231-1-1.html

    1.规范很重要 工作过的朋友肯定知道,公司里是很强调规范的,特别是对于大的设计(无论软件还是硬件),不按照规范走几乎是不可实现的.逻辑设计也是这样:如果不按规范做的话,过一个月后调试时发现有错,回头再 ...

  9. 处女项目后关于IC验证经验的总结

      http://www.cnblogs.com/jyaray/archive/2011/05/11/2043091.html   完整的.详细的设计规范是验证工作的重要起点. 验证工作根据设计规范( ...

  10. FPGA工程师的个人工作经历总结

    很早之前就想对这几个月工作经历写的东西,一是作为自己的总结,二是自己也很想将自己这段时间的一些经历和大家分享一下,希望对初学者而言能使得他们能少走一些弯路.只是公司里的事情很多,最近经常加班,所以一直 ...

最新文章

  1. 直接在PDF文件中改变字体的小技巧
  2. 开源用户界面和布局的套件XiaoCai.WinformUI(美化用户界面利器)
  3. java的解释程序_JAVA改错和程序解释
  4. ROS2 on android,ROS2 通过Debian安装ROS2
  5. ArcGIS中合并(merge)、联合(union)、追加(append)、融合(dissolve)的用法区别与联系
  6. 计算机考研压分的学校,篡改分数,恶意压分...考研院校的骚操作大盘点!小心避坑!...
  7. 一起来玩AZURE SQL(四)AZURE SQL之逻辑服务器介绍
  8. vue 实现文本的拖拽_基于Vue实现拖拽功能
  9. ExtJs之combobox详解
  10. Eclipse启动Tomcat时,45秒超时解决方案
  11. 全明星投资融资5亿美元,曾下注亏损百亿的滴滴,及商汤、陆金所等独角兽...
  12. 网站采集工具免费采集发布网站后台
  13. android studio USB连接华为手机不显示调试信息问题
  14. VGG model 涉及到的paper
  15. 热门好用的二维码生成器API
  16. 解析中小学生的 AI 思维学习模型
  17. Python爬虫:(亲测,已解决!)解决在使用谷歌浏览器的开发者工具时,没有Referer防盗链缺失问题。
  18. Python设计模式(四) -- 模板方法模式
  19. Libgdx之正交相机 OrthographicCamera
  20. 查看锐捷poe交换机供电状态_锐捷 RG-S2910-24GT4SFP-UP-H 24个电口支持PoE和PoE+供电交换机...

热门文章

  1. 贪心 + 优先队列:程序员PIPI
  2. 数据分析学习总结笔记01:情感分析
  3. Win11热键冲突怎么解决?
  4. 精密光学测量1-概论
  5. 如何用cmd打开管理员模式
  6. SignalR 循序渐进
  7. bak 安全牛 kali link
  8. android 电子签名证书,android 电子签名实现
  9. 分区属性揭秘 Win8 电脑 OEM 分区创建 分区属性
  10. 高等代数笔记4:线性空间