Next, let's think about automatically comparing against expected values. In other words, we're going to introduce a scoreboard.
I want to automate the process of doing 1000 random writes, then reading back 1000 times and comparing the results.
To do this, we build in a scoreboard. For this, we introduce something called an analysis_port into the monitor.
First, let's define the scoreboard item. I think this corresponds to an entry field of the scoreboard.
class sample_scrbd_item extends uvm_object; bit [7:0] addr, data; `uvm_object_utils_begin(sample_scrbd_item) `uvm_field_int(addr, UVM_DEFAULT) `uvm_field_int(data, UVM_DEFAULT) `uvm_object_utils_end function new (string name="sample_scrbd_item"); super.new(name); endfunction endclass
Then, using this class, we write out the behavior through the analysis_port:
- Build in an
analysis_portfor expected values - Build in an
analysis_portfor observed values - Write to the scoreboard through the
analysis_port
We embed these into sample_master_monitor.
model/sample_master_monitor.sv
class sample_master_monitor extends uvm_monitor; virtual sample_if vif; uvm_analysis_port #(sample_scrbd_item) ap_write; uvm_analysis_port #(sample_scrbd_item) ap_read; event scrbd_e; //event definition `uvm_component_utils(sample_master_monitor) function new (string name, uvm_component parent); super.new(name, parent); ap_write = new("ap_write", this); ap_read = new("ap_read", this); endfunction
Next, we define the testbench-side umv_env class (tb_env.sv). Roughly speaking, it has a structure that wraps sample_env and gp_scoreboard at an even higher level.
class tb_env extends uvm_env; sample_env sample_model; gp_scoreboard #(sample_scrbd_item) sample_scrbd; // Generic score-board /* ... omitted ... */
sample_test.sv is structured as follows.
sample_test.sv
class sample_test extends uvm_test; `uvm_component_utils(sample_test) tb_env env; /* ... omitted ... */ function void build_phase(uvm_phase phase); super.build_phase(phase); uvm_config_db #(uvm_object_wrapper)::set(this, "env.sample_model.master.sequencer.run_phase", "default_sequence", write_read_seq::type_id::get() ); uvm_config_db #(uvm_object_wrapper)::set(this, "env.sample_model.slave.sequencer.run_phase", "default_sequence", normal_response_seq::type_id::get() ); env = tb_env::type_id::create("env", this); endfunction // build_phase
UVM_INFO @ 0: uvm_test_top.env.sample_model.slave.driver [SLAVE] write access accept. addr=10h, data=5ah UVM_INFO @ 0: uvm_test_top.env.sample_model.master.monitor [MON] write addr=10h wdata=5ah UVM_INFO @ 0: uvm_test_top.env.sample_scrbd [SCRBD] write expected data UVM_INFO @ 0: uvm_test_top.env.sample_model.master.driver [DRIVER] Hi UVM_INFO @ 1000: uvm_test_top.env.sample_model.slave.driver [SLAVE] read access accept. adr=10h UVM_INFO @ 1000: uvm_test_top.env.sample_model.slave.driver [SLAVE] read data is = 5ah UVM_INFO @ 1000: uvm_test_top.env.sample_model.master.monitor [MON] read addr=10h rdata=5ah UVM_INFO @ 1000: uvm_test_top.env.sample_scrbd [SCRBD] write observed data UVM_INFO @ 1000: uvm_test_top.env.sample_scrbd [SCRBD] data compare OK UVM_INFO @ 1000: uvm_test_top.env.sample_model.master.driver [DRIVER] Hi

This is an English translation of the original Japanese post: Vivado Simulatorを使ってUVMに入門する (8. スコアボードの導入)