当前位置:网站首页>Understand chisel language thoroughly 11. Chisel project construction, operation and test (III) -- scalatest of chisel test
Understand chisel language thoroughly 11. Chisel project construction, operation and test (III) -- scalatest of chisel test
2022-07-04 14:07:00 【github-3rr0r】
Chisel The project build 、 Run and test ( 3、 ... and )——Chisel Tested ScalaTest
The test in hardware design is usually called testbench, It is called test bench , It's still used in the back testbench To express .testbench Will instantiate a piece to be tested DUT(Design Under Test, Design to be tested ), Drive the input interface and observe the output interface , Compare whether the output is compound with the expectation .
Chisel Two test methods are provided in , Namely chiseltest In bag ChiselTest and iotesters In bag PeekPokeTester. however iotesters stay Chisel 3.5 The version has been deprecated at first , This series is based on Chisel 3.5 Of , So I'm not going to introduce iotesters Related content , Just introduce ChiselTest Related content .
Chisel One of its strengths is that it can take advantage of Scala Write with the powerful function of testbench. For example, we can Write the desired hardware functions in the software simulator , Then compare the hardware simulation with the software simulation . This method is very efficient in testing the implementation of processors .
In the next few articles, we will introduce Chisel Four test frameworks that may be used in , First of all, from the ScalaTest Start .
ScalaTest
ScalaTest yes Scala Test tools ,Chisel Test tools ChiselTest It's also ScalaTest Development of . therefore , Let's first learn a simple ScalaTest Example .
To use ScalaTest, The first thing you need to do is build.sbt Contains the corresponding library , We can add a sentence directly at the end :
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.4" % "test"
It can also be in Chisel-template in build.sbt Based on ( Add ):
libraryDependencies ++= Seq(
"edu.berkeley.cs" %% "chisel3" % chiselVersion,
"edu.berkeley.cs" %% "chiseltest" % "0.5.1" % "test",
"org.scalatest" %% "scalatest" % "3.1.4" % "test"
),
The test is usually done in src/test/scala Under folder , You can run the whole test with the following instructions :
sbt test
Here is a simple test , test Scala Integer addition and multiplication in :
import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class ExampleTest extends AnyFlatSpec with Matchers {
"Integers" should "add" in {
val i = 2
val j = 3
i + j should be (5)
}
"Integers" should "multiply" in {
val i = 3
val j = 4
i * j should be (12)
}
}
It looks a little complicated , When you read it carefully, you feel that it is all vernacular , In especial should and should be, It's not like writing code , But it's really easy to understand, good memory .ScalaTest It is to support such simple unit tests that read like executable specifications . The above example contains two tests , The output of the test run will show the specification we give and whether the test passes , Output is as follows :

This grammar is actually very simple , Import three related packages , The rest can be painted according to the gourd , There's not much to explain .
sbt test This command will execute all tests , This is very useful in recursive testing . But if we want to run a single test or a single test suite , You can use this command :
sbt "testOnly ExampleTest"
here ExampleTest That is, the class of the test we run , If we accidentally misspell , Or there is no such class , Then he won't report a red error , It will only quietly output a white result :
[info] No tests to run for Test / testOnly
Conclusion
Testing is a key part of digital design , We must master .ScalaTest The relevant content is still very simple , For the next article ChiselTest It's the play . This article mentioned ChiselTest In fact, that is ScalaTest Development of , So it's not bad , There are some differences in knowledge grammar , Let's learn the next article together .
边栏推荐
- Gorm 读写分离(转)
- 392. Judgement subsequence
- 吃透Chisel语言.11.Chisel项目构建、运行和测试(三)——Chisel测试之ScalaTest
- C语言中学生成绩管理系统
- MySQL version 8 installation Free Tutorial
- Ruichengxin micro sprint technology innovation board: annual revenue of 367million, proposed to raise 1.3 billion, Datang Telecom is a shareholder
- #yyds干货盘点# 解决名企真题:连续最大和
- Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
- Interviewer: what is the internal implementation of hash data type in redis?
- C语言程序设计
猜你喜欢

如何在 2022 年为 Web 应用程序选择技术堆栈

吃透Chisel语言.06.Chisel基础(三)——寄存器和计数器

小程序直播 + 电商,想做新零售电商就用它吧!

.Net之延迟队列

Huahao Zhongtian sprint Technology Innovation Board: perte annuelle de 280 millions de RMB, projet de collecte de fonds de 1,5 milliard de Beida Pharmaceutical est actionnaire

SCM polling program framework based on linked list management

CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...

面试拆解:系统上线后Cpu使用率飙升如何排查?

源码编译安装MySQL

吃透Chisel语言.05.Chisel基础(二)——组合电路与运算符
随机推荐
基于PaddleX的智能零售柜商品识别
FS7867S是一款应用于数字系统供电电源电压监控的电压检测芯片
JVM memory layout detailed, illustrated, well written!
Flet tutorial 03 basic introduction to filledbutton (tutorial includes source code) (tutorial includes source code)
奇妙秘境 码蹄集
【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结
Unittest中的TestSuite和TestRunner
gorm 之数据插入(转)
Unittest框架之断言
php 日志调试
Qt如何实现打包,实现EXE分享
.Net之延迟队列
Fisher信息量检测对抗样本代码详解
Interview disassembly: how to check the soaring usage of CPU after the system goes online?
锐成芯微冲刺科创板:年营收3.67亿拟募资13亿 大唐电信是股东
Gorm 读写分离(转)
担心“断气” 德国正修改《能源安全法》
Distributed base theory
WS2818M是CPC8封装,是三通道LED驱动控制专用电路外置IC全彩双信号5V32灯可编程led灯带户外工程
The Secretary of Homeland Security warned immigrants "not to embark on a dangerous journey"