目录
12.1?uvm_driver class hierarchy
12.2?How to write driver code?
12.4 How to get sequence items from the sequencer?
12.5.1 Using get_next_item/ try_next_item and item_done methods
12.5.2 Using get and put methods
12.5.3 Difference between get_next_item/ item_done and get/ put approach?
driver与 DUT 交互。它使用接口/interface将随机事务(randomized transactions)或sequence item驱动到 pin-level的DUT。driver必须从uvm_driver扩展。从sequencer中检索/retrieve事务或序列项,driver使用接口句柄将它们驱动到设计。可以从已在顶级层/top-level次结构中设置的配置数据库中检索接口句柄。
uvm_driver 类是参数化类,有两个参数:类型为 REQ的uvm_sequence_item 和 RSP uvm_sequence_item 的。RSP sequence item是可选的。通常,REQ和RSP sequence item具有相同的类类型。如果特别声明,它们可能会有所不同。
uvm_driver 类声明:
class uvm_driver #( type REQ = uvm_sequence_item, type RSP = REQ ) extends uvm_component
class driver extends uvm_driver#(seq_item);
virtual add_if vif;
`uvm_component_utils(driver)
function new(string name = "driver", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual add_if) :: get(this, "", "vif", vif))
`uvm_fatal(get_type_name(), "Not set at top level");
endfunction
task run_phase (uvm_phase phase);
// Get the sequence_item and drive it to DUT
endtask
endclass
driver的uvm_seq_item_pull_port使用TLM接口来接受来自sequencer的REQ sequence items,如果需要,driver可以给sequencr提供一个RSP sequence items。细节在Sequence-Driver-Sequencer communication章节讨论。
有两种与sequencer交互的方式。
我们先来了解一下 get_next_item、try_next_item 和 item_done 方法。
get_next_item 或成功的 try_next_item 检索 REQ? sequence item,使用虚拟接口句柄将其驱动到 DUT。一旦驱动逻辑完成,就必须调用 item_done 方法。?
task run_phase (uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
// Driving logic
...
seq_item_port.item_done();
end
endtask
task run_phase (uvm_phase phase);
forever begin
seq_item_port.get(req);
// Driving logic
...
seq_item_port.put(rsp_item);
end
endtask