《Practical UVM Step By Step with IEEE》2.4 Create UVM Testbench Environment for the DUT
2.4创建UVM测试平台环境
(1) DUT的每组interface都和一个uvm容器类agent相关联; agent封装了一些产生激励(seqr),驱动数据到interface(driver)以及监测interface上data的子组件(monitor);
(2) wb_env_test框图:
2.4.1 Environment Class
1 class wb_env extends uvm_env; 2 wb_master_agent master_agent; 3 wb_slave_agent slave_agent; 4 wb_env_cov cov; 5 wb_scoreboard sb; 6 reset_agent rst_agent; 7 8 `uvm_component_utils(wb_env) 9 10 extern function new(string name="wb_env", uvm_component parent=null); 11 extern virtual function void build_phase(uvm_phase phase); 12 extern virtual function void connect_phase(uvm_phase phase); 13 14 endclass: wb_env
2.4.2 Master Agent
2.4.3 Slave Agent
(1) slave agent和master agent类似; 二者的主要不同之处在于master agent向DUT发送transaction,而slave agent等待DUT向它发送transaction;
(2) master agent与master interface相连,slave agent与slave interface相连;
2.4.4 Scoreboard
(1) scoreboard比较DUT的输入和DUT的输出,比较来自与master agent的transaction和slave agent的transaction;
1 class wb_scoreboard extends uvm_scoreboard; 2 `uvm_component_utils(wb_scoreboard) 3 4 uvm_tlm_analysis_fifo #(wb_transaction) expected_wb_transaction_fifo; 5 uvm_tlm_analysis_fifo #(wb_transaction) actual_wb_transaction_fifo; 6 7 function new(string name, uvm_component parent); 8 super.new(name,parent); 9 endfunction 10 11 extern virtual function void build_phase(uvm_phase phase); 12 extern virtual function void connect_phase(uvm_phase phase); 13 extern virtual task run_phase(uvm_phase phase); 14 15 endclass: wb_scoreboard
2.4.5 Coverage
1 class wb_env_cov extends uvm_subscriber #(wb_transaction); 2 event cov_event; 3 wb_transaction tr; 4 `uvm_component_utils(wb_env_cov) 5 6 covergroup cg_trans @(cov_event); 7 coverpoint tr.kind; 8 coverpoint tr.address { 9 bins low ={[0:10]}; 10 bins mid ={[10:100]}; 11 bins high={[100:$]}; 12 } 13 coverpoint tr.lock; 14 coverpoint tr.status; 15 coverpoint tr.num_wait_states { 16 bins legal[] = {[0:15]}; 17 illegal_bins ib = {[16:$]}; 18 } 19 endgroup: cg_trans 20 21 function new(string name, uvm_component parent); 22 super.new(name, parent); 23 cg_trans=new; 24 endfunction: new 25 26 virtual function void write(wb_transaction t); 27 this.tr=t; 28 -> cov_event; 29 endfunction: write 30 31 endclass: wb_env_cov