Chisel芯片开发入门系列 -- 2. Chisel Installation

Installation

Chisel is a Scala library and compiler plugin.

Quickstart with Scala CLI

The easiest way to use Chisel is to:

  1. First, install Scala CLI.

  2. Then, download the Chisel Scala CLI example.

  3. Finally, use Scala CLI to compile and run the example.

For Step2:

This is easiest on the command-line (works on Linux, MacOS, and Windows Subsystem for Linux (WSL)):

curl -O -L https://github.com/chipsalliance/chisel/releases/latest/download/chisel-example.scala

Alternatively you can download the example directly from this link.

For Step 3:

This is the CLI: scala-cli chisel-example.scala

The Chisel Scala CLI example is a simple, single-file example of Chisel that emits Verilog to the screen.

TIPS: While more complex projects often use a build tool like SBT or Mill as described below, we still highly recommend using Scala CLI with the example linked above for experimentation and writing small snippets to share with others.

Dependencies

As described above, Scala CLI is a great "batteries included" way to use Chisel. It will automatically download and manage all dependencies of Chisel including a Java Development Kit (JDK). More complex projects will require the user to install a JDK and a build tool.

Java Development Kit (JDK)

Scala runs on the Java Virtual Machine (JVM), so it is necessary to install a JDK to use Chisel. Chisel works on any version of Java version 8 or newer; however, we recommend using an LTS release version 17 or newer. Note that Scala CLI requires Java 17 or newer so unless your system installation of Java is at least version 17, Scala CLI will download Java 17 for its own use.

You can install any distribution of the JDK you prefer. Eclipse Adoptium Temurin is a good option with support for all platforms: Install Eclipse Temurin™ | Adoptium

Ubuntu

Note that Temurin is not part of the default apt repositories, so you will need to add the Eclipse Adoptium repository.

Taken from the official Temurin docs. Please note that installation on most systems will require superuser priviledges (sudo). You may need to prefix these commands with sudo including the tee commands following any pipes (|).

MacOS

Using MacPorts: sudo port install openjdk17-temurin

Using Homebrew: brew install temurin@17

Windows

Using Scoop: scoop install temurin17-jdk

Windows users may also prefer using an installer.

Java Versions

Different JVM versions need diffrent Scala versions. And the highest Scala version is set by the compiler plugin for a Chisel version.

current highest supported versions are:

ChiselScalaJava
3.5.62.13.1017
3.6.12.13.1422
5.3.x2.13.1422
6.6.x2.13.1623
7.0.0-RC12.13.1623

Note that brew on Mac currently installs Java 23, which is not supported by Scala 2.13.14 and lower.

Build Tools

Scala CLI is only intended for projects made up of a single to a handful of files. Larger projects need a build tool.

Mill

Mill is a modern Scala build tool with simple syntax and a better command-line experience than SBT. We recommend Chisel users use Mill.

For detailed instructions, please see the Mill documentation.

Linux and MacOS

The easiest way to use Mill is with the Mill Wrapper Script millw:

curl -L https://raw.githubusercontent.com/lefou/millw/0.4.11/millw > mill && chmod +x mill

You can then move this script to a global install location:

sudo mv mill /usr/local/bin/

Windows

Using Scoop: scoop install mill

Download millw.bathttps://raw.githubusercontent.com/lefou/millw/0.4.11/millw.bat.

SBT

SBT is the more traditional Scala build tool with many resources and examples. It is most productively used with its REPL rather than on the command line.

Linux

The easiest way to install SBT is manually from the release tarball. Note that MacOS and Windows users can also do a manual install.

curl -s -L https://github.com/sbt/sbt/releases/download/v1.9.7/sbt-1.9.7.tgz | tar xvz

Then copy the sbt bootstrap script into a global install location.

sudo mv sbt/bin/sbt /usr/local/bin/

MacOS

Using MacPorts:

sudo port install sbt

Using Homebrew:

brew install sbt
Windows

Using Scoop:

scoop install sbt

Firtool

Beginning with version 6.0, Chisel will manage the version of firtool on most systems. However, some systems (e.g. NixOS or older Linux distributions like CentOS 6) may need to build firtool from source. If you need to build firtool from source, please see the Github repository.

To override the Chisel-managed version of firtool, set environment variable CHISEL_FIRTOOL_PATH to point to the directory containing your firtool binary.

To see what version of firtool is recommended for a given version of Chisel, see Versioning. You can also query this information programmatically in Scala via chisel3.BuildInfo.firtoolVersion. For example, you can use Scala CLI to compile a tiny program on the command-line to print out this value:

scala-cli -S 2.13 -e 'println(chisel3.BuildInfo.firtoolVersion)' --dep org.chipsalliance::chisel:6.0.0

Verilog Simulation

Verilator

Verilator is a high-performance, open-source Verilog simulator. It is not a simulator in the traditional sense, but rather it works by transpiling your Verilog code to C++ which you then compile into a binary. This results in Verilator itself having additional requirements, like a C++ compiler supporting at least C++14, and Make.

Please see Verilator's install page for more detailed instructions.

Linux

Most Linux package managers include Verilator, for example:

apt install -y verilator

Note that the default version is likely to be old, especially on older Linux distributions. Users are encouraged to build Verilator from source, please see the instructions on the Verilator website.

MacOS

Using MacPorts:

sudo port install verilator

Using Homebrew:

brew install verilator

Windows

As mentioned above, Verilator is not a "single-executable" solution; it requires a C++ compiler and also uses quite a bit of Perl scripts. We recommend using the Yosys OSS CAD Suite build for Windows, see the install instructions. Note that the Yosys OSS CAD Suite requires MinGW (Minimalist GNU for Windows).

Any Windows users who would like to help improve this usability of Chisel on Windows are encouraged to reach out. See how to get in contact on the Chisel community page.

中文总结:

这篇官方Installation文档可以说相当全面,包括了以下几个层次的软件依赖安装:1是JDK。2是构建工具(Build Tools)包括Mill和SBT。3是Firtool。4是作为Verilog仿真器的Verilator。

这篇文章没有介绍Scala的安装,也没有介绍Chisel的安装。实际上这两个也是使用Chisel语言进行数字设计和仿真的必要工具。对于想基于Chisel跑通Chisel-Hello来“打底”的初学者来说,最重要的安装应该是:JDK的安装及Hello.java的运行Scala的安装及Hello.scala的运行Sbt的安装及ChiselHello.scala的运行。----特别注意最后一步没有提Chisel的安装及ChiselHello.scala的运行,而是说的Sbt的安装及ChiselHello.scala的运行。这其中的原因将在文章的评论中给出。

参考性示意图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

ChipCamp

谢谢支持和鼓励!

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

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

打赏作者

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

抵扣说明:

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

余额充值