uvm_scoreboard

本篇主要介绍一下uvm_scoreboard的作用和创建步骤。

uvm_scoreboard一般是包含了refrence model和checker, 用refrece model的输出和电路的输出做对比, 来判断电路是否工作正常。

一个典型的应用如下图所示。 对于一些信号处理算法相关的电路, 这个reference model可能是C++ model。

创建 uvm_scoreboard

  1. 和其他的component一样, 第一步仍然是写一个自定义的scoreboard, 并且注册
1
2
3
4
5
6
7
8
9
10
// my_scbd is user-given name for this class that has been derived from "uvm_scoreboard"
class my_scbd extends uvm_scoreboard;
// [Recommended] Makes this scoreboard more re-usable
`uvm_component_utils (my_scoreboard)
// This is standard code for all components
function new (string name = "my_scoreboard", uvm_component parent = null);
super.new (name, parent);
endfunction
// Code for rest of the steps come here
endclass
  1. 为了接收其他component的transaction, 需要增加一些TLM端口,并且在build phase 进行实例化:
1
2
3
4
5
uvm_analysis_imp #(apb_pkt, my_scoreboard) apb_export;
// Instantiate the analysis port, because afterall, its a class object
function void build_phase (uvm_phase phase);
apb_export = new ("apb_export", this);
endfunction
  1. 当数据通过analysis port接收以后, 定义一些操作:
1
2
3
4
virtual function void write (apb_pkt data);
// What should be done with the data packet received comes here - let's display it
`uvm_info ("write", $sformatf("Data received = 0x%0h", data), UVM_MEDIUM)
endfunction
  1. check数据。 其实check的过程并不一定实在check phase, 也可以在run_phase
1
2
3
virtual function void check_phase (uvm_phase phase);
...
endfunction
  1. 把scoreboard的analysis端口和env中的其他component连接起来
1
2
3
4
5
6
7
8
9
10
class my_env extends uvm_env;
...

// Step5: Connect the analysis port of the scoreboard with the monitor so that
// the scoreboard gets data whenever monitor broadcasts the data.
virtual function void connect_phase (uvm_phase phase);
super.connect_phase (phase);
m_apb_agent.m_apb_mon.analysis_port.connect (m_scbd.apb_export);
endfunction
endclass