Skip to content

Commit

Permalink
Fix ChiselEnum docs (#2016) (#2017)
Browse files Browse the repository at this point in the history
Also add newline to end of `verilog` modifier code blocks so that there
is always a newline between code blocks and following material.

(cherry picked from commit 558df41)

Co-authored-by: Jack Koenig <koenig@sifive.com>
  • Loading branch information
mergify[bot] and jackkoenig authored Jul 8, 2021
1 parent 9512538 commit d9009d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class VerilogMdocModifier extends PostModifier {
case (None, _) => None
}
result match {
case Some(content) => s"```verilog\n$content```"
case Some(content) => s"```verilog\n$content```\n"
case None => ""
}
}
Expand Down
7 changes: 5 additions & 2 deletions docs/src/explanations/chisel-enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class AluMux1File extends Module {
}
}
```

```scala mdoc:verilog
ChiselStage.emitVerilog(new AluMux1File)
```
Expand Down Expand Up @@ -140,8 +141,9 @@ that the `UInt` could hit, you will see a warning like the following:

```scala mdoc:passthrough
val (log, _) = grabLog(ChiselStage.emitChirrtl(new FromUInt))
println(s"```$log```")
println(s"```\n$log```")
```

(Note that the name of the Enum is ugly as an artifact of our documentation generation flow, it will
be cleaner in normal use).

Expand All @@ -162,7 +164,7 @@ Now there will be no warning:

```scala mdoc:passthrough
val (log2, _) = grabLog(ChiselStage.emitChirrtl(new SafeFromUInt))
println(s"```$log2```")
println(s"```\n$log2```")
```

## Testing
Expand All @@ -181,6 +183,7 @@ def expectedSel(sel: AluMux1Sel.Type): Boolean = sel match {
```

Some additional useful methods defined on the `ChiselEnum` object are:

* `.all`: returns the enum values within the enumeration
* `.getWidth`: returns the width of the hardware type

Expand Down

0 comments on commit d9009d5

Please sign in to comment.