当前位置:网站首页>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 .
边栏推荐
- BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
- 基于PaddleX的智能零售柜商品识别
- Worried about "cutting off gas", Germany is revising the energy security law
- 舔狗舔到最后一无所有(状态机)
- Summary of recent days (non-technical article)
- Ws2811 m is a special circuit for three channel LED drive and control, and the development of color light strip scheme
- Source code compilation and installation of MySQL
- Introduction to reverse debugging PE structure resource table 07/07
- 德明利深交所上市:市值31亿 为李虎与田华夫妻档
- Programmer anxiety
猜你喜欢
随机推荐
逆向调试入门-PE结构-资源表07/07
Service Mesh的基本模式
30:第三章:开发通行证服务:13:开发【更改/完善用户信息,接口】;(使用***BO类承接参数,并使用了参数校验)
C language staff management system
Go 语言入门很简单:Go 实现凯撒密码
FS7867S是一款应用于数字系统供电电源电压监控的电压检测芯片
2022 Shandong Province safety officer C certificate examination question bank and online simulation examination
Node の MongoDB安装
markdown 语法之字体标红
Read excel table data
Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?
Fs4056 800mA charging IC domestic fast charging power IC
Qt如何实现打包,实现EXE分享
392. Judgement subsequence
Unittest中的TestSuite和TestRunner
字节面试算法题
IP 实验室月复盘 · 第 5 期
硬件基础知识-二极管基础
安装trinity、解决报错
[antd] how to set antd in form There is input in item Get input when gourp Value of each input of gourp