当前位置:网站首页>UVM learning - build a simple UVM verification platform
UVM learning - build a simple UVM verification platform
2022-07-02 10:41:00 【weixin_ forty-five million seven hundred and four thousand five】
Build a simple one UVM Verification platform
The verification platform built this time does not include DUT.
establish transaction and sequence
transaction The code is as follows :
class my_transaction extends uvm_sequence_item;
rand bit [4:0] sa;
rand bit [3:0] da;
rand reg [7:0] payload[$]; // Define data members
`uvm_object_utils_begin(my_transaction)
`uvm_field_int(sa, UVM_ALL_ON);
`uvm_field_int(da, UVM_ALL_ON);
`uvm_field_queue_int(payload, UVM_ALL_ON);
`uvm_object_utils_end
// constraint
constraint Limit{
sa inside {
[0:15] };
da inside {
[0:15] };
payload.size() inside {
[2:4] };
}
function new(string name = "my_transaction");
super.new(name);
endfunction
endclass
sequence The code is as follows :
class my_sequence extends uvm_sequence #(my_transaction);
`uvm_object_utils(my_sequence)
function new(string name = "my_sequence");
super.new(name);
endfunction
virtual task body();
if(starting_phase != null)
starting_phase.raise_objection(this);
repeat(10) begin
`uvm_do(req);
end
#100;
if(starting_phase != null)
starting_phase.drop_objection(this);
endtask
endclass
establish sequencer and driver
sequencer The code for is as follows :
typedef uvm_sequencer #(my_transaction) my_sequencer;
driver The code for is as follows :
class my_driver extends uvm_driver #(my_transaction);
`uvm_component_utils(my_driver)
function new(string name = "my_driver", uvm_component parent);
super.new(name, parent);
endfunction
virtual task run_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
`uvm_info("DRV_RUN_PHASE", req.sprint(), UVM_MEDIUM)
#100;
seq_item_port.item_done();
end
endtask
endclass
seq_item_port by uvm_driver Class built-in interface , Used with sequencer Of TLM signal communication , Namely the transaction Transferred to the driver.
establish monitor
class my_monitor extends uvm_monitor;
`uvm_component_utils(my_monitor);
function new(string name = "", uvm_component parent);
super.new(name, parent);
endfunction
virtual task run_phase(uvm_phase phase);
forever begin
`uvm_info("MON_RUN_PHASE", "Monitor run!", UVM_MEDIUM);
#100;
end
endtask
endclass
establish agent
class master_agent extends uvm_agent;
`uvm_component_utils(master_agent)
my_sequencer m_seqr;
my_driver m_driv;
my_monitor m_moni;
function new(string name = "", uvm_component parent);
super.new(name, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(is_active == UVM_ACTIVE) begin
m_seqr = my_sequencer::type_id::create("m_seqr", this);
m_driv = my_driver::type_id::create("m_driv", this);
end
m_moni = my_monitor::type_id::create("m_moni", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
if(is_active == UVM_ACTIVE)
m_driv.seq_item_port.connect(m_seqr.seq_item_export);
endfunction
endclass
m_driv.seq_item_port.connect(m_seqr.seq_item_export);
Realization driver and sequencer Connection of communication port .
establish envirenment and testcase
establish envirenment:
class my_env extends uvm_env;
`uvm_component_utils(my_env)
master_agent m_agent;
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_agent = master_agent::type_id::create("m_agent", this);
endfunction
endclass
m_agent = master_agent::type_id::create(“m_agent”, this);
adopt uvm Of factory Mechanism instantiation object .
testcase The code is as follows :
class my_test extends uvm_test;
`uvm_component_utils(my_test)
my_env m_env;
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_env = my_env::type_id::create("m_env", this);
uvm_config_db#(uvm_object_wrapper)::set(
this, "*.m_seqr.run_phase",
"default_sequence", my_sequence::get_type());
endfunction
virtual function void start_of_simulation_phase(uvm_phase phase);
super.start_of_simulation_phase(phase);
uvm_top.print_topology(uvm_default_tree_printer);
endfunction
endclass
top floor
program automatic test;
import uvm_pkg::*;
`include "uvm_macros.svh"
`include "my_transaction.sv"
`include "my_sequence.sv"
`include "my_sequencer.sv"
`include "my_driver.sv"
`include "my_monitor.sv"
`include "master_agent.sv"
`include "my_env.sv"
`include "my_test.sv"
initial begin
run_test("my_test");
end
endprogram
Simulation
Makefile as follows :
SEED = 1
default: test
test: compile run
run:
./simv -l simv.log +ntb_ramdom_seed=$(SEED)
compile:
vcs -l vcs.log -sverilog -debug_all -full64 -ntb_opts uvm-1.1 -timescale=1ns/100ps test.sv
clean:
rm -rf simv* csrc* *.tmp *.vpd *.key *.log *hdrs.h
Come to the simulation directory , Input make Start compilation and simulation , You can see the printed test platform hierarchy as follows :
边栏推荐
- [visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened
- Transport Optimization abstraction
- 4.随机变量
- 2021-10-04
- Feature (5): how to organize information
- ERROR 1118 (42000): Row size too large (> 8126)
- flume 190 INSTALL
- LeetCode+ 76 - 80 暴搜专题
- Determine whether there are duplicate elements in the array
- 网络通信学习
猜你喜欢
随机推荐
01安装虚拟机
Merge ordered sequence
pytest--之测试报告allure配置
14.信号量的代码实现
SAP Spartacus express checkout design
Flutter环境配置保姆级教程,让doctor一绿到底
KS009基于SSH实现宠物管理系统
Sum the two numbers to find the target value
[tutorial] how to make the Helpviewer help document of VisualStudio run independently
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
Nonlinear optimization: steepest descent method, Newton method, Gauss Newton method, Levenberg Marquardt method
SUS系统可用性量表
pytest学习--base
13. Semaphore critical zone protection
Stm32 et développement de moteurs (système supérieur)
Blender camera surround motion, animation rendering, video synthesis
Mongodb quickly get started with some simple operations of mongodb command line
SPSS做Shapiro-Wilk正态分析
[jetbrain rider] an exception occurred in the construction project: the imported project "d:\visualstudio2017\ide\msbuild\15.0\bin\roslyn\microsoft.csh" was not found
大华设备播放过程中设置播放速度