当前位置:网站首页>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 .
边栏推荐
- Redis —— How To Install Redis And Configuration(如何快速在 Ubuntu18.04 与 CentOS7.6 Linux 系统上安装 Redis)
- 如何在 2022 年为 Web 应用程序选择技术堆栈
- 担心“断气” 德国正修改《能源安全法》
- FS4059C是5V输入升压充电12.6V1.2A给三节锂电池充电芯片 输入小电流不会拉死,温度60°建议1000-1100MA
- 自主工业软件的创新与发展
- 国内酒店交易DDD应用与实践——代码篇
- 2022kdd pre lecture | 11 first-class scholars take you to unlock excellent papers in advance
- markdown 语法之字体标红
- 2022年起重机械指挥考试模拟100题模拟考试平台操作
- How to choose a technology stack for web applications in 2022
猜你喜欢
ViewBinding和DataBinding的理解和区别
自主工业软件的创新与发展
吃透Chisel语言.09.Chisel项目构建、运行和测试(一)——用sbt构建Chisel项目并运行
Go 语言入门很简单:Go 实现凯撒密码
JVM memory layout detailed, illustrated, well written!
Unity Shader学习(三)试着绘制一个圆
英视睿达冲刺科创板:年营收4.5亿 拟募资9.79亿
OPPO Find N2产品形态首曝:补齐各项短板
华昊中天冲刺科创板:年亏2.8亿拟募资15亿 贝达药业是股东
CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...
随机推荐
IDEA快捷键大全
2022g3 boiler water treatment examination question simulation examination question bank and simulation examination
FS4059C是5V输入升压充电12.6V1.2A给三节锂电池充电芯片 输入小电流不会拉死,温度60°建议1000-1100MA
golang fmt.printf()(转)
1200. 最小绝对差
奇妙秘境 码蹄集
【C 题集】of Ⅶ
C language programming topic reference
ViewBinding和DataBinding的理解和区别
美国土安全部部长警告移民“不要踏上危险的旅程”
MySQL5免安装修改
CVPR 2022 | greatly reduce the manual annotation required for zero sample learning, and propose category semantic embedding rich in visual information (source code download)
Use the default route as the route to the Internet
Gorm 读写分离(转)
OPPO Find N2产品形态首曝:补齐各项短板
WS2818M是CPC8封装,是三通道LED驱动控制专用电路外置IC全彩双信号5V32灯可编程led灯带户外工程
【Antd】Antd 如何在 Form.Item 中有 Input.Gourp 时获取 Input.Gourp 的每一个 Input 的value
BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
Go 语言入门很简单:Go 实现凯撒密码
Haobo medical sprint technology innovation board: annual revenue of 260million Yonggang and Shen Zhiqun are the actual controllers