书接上回:
从零开始搭建UVM平台(一)-只有uvm_driver的验证平台
从零开始搭建UVM平台(五)-加入transaction机制
加入reference model
Reference model的作用类似于dut,输入到dut的数据也会给到reference model进行处理后方便和dut输出的数据一起做比较来查看dut的功能是否正常。
由于reference model的作用仅仅是copy一下数据,因此可以在my_transaction里实现这个copy方法:

在搭建reference model之前要想清楚现在的环境结构。在uvm里,实现不同component之间transaction级别通信的工具是TLM机制。为了从i_agent里面拿到transaction,需要在i_agent里创建一种port,在reference model里也创建一种port,实现transaction从i_agent的port传输到reference model里的port。同时,考虑到两个port在发/收transaction时可能存在阻塞情况,需要在两个port之间建立一个fifo来缓存数据。
在uvm中,常用的主动发数据的port是uvm_analysis_port,常用的用于缓存数据的fifo是uvm_tlm_analysis_fifo,常用的主动接收数据的port是uvm_blocking_get_port。考虑好了这些,可以执行以下步骤:
第一步:新建一个my_model文件

其中port主要用于接收从i_agent传输过来的transaction,经过copy后通过ap写入传输给scoreboard。
第二步:在my_monitor文件里创建一个uvm_analysis_port来实现每收集到一个transaction就传输给reference model。


第三步:i_agent作为my_monitor的parent,作为中间桥梁将i_agent的port指向my_monitor的port,方便reference model能够直接从i_agent的port拿到数据。

第四步:在my_env里例化reference model,并连接各个port和fifo,实现最后的连接。
