0%

# 什么是 chisel

https://www.chisel-lang.org/

# 学习资料

freechipsproject/chisel-bootcamp

Chisel Bootcamp 中文

schoeberl/chisel-book

schoeberl/chisel-examples

chisel3 api

# 安装

Installing sbt

Follow the instructions from Chisel3 and firrtl websites.

Docker:

# 语法

## if or when ?

if 是 scala 的语法，不能综合；

when 是 chisel 的语法，等同于 Verilog 中的 if

## 带有Decoupled接口的模块

Decoupled可以将基本的chisel数据类型包装起来，并为其提供readyvalid信号。 Testers2提供了一些很好的工具，可以自动并可靠地测试这些接口。

src

tb

## Queues

Queue creates a FIFO (first-in, first-out) queue with Decoupled interfaces on both sides, allowing backpressure. Both the data type and number of elements are configurable.

## Arbiters

Arbiters routes data from n DecoupledIO sources to one DecoupledIO sink, given a prioritization. There are two types included in Chisel:

• Arbiter: prioritizes lower-index producers
• RRArbiter: runs in round-robin order

Note that Arbiter routing is implemented in combinational logic.

## PopCount

PopCount returns the number of high (1) bits in the input as a UInt.

## Reverse

Reverse returns the bit-reversed input.

## OneHot encoding utilities

OneHot is an encoding of integers where there is one wire for each value, and exactly one wire is high. This allows the efficient creation of some functions, for example muxes. However, behavior may be undefined if the one-wire-high condition is not held.

• UInt to OneHot: UIntToOH
• OneHot to UInt: OHToUInt

## Muxes

These muxes take in a list of values with select signals, and output the value associated with the lowest-index select signal.

These can either take a list of (select: Bool, value: Data) tuples, or corresponding lists of selects and values as arguments. For simplicity, the examples below only demonstrate the second form.

### Priority Mux

A PriorityMux outputs the value associated with the lowest-index asserted select signal.

### OneHot Mux

An Mux1H provides an efficient implementation when it is guaranteed that exactly one of the select signals will be high. Behavior is undefined if the assumption is not true.

## scala 语法

### 合并 list

Merge two lists using the ++, concat, or ::: methods.