Linux chisel环境配置

环境要求
CentOS7安装JDK1.8
Linux 安装sbt

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的版本、依赖的库等。
你可以合理的修改其中的版本号,来控制自动下载的chisel版本,虽然没有显式配置firrtl,但是firrtl也会同步下载。
关于以上指定的版本号,可以在这里传送门查看,对应起来就好,如下所示:

项目源代码

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

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

编译运行

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

sbt run

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

sbt test

推荐使用官方提供的模板https://gitcode.net/mirrors/freechipsproject/chisel-template?utm_source=csdn_github_accelerator,直接修改其中的源代码文件即可。

参考

http://t.csdn.cn/pbCei

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AlwaysDayOne

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值