UVM中uvm_component之间的transaction传输

有5个uvm component class:A, B, C, D, E,需要把一个transaction从A通过B, C, D传到E,怎么传输?

        方法一:使用TLM通信传输,利用多层PORT端口级联实现,如图1所示。

图1 多层PORT连接

        A component的代码为:

图2 A component代码

        B component的代码为:

图3 B component的代码

       C component和D component的代码类似于B component。在每个component中定义一个uvm_blocking_put_port端口(PORT)和次内层component的句柄,然后再build_phase中实例化,最后在connect_phase中连接起来。

        E component的代码为:

图4 E component的代码

        env的代码为:

图5 env的代码

       TLM是Transaction Level Modeling(事务级建模)的缩写,它起源于SystemC的一种通信标准。TLM通信中有三个常用的术语:put操作、get操作和transport操作。有三种端口PORT、EXPORT和IMP。在UVM中,只有IMP才能作为连接关系的终点,如果PORT或者EXPORT作为终点,则会报错。

       除了以上三种端口外,UVM中还有两种特殊的端口:analysis_portanalysis_export,用于传递transactionanalysis_portanalysis_export如果直接相连会出错,只有在analysis_export后面再连接一级uvm_analysis_imp才不会出错。

在此基础上,可以引入FIFO来进行通信,FIFO的本质是一块缓存加两个IMPFIFO中的analysis_exportblocking_get_export虽然名字中有关键字export,但是其类型却是IMP(uvm_analysis_imp)

       不过无论使用FIFO还是使用IMP,都能实现同样的目标,两者各有其优势与劣势,在实际应用中,读者可以根据自己的习惯来选择合适的连接方式。

 

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
`start_item`函数是UVM序列化对象的一种机制,用于将序列化对象插入到序列执行队列。以下是UVM`start_item`的源代码: ```systemverilog function bit uvm_sequence_base::start_item (uvm_sequence_item item, uvm_sequencer_base sequencer, bit set_priority = 0, string source_file = "", int source_line = 0); uvm_sequence_item item_copy; uvm_tlm_transaction_base t; uvm_component comp = get_parent(); uvm_phase phase; if (!item) `uvm_fatal("NOITEM","Attempting to start a NULL sequence_item") if (!sequencer) `uvm_fatal("NOSEQ","Attempting to start a sequence_item with a NULL sequencer") if (comp is uvm_root) begin `uvm_warning("SEQROOT",{"Attempt to start sequence '",get_type_name(), "' outside of a phase process. Ignored."}) return 0; end // Create a copy of the item if(item.try_clone(item_copy) == 0) begin `uvm_error("CLONE", {"Unable to clone sequence item '",item.get_type_name(),"'"}) return 0; end // Check for TLM analysis ports if(item_copy.get_type_name() == "uvm_tlm_analysis_port_base") begin t = item_copy; t.set_source_info(source_file, source_line); t.analysis_imp.connect(item_copy.analysis_export); t.write(t); return 1; end // Set the item's sequencer item_copy.set_sequencer(sequencer); // Set the item's source info item_copy.set_source_info(source_file, source_line); // Set the item's priority if (set_priority) item_copy.set_priority(m_priority); // If in a run phase, start the item phase = comp.get_phase(); if (phase != null && phase.get_name() == "run") begin if (!sequencer.start_item(item_copy)) begin `uvm_error("NOSEQITEM", {"Failed to start sequence item ", item_copy.get_type_name()," with sequencer ", sequencer.get_type_name()}) return 0; end end else m_req_q.push_back(item_copy); return 1; endfunction ``` 此函数接收四个参数: - `item`:要插入序列执行队列的序列化对象。 - `sequencer`:将序列化对象插入到其执行队列UVM序列器。 - `set_priority`:指示是否应将`item`的优先级设置为该序列的优先级。 - `source_file`和`source_line`:指示从哪个源代码文件和行开始创建序列化对象。 该函数首先检查传递的参数是否有效。然后,它会复制序列化对象并将其设置在传递的`sequencer`。如果序列化对象是一个TLM分析端口,则该函数会将其连接到分析导出,并通过`write`函数写入分析对象。如果在运行阶段,则该函数将使用传递的`sequencer`启动序列化对象。否则,它将序列化对象插入到要求队列。函数返回1表示成功,返回0表示失败。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谷公子的藏经阁

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值