UVM验证平台中的scoreboard

scoreboard主要用于比较reference modelDUT输出是否一致,并给出比较结果。

一个简单的scoreboard如下:


6~7行分别定义了两个端口,一个事exp_port,用于从reference modelap获得期望的数据;

另外一个端口是act_export,用于从monitorap获得实际DUT的输出数据。

 

main_phase中使用fork开启了两个进程,其中一个用于从reference model中获得数据,另一个用于从monitor中获得数据。一般来说,同样一组数据,经过DUT处理后会存在延迟,但是在reference model中部会(除非刻意这么做)。

scoreboard的角度看,reference model中的数据总是先到达,所以在33行中把reference model的数据先放入一个队列中。

由于DUT的输出后到达,所以当36行接收到DUT的输出后,先查看队列中是否有记录,如果没有记录,则说明reference model没有数据输出,而DUT输出了,这是不期望的结果,52行给出错误信息。如果队列中有记录,则从38行从队列中弹出第一个数据,并把此数据与DUT的输出比较,这里比较用到了compare函数,这里之所以可以用这个函数比较,是因为在定义transaction时使用了一些列的uvm_field_*宏。compare会逐字段比较get_actualtmp_tran,如果所有的字段都一样,那么返回1,否则返回0.

★:scoreboard中一般使用一个队列来暂存从reference model中得到的期望数据。


  • 5
    点赞
  • 68
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
以下是一个简单的UVM验证平台示例: 1. 创建一个UVM测试环境类(testbench),该类将包含所有UVM组件,并提供测试所需的接口和配置信息。 ``` class my_testbench extends uvm_env; `uvm_component_utils(my_testbench) // Define interface signals and configurations // ... // Define UVM components my_agent m_agent; my_driver m_driver; my_monitor m_monitor; my_scoreboard m_scoreboard; // Define UVM sequences and sequences library my_sequence_lib m_sequence_lib; function new(string name, uvm_component parent); super.new(name, parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); m_agent = my_agent::type_id::create("m_agent", this); m_driver = my_driver::type_id::create("m_driver", this); m_monitor = my_monitor::type_id::create("m_monitor", this); m_scoreboard = my_scoreboard::type_id::create("m_scoreboard", this); m_sequence_lib = my_sequence_lib::type_id::create("m_sequence_lib", this); endfunction function void connect_phase(uvm_phase phase); super.connect_phase(phase); // Connect UVM components m_driver.seq_item_port.connect(m_agent.seq_item_export); m_monitor.analysis_port.connect(m_agent.analysis_export); m_scoreboard.reference_port.connect(m_monitor.monitor_export); endfunction virtual function void run_phase(uvm_phase phase); super.run_phase(phase); m_sequence_lib.run_sequence(); endfunction endclass ``` 2. 创建一个UVM代理(agent)类,该类将实现将数据传输到DUT和从DUT接收数据的功能。 ``` class my_agent extends uvm_agent; `uvm_component_utils(my_agent) // Define interface signals and configurations // ... // Define UVM components my_sequencer m_sequencer; function new(string name, uvm_component parent); super.new(name, parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); m_sequencer = my_sequencer::type_id::create("m_sequencer", this); endfunction virtual function void connect_phase(uvm_phase phase); super.connect_phase(phase); // Connect UVM components m_sequencer.seq_item_port.connect(seq_item_export); endfunction endclass ``` 3. 创建一个UVM驱动(driver)类,该类将向DUT发送数据。 ``` class my_driver extends uvm_driver; `uvm_component_utils(my_driver) // Define interface signals and configurations // ... function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual task run_phase(uvm_phase phase); super.run_phase(phase); forever begin seq_item_port.get_next_item(req); send_req_to_dut(); seq_item_port.item_done(); end endtask endclass ``` 4. 创建一个UVM监视器(monitor)类,该类将从DUT接收数据。 ``` class my_monitor extends uvm_monitor; `uvm_component_utils(my_monitor) // Define interface signals and configurations // ... function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual task run_phase(uvm_phase phase); super.run_phase(phase); forever begin wait_for_dut_data(); pass_data_to_scoreboard(); end endtask endclass ``` 5. 创建一个UVM评分板(scoreboard)类,该类将比较从驱动程序发送的数据和从监视器接收的数据,以确认DUT是否按预期工作。 ``` class my_scoreboard extends uvm_scoreboard; `uvm_component_utils(my_scoreboard) // Define interface signals and configurations // ... function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual function void compare(ref_item, dut_item, ...); // Compare reference and DUT data // ... endfunction endclass ``` 6. 创建UVM序列(sequence)类和UVM序列库(sequence library)类,以定义测试序列并将其添加到测试环境。 ``` class my_sequence extends uvm_sequence; `uvm_object_param_utils(my_sequence) // Define sequence items and data // ... function new(string name = "my_sequence"); super.new(name); endfunction virtual task body(); // Define test sequence // ... endtask endclass class my_sequence_lib extends uvm_sequence_library; `uvm_component_utils(my_sequence_lib) // Define test sequences my_sequence m_test_sequence; function new(string name, uvm_component parent); super.new(name, parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); m_test_sequence = my_sequence::type_id::create("m_test_sequence"); m_test_sequence.set_sequence_state(uvm_sequence_base::is_auto_item); endfunction function void run_sequence(); m_test_sequence.start(m_sequencer); m_test_sequence.wait_for_sequence_state(UVM_FINISHED); endfunction endclass ``` 7. 在UVM测试使用这些组件,创建一个UVM测试(test)类并运行它。 ``` class my_test extends uvm_test; `uvm_component_utils(my_test) my_testbench m_testbench; function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual function void build_phase(uvm_phase phase); super.build_phase(phase); m_testbench = my_testbench::type_id::create("m_testbench", this); endfunction virtual task run_phase(uvm_phase phase); super.run_phase(phase); // Run testbench m_testbench.run_phase(phase); endtask endclass module top; initial begin uvm_config_db#(uvm_object_wrapper)::set(null, "uvm_test_top", "test", my_test::type_id::get()); run_test(); end endmodule ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值