1.安装Java

官方下载地址:https://www.oracle.com/cn/java/technologies/javase/downloads/#java8

2.安装sbt

官方下载地址:https://www.scala-sbt.org/download.html
1

下载后解压缩,将sbt文件夹放到想要安装的位置
或者直接下载.msi文件后安装

然后配置环境变量:将sbt文件夹下的bin添加到环境变量中的Path中
2

然后打开sbt文件夹
3

/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)插件,实现语法高亮
4

接下来我们写一个程序试验一下:

建立一个文件夹在vscode中打开
在终端中打开cmd,输入sbt,显示没有找到build.sbt,输入c以继续,则会自动生成一些目录
5
第一次运行sbt时会比较慢

新建文件hello.scala,在里面输入如下内容:

object HelloWorld {
   def main(args: Array[String]) = println("Hello, world!")
}

在cmd中输入compile进行编译,成功
再输入run运行,成功输出"Hello World"
6

3.配置chisel

在https://github.com/schoeberl/chisel-empty 上克隆一个叫chisel-empty的文件夹
在建一个chisel项目时,把该文件夹下的build.sbtscr拷贝到你的项目的文件夹下

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

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/xusiqi/p/16366771.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!

相关课程

3671 9.8元 98元 1折
3722 9.8元 98元 1折