测试用例简介:
uart ip来自于openc910项目的uart源代码,本测试用例通过配置uart寄存器来实现uart的组件的发送和接收以及数据的检查,使用dsl语言抽象描述uart组件和vip_uart组件,并通过PSS的action infer feature来推断生成各种合法的配置场景。数字IC验证 - Portable Stimulus Standard(PSS) Uart IP级测试用例此测试用例在数字IC验证 - Portable Stimulus Standard(PSS) Uart IP级测试用例 的基础之上,进一步在SoC系统上对uart ip进行的测试。uart_c组件以及vip_uart_c组件可以复用Uart IP级测试用例,需要修改的部分仅仅是将apb_sv_binding_pkg部分对apb写接口xpss_scalar_write32和读接口xpss_scalar_read32的实现,SoC系统可以通过处理器核对uart寄存器进行读写,因此可以将写接口xpss_scalar_write32和读接口xpss_scalar_read32实现为IO内存读写。
#define xpss_raw_write8(addr, val) asm volatile("sb %0, 0(%1)" :: "r"(val), "r"(addr))
#define xpss_raw_write16(addr, val) asm volatile("sh %0, 0(%1)" :: "r"(val), "r"(addr))
#define xpss_raw_write32(addr, val) asm volatile("sw %0, 0(%1)" :: "r"(val), "r"(addr))
#define xpss_raw_write64(addr, val) asm volatile("sd %0, 0(%1)" :: "r"(val), "r"(addr))
#define xpss_raw_read8(addr) ({ \
xpss_uint8_t val;
asm volatile ("lb %0, 0(%1)" : "=r"(val) : "r"(addr)); \
val; \
})
#define xpss_raw_read16(addr) ({ \
xpss_uint16_t val;
asm volatile ("lh %0, 0(%1)" : "=r"(val) : "r"(addr)); \
val; \
})
#define xpss_raw_read32(addr) ({ \
xpss_uint32_t val;
asm volatile ("lw %0, 0(%1)" : "=r"(val) : "r"(addr)); \
val; \
})
#define xpss_raw_read64(addr) ({ \
xpss_uint64_t val;
asm volatile ("ld %0, 0(%1)" : "=r"(val) : "r"(addr)); \
val; \
})
#define xpss_scalar_write8(addr, val) ({ xpss_io_wmb; xpss_raw_write8(addr, val); })
#define xpss_scalar_write16(addr, val) ({ xpss_io_wmb; xpss_raw_write16(addr, val); })
#define xpss_scalar_write32(addr, val) ({ xpss_io_wmb; xpss_raw_write32(addr, val); })
#define xpss_scalar_write64(addr, val) ({ xpss_io_wmb; xpss_raw_write64(addr, val); })
#define xpss_scalar_read8(addr, val) ({ (*val) = xpss_raw_read8(addr); xpss_io_rmb(); })
#define xpss_scalar_read16(addr, val) ({ (*val) = xpss_raw_read16(addr); xpss_io_rmb(); })
#define xpss_scalar_read32(addr, val) ({ (*val) = xpss_raw_read32(addr); xpss_io_rmb(); })
#define xpss_scalar_read64(addr, val) ({ (*val) = xpss_raw_read64(addr); xpss_io_rmb(); })
将pss_top component中insts的inst[0]和inst[1]配置为riscv架构的EMBEDDED_TYPE绑定为嵌入式线程。
component pss_top {
exec init_down {
// bind threads to exectors
insts.inst[0].tag = "riscv_core0";
insts.inst[0].agent_context_type = EMBEDDED_TYPE;
insts.inst[1].tag = "riscv_core1";
insts.inst[1].agent_context_type = EMBEDDED_TYPE;
insts.inst[2].tag = "uart0";
insts.inst[2].agent_context_type = UVM_TYPE;
};
}
从Uart IP级测试用例到SoC系统级测试用例model部分就修改完成了,主要是两部分:
1. 实现IO内存写xpss_scalar_write32和读xpss_scalar_read32 HSI接口;
2. excutor线程绑定;
下面介绍如何将PSS生成的文件集成到testbench。由于是测试用例是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(...);
soc x_soc(
.i_pad_rst_b (rst_b),
.i_pad_clk (sys_clk),
...
.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工具生成测试用例,test_case.c文件编译为可执行bin/hex文件由SoC核执行,test_sv_case.c文件跟Uart IP级测试用例一样编译执行。
在vcs下的仿真结果: