TLM2模型测试

unit test并不是发现现有代码的bug,而是进行功能测试,即测试现有代码是否完成期望的功能。而代码的bug,更像是安全性测试,不属于unit test范畴。
unit test 要求:
必须毫秒级的运行。
能独立运行。
不能依赖外部输入。

我们回顾c++, python的unit test,我们会发现,所有unit test遵循以下结构:
assume(arrange):提供激励。
act:激励施加到dut上。
assert:检查dut的输出。

testfixture: 事先定义的common code,例如:
class SystemCFixture : public testing::Test {
protected:
void SetUp() override; // Build the top level and start simulation.
void TearDown() override; // Restart the simulator at the end.
virtual void BuildTestbenchTop() = 0; // Construct and bind modules
static void AdvanceSimulationTime(const sc_time& timeOffset = sc_max_time());
private:
static void RestartSim();
};

最后说一下mock,stub,fake的区别。
mock是代替外部接口。
stub产生预定义的输出。
fake是接近可以工作的实现。

比较好的介绍Googletest framework:
https://www.youtube.com/watch?v=x5_UxQ9wrH4&list=PL_dsdStdDXbo-zApdWB5XiF2aWpsqzV55&index=2

该链接给出用google test框架来测试TLM2 模型。
https://github.com/cphurley82/tlm2-gtestbench

synopsys有TLM creator工具帮助测试LT model,使用的是c++unittest框架。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值