0
点赞
收藏
分享

微信扫一扫

Linux chisel环境配置

小北的爹 2022-03-20 阅读 86
chiselscala

Chisel项目和Java这种类似,一般是有标准的目录结构的,对于Chisel而言,使用Scala项目构建工具sbt会很方便,所以环境要求中需要sbt工具。

chisel的环境配置并不需要安装其他东西了,只需要配置sbt的项目管理依赖文件即可。

这里我们以一个例子来讲解。

例子下载与测试

首先下载此github仓库,进入hello-world项目文件夹下,并测试sbt工具正常

git clone https://github.com/schoeberl/chisel-examples.git
cd chisel-examples/hello-world
make  # 实际执行sbt run 下载安装依赖与执行
sbt test # 执行测试文件

然后可以看到如下输出

[info] welcome to sbt 1.6.2 (Oracle Corporation Java 1.8.0_281)
[info] loading project definition from /root/workspace/chisel_leaning/chisel-examples/hello-world/project
[info] loading settings for project hello-world from build.sbt ...
[info] set current project to hello-world (in build file:/root/workspace/chisel_leaning/chisel-examples/hello-world/)
Start the blinking LED
o

End the blinking LED
[info] HelloTest:
[info] Hello
[info] - should pass
[info] Run completed in 21 seconds, 427 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 23 s, completed Mar 20, 2022 5:57:01 PM

Chisel项目文件目录结构

使用sbt需要在项目文件夹下应有一个build.sbt文件,这个文件长这样(这样在执行sbt run的时候就会下载安装相应的依赖,比如这里会安装Chisel 3.5):

scalaVersion := "2.12.13"

scalacOptions ++= Seq(
  "-feature",
  "-language:reflectiveCalls",
)

resolvers ++= Seq(
  Resolver.sonatypeRepo("releases")
)

// Chisel 3.5
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "3.5.0" cross CrossVersion.full)
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.5.0"
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.5.0"

这个文件会指定很多信息,比如Scala的版本、依赖的库等。

项目源代码

源代码一般放在src/main/scala/路径和src/test/scala,分别用于存放主程序和测试用代码。

.
├── main
│   └── scala
│       └── Hello.scala
└── test
    └── scala
        └── HelloTest.scala

编译运行

在此项目/hello-world/路径下执行即可编译运行Hello.scala

sbt run

执行以下命名可以编译运行测试文件HelloTest.scala

sbt test

参考

举报

相关推荐

Linux环境配置

【Linux】Linux环境配置安装

Linux并发环境配置

linux环境配置qt

配置Linux网络环境

0 条评论