测试用例简介:
uart ip来自于openc910项目的uart源代码,本测试用例通过配置uart寄存器来实现uart的组件的发送和接收以及数据的检查,使用dsl语言抽象描述uart组件和vip_uart组件,并通过PSS的action infer feature来推断生成各种合法的配置场景。 此测试用例在数字IC验证 - Portable Stimulus Standard(PSS) Uart IP级测试用例的基础之上,进一步在子系统上对uart ip进行的测试。uart_c组件以及vip_uart_c组件可以复用Uart IP级测试用例,需要修改的部分仅仅是将apb_sv_binding_pkg部分对apb写接口xpss_scalar_write32和读接口xpss_scalar_read32的实现,替换成axi_sv_binding_pkg部分对axi写接口xpss_scalar_write32和读接口xpss_scalar_read32的实现,vip_uart_sv_binding_pkg.pss无需修改。
task automatic axi_write8(input axi_master_agent master, longint unsigned addr, input byte unsigned data);
axi_write_byte_sequence byte_seq;
byte_seq = axi_write_byte_sequence::type_id::create("byte_seq");
byte_seq.addr = addr[39:0];
byte_seq.data = data[7:0];
byte_seq.start(master.sequencer);
endtask;
task automatic axi_write16(input axi_master_agent master, longint unsigned addr, input shortint unsigned data);
axi_write_hword_sequence hword_seq;
hword_seq = axi_write_hword_sequence::type_id::create("hword_seq");
hword_seq.addr = addr[39:0];
hword_seq.data = data[15:0];
hword_seq.start(master.sequencer);
endtask;
task automatic axi_write32(input axi_master_agent master, longint unsigned addr, input int unsigned data);
axi_write_word_sequence word_seq;
word_seq = axi_write_wrod_sequence::type_id::create("word_seq");
word_seq.addr = addr[39:0];
word_seq.data = data[31:0];
word_seq.start(master.sequencer);
endtask;
task automatic axi_write64(input axi_master_agent master, longint unsigned addr, input longint unsigned data);
axi_dwrite_word_sequence word_seq;
dword_seq = axi_write_dwrod_sequence::type_id::create("dword_seq");
dword_seq.addr = addr[39:0];
dword_seq.data = data[63:0];
dword_seq.start(master.sequencer);
endtask;
task automatic axi_read8(input axi_master_agent master, longint unsigned addr, output byte unsigned data);
axi_read_byte_sequence byte_seq;
byte_seq = axi_read_byte_sequence::type_id::create("byte_seq");
byte_seq.addr = addr[39:0];
byte_seq.start(master.sequencer);
data = byte_seq.data[7:0];
endtask;
task automatic axi_read16(input axi_master_agent master, longint unsigned addr, output shortint unsigned data);
axi_read_hword_sequence hword_seq;
hword_seq = axi_read_hword_sequence::type_id::create("hword_seq");
hword_seq.addr = addr[39:0];
hword_seq.start(master.sequencer);
data = hword_seq.data[15:0];
endtask;
task automatic axi_read32(input axi_master_agent master, longint unsigned addr, output int unsigned data);
axi_read_word_sequence hword_seq;
word_seq = axi_read_word_sequence::type_id::create("word_seq");
word_seq.addr = addr[39:0];
word_seq.start(master.sequencer);
data = word_seq.data[31:0];
endtask;
task automatic axi_read64(input axi_master_agent master, longint unsigned addr, output longint unsigned data);
axi_read_dword_sequence dword_seq;
dword_seq = axi_read_dword_sequence::type_id::create("dword_seq");
dword_seq.addr = addr[39:0];
dword_seq.start(master.sequencer);
data = dword_seq.data[63:0];
endtask;
export "DPI-C" task xpss_scalar_write8;
task xpss_scalar_write8(input longint unsigned addr, input byte unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
axi_write8(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_write16;
task xpss_scalar_write16(input longint unsigned addr, input shortint unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
axi_write16(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_write32;
task xpss_scalar_write32(input longint unsigned addr, input int unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
axi_write32(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_write64;
task xpss_scalar_write64(input longint unsigned addr, input longint unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
axi_write64(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_read8;
task xpss_scalar_read8(input longint unsigned addr, output byte unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
apb_read8(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_read16;
task xpss_scalar_read16(input longint unsigned addr, output shortint unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
apb_read16(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_read32;
task xpss_scalar_read32(input longint unsigned addr, output int unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
axi_write32(master, addr, data);
endtask;
export "DPI-C" task xpss_scalar_read64;
task xpss_scalar_read64(input longint unsigned addr, output longint unsigned data);
static string axi_master = {"*.", inst_name, ".master"};
axi_master_agent master;
master = find_axi_master_agent(axi_master);
axi_write64(master, addr, data);
endtask;
将pss_top component中insts.inst[0].tag的"apb0"修改成"axi0_agent",根据这个字符串匹配查找axi agent,将axi agent绑定到线程0执行。
component pss_top {
exec init_down {
// bind threads to exectors
insts.inst[0].tag = "axi0_agent";
insts.inst[0].agent_context_type = UVM_TYPE;
};
};
从Uart IP级测试用例到子系统级测试用例model部分就修改完成了,主要是两部分:
1. 实现AXI写接口xpss_scalar_write32和读接口xpss_scalar_read32;
2. 实现AXI agent与excutor线程绑定;
下面介绍如何将PSS生成的文件集成到testbench。由于是测试用例是子系统测试用例,因此我们把openc910的核部分代码给去掉,连接AXI信号到module soc,如下图所示。
1. 在module tb_top中例化module lib_entry_top;
2. 在pss_sequence_test类的run_phase,启动C main同步;
module tb_top;
......
// instance pss entry module
lib_entry_top entry_top();
// instance uart interface and apb interface
uart_if uart_if_0(...);
axi_if apb_if[2](...);
soc x_soc(
.i_pad_rst_b (rst_b),
.i_pad_clk (sys_clk),
...
// axi signals
.pad_biu_core0_arready (axi_if[0].arready),
...
.biu_pad_core1_wvalid (axi_if[1].wvalid),
.i_pad_uart0_sin (uart_if_0.txd),
.o_pad_uart0_sout (uart_if_0.rxd)
);
initial begin
......
run_test();
end
......
endmodule
class pss_sequence_test extends pss_base_test;
`uvm_component_utils(pss_sequence_test);
function new(string name = "pss_sequence_test", uvm_component parent=null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
task run_phase(uvm_phase phase);
phase.raise_objection(this);
// entry the PSS C test main scenario
lib_startup_pkg::xpss_sync_entry_main();
phase.drop_objection(this);
endtask;
endclass;
使用PSS工具生成测试用例,下面是在vcs下的仿真结果: