uvm driver介绍 |
您所在的位置:网站首页 › drive的done形式 › uvm driver介绍 |
本篇主要介绍uvm环境中的driver。 driver的主要作用是从squencer获取transaction, 然后驱动DUT的interface。如下图所示: Driver的编写 从uvm_driver派生出自定义的class, 比如说是my_driver, 然后用factory机制注册, 并且创建 “new” 函数, 如下面代码所示 12345678910// my_driver is user-given name for this class that has been derived from "uvm_driver"class my_driver extends uvm_driver; // [Recommended] Makes this driver more re-usable `uvm_component_utils (my_driver) // This is standard code for all components function new (string name = "my_driver", uvm_component parent = null); super.new (name, parent); endfunction // Code for rest of the steps come hereendclass 申明 vitual interface, 并在build_phase获取配置: 123456789 // Actual interface object is later obtained by doing a get() call on uvm_config_db virtual if_name vif; virtual function void build_phase (uvm_phase phase); super.build_phase (phase); if (! uvm_config_db #(virtual if_name) :: get (this, "", "vif", vif)) begin `uvm_fatal (get_type_name (), "Didn't get handle to virtual interface if_name") endendfunction 编写run_phase 123456virtual task run_phase (uvm_phase phase); // Loop the following steps // 1. Get next item from the sequencer // 2. Assign data from the received item into DUT interface // 3. Finish driving transaction endtask Driver-Sequencer 通信Driver 可以使用TLM端口和sequencer进行通信, 比如uvm_seq_pull_port。driver 可以向squencer请求transaction, 也可以在完成驱动后,进行回应(reponse)。 那么如何使用API呢? 在agent或者是env中将sequencer和driver的TLM 端口相连: 123virtual function void connect_phase (); m_drv0.seq_item_port.connect (m_seqr0.seq_item_export);endfunction 使用握手的方式:get_next_item后面跟item_done(); 123456789101112131415virtual task run_phase (uvm_phase phase); my_data req_item; forever begin // 1. Get next item from the sequencer seq_item_port.get_next_item (req_item); // 2. Drive signals to the interface @(posedge vif.clk); vif.en |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |