UVM实战指南-第四章
- 格式:pdf
- 大小:604.05 KB
- 文档页数:35
(*)题外话:TLM可能是UVM中最重要的概念,掌握了TLM,就可以开场尝试编写一些小程序了。
翻译这篇文章,也是为了稳固加强对TLM的理解。
(*)几个名词:transaction翻译为事务或者交易;packet翻译为封包,packet属于transaction;monitor翻译为监视器;driver翻译为驱动器;scoreboard翻译为记分牌;有些词汇直接被运用到UVM源代码上,所以有时候用英文更容易描述清楚。
(*)语言的目的是为了交流,翻译不是为了纯粹的语言转换,而是为了传递思想。
4.6 UVM中事务级建模(TLM)20多年前,设计者从门级转向RTL级。
这次转换来自于标准Verilog/VHDL的RTL编码风格,以及RTL综合实现工具的推出。
使用RTL最大的好处是让设计者更多的专注于时序行为的设计以及功能的正确性,而很少考虑门级相关设计。
TLM(事务级建模)同样在抽象级别上更进了一步,在设计与验证领域都有出现。
通过TLM, 中心放在系统级别的各种事务流的建模,而更少关心时钟级别的行为。
TLM在测试向量中已经使用多年。
通常,在产生鼓励与覆盖率检查的时候使用事务而不是用时钟级别建模,这种方式就是TLM. 为了验证RTL级别的DUT(需要测试的模块),测试向量使用事务第 1 页发生器(transactor)(有时也称为总线功能模型(BFM)),将RTL 级与事务级进展转换。
在UVM中,此事务发生器也被叫做驱动(driver)或者收集器(collector)。
TLM中,事务通过方法调用与类对象来建模。
使用事务级而不是信号级别来建模有几个显著的好处:•TLM比RTL更简洁,仿真速度快。
•TLM模型的抽象级别更高,更加契合验证工程师或设计工程师对内部功能的考虑,从而使得建模更简单,并且更容易被其他工程师理解。
•TLM模型将不符合复用的局部移到模型之外,因此TLM很适合复用。
并且,TLM使用面向对象的技术,比方继承、实现与接口别离的技术。
UVM实战指南Callback——最简单的callback2021-01-21 22:06:01| 分类:SystemVerilog|字号订阅在RVM、VMM、OVM/UVM中,常常提到callback这个概念。
指在事先设置好的地方留下一个接口,通过向这个接口添加一些函数对象,来到达不改变代码结构而动态修改代码行为。
下面用systemverilog来举一个简单的callback 例子:1 class callback;23 virtual task cb_pre_run();4 $display("base callback run");5 endtask:cb_pre_run67 endclass:callback89 class widget;1011 callback cb_queue[$];1213 function void add_cb(callback cb);14 cb_queue.push_back(cb);15 endfunction:add_cb1617 task run();18 // add callback here19 foreach(cb_queue[i])begin20 cb_queue[i].cb_pre_run();21 end22 $display("widget run....");23 endtask:run24 endclass:widget2526 module top;2728 class ext_callback extends callback;29 task cb_pre_run();30 $display("ext callback run");31 endtask:cb_pre_run32 endclass:ext_callback33 widget w;34 callback cb0;35 ext_callback cb_ext;363738 initial begin39 w =new;40 cb0 =new;41 cb_ext =new;42 w.run;43 w.add_cb(cb0);44 $display("=========== After Add base Callback");45 w.run;46 w.add_cb(cb_ext);47 $display("=========== After Add extention Callback");48 w.run;49 end5051 endmodule;// top在sysverilog中,没有函数指针的概念,因此必须将函数包装成为一个对象,就是上面例子中的callback class. 而为了在widget的对象中使用这个函数对象,必须事先在设计好的调用点对callback对象中的函数进行逐个调用〔代码19-21行〕。
摘要摘要数字芯片项目前期实现的代码质量主要由功能验证进行保证。
完备的功能验证可以确保设计文档的功能描述与具体实现代码之间的一致性。
因而,功能验证的焦点体现在尽早地发现代码漏洞,节约项目开发成本。
UVM作为功能验证过程中所用到的一种技术,可以高效地实现完备性验证。
本文通过对验证平台的设计与分析,实现了可重用的验证环境,该环境在提高验证效率及验证完备性方面具备优势。
首先,通过与纯硬件描述语言及面向对象编程语言的对比,分析了SystemVeriolog 语言在数字芯片功能验证方面的特性。
SystemVeriolog选择性地继承了硬件与软件两方面语言优势;然后分析UVM基本类库以及基于该类库实现的验证组件,运用组件模型可以快速完成验证平台的构建工作;UVM特有的层次化平台架构及完善的运行机制使得验证人员从繁杂的验证平台构建工作中释放出来,较多地关注于验证功能点的实现。
其次,对验证对象跟踪调试模块进行说明。
通过对比传统的JTAG芯片调试方式,本文的验证对象跟踪调试模块不但继承JTAG已有功能,而且提供系统内核模块实时调试能力及针对多数据源的高带宽系统跟踪能力。
跟踪调试模块便于测试工程师在芯片流片完成后对芯片生产质量进行评估,找到导致芯片出现缺陷的根源问题。
同样也便于软件工程师运用该模块进行软件调试,检测内部模块运行情况。
该跟踪调试系统同ARM公司的Coresight跟踪调试架构相比,在芯片面积、功耗及针对特殊模块的灵活设计方面有一定的优势。
再次根据验证对象按优先级次序提取验证功能点。
针对功能点划分不同功能点所应采用的验证方式及层次。
编写UVM验证组件,运用复用性思想完成平台组件的构建。
采用分层次模块化的方式完成测试序列库的构建。
通过仿真调试的多次迭代及结果分析,针对不同验证阶段采用对应验证策略,不断提高功能及代码覆盖率,最终达到验证的完备性。
最后对各功能点所采用的验证方法及仿真结果进行分析。
结合构建的跟踪调试模块验证平台及代码覆盖率和功能覆盖率100%的指标要求,得出UVM随机测试相较与直接测试在验证效率、复用性及完备性方面具有显著优势。
UVM Lab Guide自学笔记——快速入门UVMfrom Monchy(蒙奇)在2020年秋招前根据Synopsys的SystemVerilog Verification UVM1.1Lab Guide自学UVM验证,在此分享前两章详细的学习笔记,几乎是指南的中文翻译,大量的过程截图对初学者很友好。
(UVM Lab Guide是Synopsys给出的UVM官方入门指南,里面包涵源码和实验指导,可以在网上自行下载。
建议参考《UVM实战》(张强))1UVM Environment1学习目标创建一个简单的UVM测试环境嵌入报告消息编译测试环境运行仿真并观察结果将数据、sequencer和驱动程序类添加到环境编译并仿真环境以观察行为2实验准备UVM由一组编码准则以及一组基类和宏组成。
这组基类和宏可帮助你开发外观和感觉上一致的测试平台。
这套编码准则使您能够开发鲁棒且高度可重复使用的测试平台组件,从而减少了修改、维护验证基础架构的时间,并花费更多时间验证您的设计。
第一个实验将按照UVM编码准则,使用UVM基类和宏开始构建UVM验证环境的过程:UVM lab文件夹有3个目录:labs(实验文件夹,里面的程序待补充)、solutions(lab的参考代码)和rtl(被测试的rtl代码)。
3搭建UVM测试平台任务1.创建简单的UVM 测试文件test_collection.svSolution:`ifndef TEST_COLLECTION_SV `define TEST_COLLECTION_SV `include "router_env.sv"class test_base extends uvm_test;`uvm_component_utils(test_base)router_env env;function new(string name,uvm_component parent);super.new(name,parent);`uvm_info("TRACE",$sformatf("%m"),UVM_HIGH);endfunction:newvirtual function void build_phase(uvm_phase phase);super.build_phase(phase);`uvm_info("TRACE",$sformatf("%m"),UVM_HIGH);env =router_env::type_id::create("env",this);endfunction:build_phasevirtual function void start_of_simulation_phase(uvm_phase phase);super.start_of_simulation_phase(phase);`uvm_info("TRACE",$sformatf("%m"),UVM_HIGH);//Note:If you want to see the topology as a tree format try://uvm_top.print_topology(uvm_default_tree_printer);uvm_top.print_topology();factory.print();endfunction:start_of_simulation_phase endclass:test_base`endiftest.sv Solution:program automatic test;import uvm_pkg::*;`include "test_collection.sv"initial begin$timeformat(-9,1,"ns",10);run_test();end endprogram编译并仿真简单的UVM 测试平台:$vcs -sverilog -ntb_opts uvm-1.1test.sv 编译开关-ntb_opts 用于使能UVM$simv +UVM_TESTNAME=test_base 可以通过factory configuration 修改测试。
UVM:下一代验证方法学Mark Glasser,方法学建构师2011年2月4日UVM是验证业界为自身研发的一种新验证方法学。
UVM代表着验证技术的最新进展,使用它可创建坚实、可重用、具互操作性的验证IP和测试流程(testbench)组件。
UVM最新奇、最令人兴奋的方面之一却是它是如何被开发的。
UVM不是由一家EDA供应商开发的,也并非作为营销活动的一部分而推出,它是由众多业内专家联合开发的,他们来自微处理器公司、网络公司、验证顾问机构以及EDA供应商。
UVM的全部开发工作是在Accellera(一个标准化组织,致力于开发电子设计自动化领域里的标准和开放接口)架构下完成的。
在一个标准组织的旗帜下,各家公司(其中一些是市场上的对手)才能够在协作的环境中携起手来,以迎战建构一个先进验证方法学所面临的技术挑战。
每位代表为这一协同努力都贡献了他们所在行业的专业知识和视角。
其结果是为建构验证环境贡献出一个强大、多维的软件层和方法学。
当然,UVM已经在主要EDA供应商的所有模拟器上都进行了测试。
UVM的确是种真正的行业创举,Mentor以亲历其中而自豪。
UVM并非从天而降。
它集许多独立验证方法学的成果之大成。
其承继的资产包括AVM、URM,VMM和OVM。
图1. UVM的继承UVM承继的这些方法学提供了UVM得以建立其上的丰富的方法学库。
最值得注意的是,OVM-2.1.1是UVM的“起点”,是UVM得以孕育成功的种子代码库。
因此,UVM与OVM最相近,且大体上向后兼容OVM。
作为VMM一部分的RAL 包被转化为UVM的寄存器功能。
虽然上面提到的一系列方法学是UVM得以成就的种子,但UVM并非其前辈代码的简单叠加。
UVM为测试流程(testbench)建构提供了新功能和新的使用模式,从而将验证方法学提升到一个新高度。
寄存器在现代SoC设计中,寄存器集合是作为设计的接口。
通过寄存器——器件得以复位和配置;数据得以接收和发送。
《UVM实战》代码⽰例⾸先是top_tb:`timescale 1ns/1ps`include "uvm_macros.svh"import uvm_pkg::*;`include "my_if.sv"`include "my_transaction.sv"`include "my_sequencer.sv"`include "my_driver.sv"`include "my_monitor.sv"`include "my_agent.sv"`include "my_model.sv"`include "my_scoreboard.sv"`include "my_env.sv"`include "base_test.sv"`include "my_case0.sv"`include "my_case1.sv"module top_tb;reg clk;reg rst_n;reg[7:0] rxd;reg rx_dv;wire[7:0] txd;wire tx_en;my_if input_if(clk, rst_n);my_if output_if(clk, rst_n);dut my_dut(.clk(clk),.rst_n(rst_n),.rxd(input_if.data),.rx_dv(input_if.valid),.txd(output_if.data),.tx_en(output_if.valid));initial beginclk = 0;forever begin#100 clk = ~clk;endendinitial beginrst_n = 1'b0;#1000;rst_n = 1'b1;endinitial beginrun_test();endinitial beginuvm_config_db#(virtual my_if)::set(null, "uvm_test_top.env.i_agt.drv", "vif", input_if);uvm_config_db#(virtual my_if)::set(null, "uvm_test_top.env.i_agt.mon", "vif", input_if);uvm_config_db#(virtual my_if)::set(null, "uvm_test_top.env.o_agt.mon", "vif", output_if);endendmodule定义了时钟频率,传递了接⼝以链接TB,和⼀个run_test()。
UVM基础总结——基于《UVM实战》⽰例⼀、前⾔ ⼯作⼀直在做SoC验证,更关注模块间的连接性和匹配性,所以相⽐于擅长随机约束激励的UVM来说,定向测试的概念更容易debug。
当然前提是IP已经被充分验证。
因此觉得接触UVM的机会较少。
到现在发现即使在SoC验证中依然有它的⽤武之地。
⽐如验证可独⽴于CPU⼯作的IP、快速对系统性能进⾏评估、重⽤IP级别的验证环境,甚⾄是⼀些通⽤的VIP也有基于UVM编写的。
基于这些考量,也逐渐开始接触。
《UVM实战》是很多验证⼯程师的启蒙,本⽂借⽤书中开头的⽰例简单梳理下UVM的基本知识。
⼆、UVM基础概述 关于UVM的知识⽹络上已经铺天盖地了,下边的内容只是⾃⼰的⼀些认识和随记。
UVM其实就是基于SV语⾔写的⽤于验证的代码库和对应的验证规范。
下图是UVM验证环境的整体结构(图来源见参考⽂献1)。
图中注释介绍了每个组成部分的作⽤。
《UVM实战》书中给我留下最深刻的印象就是⽤⼦弹、弹夹和⼿枪分别类⽐transaction sequence和sequencer,这也是UVM环境灵活的重要原因之⼀。
这是激励的产⽣机制,⾄于响应的采集和响应任务会交给monitor和scoreboard。
后者中的期望数据或者参考数据的来源⽐较灵活,函数、⽂件或是reference model的响应均可。
以上是UVM的空间维度,这⼀概念也被抽象成如下的树状结构。
各个部分必然存在信息交互。
sequence和sequencer之间传递的是transaction,实际上component之间也是transaction级别的通信,叫做TLM (transaction level model)最常见的就是monitor中uvm_analysis_port通过uvm_tlm_analysis_fifo连接到reference model或scoreboard中的uvm_blocking_get_port。
uvm知识点总结UVM 架构UVM 的架构包括以下几个重要部分:1. UVM 库 (UVM Library): UVM 库是一个可复用的验证组件集合,包含了多个验证类,如uvm_component、uvm_object、uvm_sequence 等,这些类组成了 UVM 框架。
2. UVM Testbench: UVM Testbench 是一个验证环境框架,它是基于 UVM 库构建起来的,用于创建验证环境、生成测试用例、进行仿真等。
3. UVM Test: UVM Test 是一个测试用例,主要由 UVM sequence 和 UVM 配置对象构成,它是用来验证被测试设计的功能是否正确。
4. UVM Agent: UVM Agent 是一个验证组件,是用于连接被测试设计和验证环境的中间层;它包括了 driver、monitor、sequence、sequencer 等。
基本概念UVM 中的一些基本概念包括以下内容:1. UVM Component: UVM 组件是 UVM 测试环境中的基本单元,用于组织和管理验证环境中的各种功能。
UVM 组件包括了 uvm_component、uvm_object、uvm_sequence 等。
2. UVM Object: UVM 对象是 UVM 中的一个基本概念,它是 uvm_component、uvm_sequence 和 uvm_transaction 的基类,用于实现类似于面向对象编程的功能。
3. UVM Phase: UVM 通过阶段 (Phase) 来管理验证环境的初始化、运行和结束等过程。
UVM 提供了一系列的任务来进行阶段的管理,如 uvm_phase、uvm_sequence、uvm_objection 等。
4. UVM Transaction: UVM 事务是指在验证中进行的交互过程,包括了数据传输、信号传递、命令执行等;UVM 提供了 uvm_transaction 类来实现事务级建模。
uvm system函数UVM (Universal Verification Methodology) System Functions: Understanding the Core Elements of UVM Verification [UVM系统函数:理解UVM验证的核心元素]Introduction:UVM (Universal Verification Methodology) has become the backbone of modern verification methodologies in the semiconductor industry. It provides a standardized and scalable way of verifying complex digital designs. The core elements of UVM, known as system functions, play a crucial role in achieving effective and efficient verification. In this article, we will dive into the details of UVM system functions, discussing their purpose, usage, and how they contribute to successful verification.Chapter 1: Setting the Foundation with UVM BasicsBefore we delve into system functions, it's essential to establish a basic understanding of UVM. UVM is an open-source framework based on the SystemVerilog language. It follows the principles of object-oriented programming, promoting reusability and modularity. UVM encourages the use of predefined base classes and provides a clear hierarchy for verification components.Chapter 2: Introducing UVM System FunctionsSystem functions are predefined functions provided by UVM that accomplish specific tasks during the verification process. These functions are categorized into different groups according to their functionality. Some of the commonly used groups of system functions are the build phase, connect phase, main phase, etc.Chapter 3: The Build Phase System FunctionsThe build phase is responsible for constructing the verification environment and creating the test objects. The build phase system functions initialize the components and establish connections between them. Some key build phase system functions include`uvm_component_utils`, `uvm_component`, `uvm_object`, and`uvm_factory`.Chapter 4: The Connect Phase System FunctionsThe connect phase is focused on configuring the testbench and connecting the DUT (Device Under Test) to the testbench. System functions such as `uvm_connect`, `uvm_config_db`, and`uvm_config_object` facilitate the connectivity between the testbench components and the DUT.Chapter 5: The Main Phase System FunctionsThe main phase involves the actual execution of the verification sequence and the generation of stimulus for the DUT. Here, the main phase system functions, such as `uvm_do`, `uvm_send`, and `uvm_get`, are crucial for controlling the sequence execution and applying the appropriate stimuli to the DUT.Chapter 6: Reflection on the System FunctionsUVM system functions provide high-level abstraction to the verification process, allowing engineers to focus on higher-level tasks. They enhance reusability, modularity, and flexibility, thereby reducing verification effort and improving productivity. The use of system functions ensures the consistent application of UVM methodology across different projects and teams.Chapter 7: Best Practices for Using System FunctionsTo make the most out of UVM system functions, it is important to follow some best practices. Firstly, understanding the purpose and functionality of each system function is crucial for effective utilization. Secondly, adhering to coding guidelines and maintaining a consistent naming convention promotes codereadability and maintainability. Additionally, documenting the functionality of system functions within the testbench helps in knowledge transfer and code reuse.Conclusion:UVM system functions play a vital role in the successful adoption of UVM methodology for the verification of complex digital designs. They provide a standardized and scalable approach for constructing the verification environment, establishing connectivity, and driving the test sequences. Understanding the core elements of UVM and mastering the usage of system functions contribute to efficient verification, reduced time-to-market, and improved quality of semiconductor products.。