1.安装Java
官方下载地址:https://www.oracle.com/cn/java/technologies/javase/downloads/#java8
2.安装sbt
官方下载地址:https://www.scala-sbt.org/download.html
下载后解压缩,将sbt文件夹放到想要安装的位置
或者直接下载.msi文件后安装
然后配置环境变量:将sbt文件夹下的bin添加到环境变量中的Path中
然后打开sbt文件夹
在/sbt/conf
文件夹下创建repo.properties
文件,里面加入如下内容:(设置从镜像下载依赖,这里选择的是阿里云的镜像)
[repositories]
local
aliyun: https://maven.aliyun.com/nexus/content/groups/public
在sbtconfig.txt
中增加如下内容:
-Dsbt.override.build.repos=true
-Dsbt.repository.config=D:sbtconfrepo.properties
-Dsbt.ivy.home=D:sbt.ivy
-Dsbt.log.format=true
-Dsbt.boot.directory=D:sbtboot
-Dsbt.global.base=D:sbt.sbt
注:等号和地址之间不能加空格
在vscode中下载Scala Syntax(official)
插件,实现语法高亮
接下来我们写一个程序试验一下:
建立一个文件夹在vscode中打开
在终端中打开cmd
,输入sbt
,显示没有找到build.sbt,输入c以继续,则会自动生成一些目录
第一次运行sbt时会比较慢
新建文件hello.scala
,在里面输入如下内容:
object HelloWorld {
def main(args: Array[String]) = println("Hello, world!")
}
在cmd中输入compile
进行编译,成功
再输入run
运行,成功输出"Hello World"
3.配置chisel
在https://github.com/schoeberl/chisel-empty 上克隆一个叫chisel-empty
的文件夹
在建一个chisel项目时,把该文件夹下的build.sbt
和scr
拷贝到你的项目的文件夹下
在scrmainscala
下存放自定义的工程文件,在scrtestscala
下放测试代码。chisel-empty
中自带有一个加法器
文件夹下打开cmd,输入sbt run
出现如下信息,chisel可以正常运行,在generated
文件夹下可以看到生成的verilog文件
E:codeschiseltest>sbt run
[info] Updated file E:codeschiseltestprojectbuild.properties: set sbt.version to 1.6.2
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 18.0.1.1)
[info] loading project definition from E:codeschiseltestproject
[info] loading settings for project chiseltest from build.sbt ...
[info] set current project to chiseltest (in build file:/E:/codes/chiseltest/)
[info] compiling 1 Scala source to E:codeschiseltesttargetscala-2.12classes ...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.13. Compiling...
[info] Compilation completed in 5.826s.
[info] running empty.AddMain
Generating the adder hardware
[success] Total time: 24 s, completed 2022骞?鏈?1鏃?涓嬪崍9:48:36
[0J
输入sbt test
,运行测试程序,结果如下
E:codeschiseltest>sbt test
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 18.0.1.1)
[info] loading project definition from E:codeschiseltestproject
[info] loading settings for project chiseltest from build.sbt ...
[info] set current project to chiseltest (in build file:/E:/codes/chiseltest/)
[info] compiling 1 Scala source to E:codeschiseltesttargetscala-2.12test-classes ..
[info] AddTester:
[info] Add
[info] - should work
[info] Run completed in 2 seconds, 264 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: 6 s, completed 2022骞?鏈?1鏃?涓嬪崍9:51:01
[0J
参考:
https://blog.csdn.net/a18792721831/article/details/122904465
https://blog.csdn.net/a18792721831/article/details/122871070
https://www.cnblogs.com/lenmom/p/10364078.html
https://blog.csdn.net/qq_34291505/article/details/87365907
文章来源: 博客园
- 还没有人评论,欢迎说说您的想法!