blob: 2a34fc458a774b33bad4016faef872d931cc0baa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# Chisel 3 Documentation
This directory contains documentation on the code within this repository.
Documents can either be written directly in markdown, or
use embedded [mdoc](https://scalameta.org/mdoc/)
which compiles against the `chisel3` (and dependencies) codebase
as part of the PR CI checks,
forcing the documentation to remain current with the codebase.
The `src` folder contains the source from which these are generated.
Our documentation is organized into the four categories as described in
[Divio's documentation system](https://documentation.divio.com/).
The four documentation types are:
1. Reference (source code scaladoc)
1. Explanation (`src/explanations`)
1. How-To Guides (`src/cookbooks`)
1. Tutorials (currently not located here)
Our documentation strategy for this repository is as follows:
* Any new public API requires reference documentation.
* Any new user-facing feature requires explanation documentation.
* Any bugfixes, corner-cases, or answers to commonly asked questions requires a how-to guide.
* Tutorials are kept in a separate repository.
This documentation is hosted on the Chisel [website](https://www.chisel-lang.org).
## mdoc
### Basic Use
To build the documentation, run `docs/mdoc` via SBT in the root directory. The generated documents
will appear in the `docs/generated` folder. To iterate on the documentation, you can run `docs/mdoc --watch`. For
more `mdoc` instructions you can visit their [website](https://scalameta.org/mdoc/).
### Custom `verilog` modifier
mdoc supports [custom modifiers](https://scalameta.org/mdoc/docs/modifiers.html#postmodifier).
We have created a custom `verilog` modifier to enable displaying the Verilog output of Chisel.
Example use:
````
```scala mdoc:silent
class MyModule extends RawModule {
val in = IO(Input(UInt(8.W)))
val out = IO(Output(UInt(8.W)))
out := in + 1.U
}
```
```scala mdoc:verilog
ChiselStage.emitVerilog(new MyModule)
```
````
The `verilog` modifier tells mdoc to run the Scala block, requiring that each Statement returns a String.
It will then concatenate the resulting Strings and wrap them in triple backticks with the language set to `verilog`:
````
```scala
class MyModule extends RawModule {
val in = IO(Input(UInt(8.W)))
val out = IO(Output(UInt(8.W)))
out := in + 1.U
}
```
```verilog
module MyModule(
input [7:0] in,
output [7:0] out
);
assign out = in + 8'h1; // @[main.scala 9:13]
endmodule
```
````
Note that `imports` are okay in `mdoc:verilog` blocks, but any utility Scala code should be in a separate block.
|