Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/src/cookbooks/hierarchy.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,12 @@ class AddOne(val width: Int) extends Module {
out := in + 1.U
}

class AddTwo(addOneDef: Definition[AddOne]) extends Module {
val i0 = Instance(addOneDef)
val i1 = Instance(addOneDef)
val in = IO(Input(UInt(addOneDef.width.W)))
val out = IO(Output(UInt(addOneDef.width.W)))
class AddTwo(addOneDef: => Definition[AddOne]) extends Module {
private val definition = addOneDef
val i0 = Instance(definition)
val i1 = Instance(definition)
val in = IO(Input(UInt(definition.width.W)))
val out = IO(Output(UInt(definition.width.W)))
i0.in := in
i1.in := i0.out
out := i1.out
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/circt/stage/ChiselStage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ object ChiselStage {
Seq(
Dependency[chisel3.stage.phases.Elaborate],
Dependency[chisel3.stage.phases.Convert],
Dependency[chisel3.stage.phases.AddDedupGroupAnnotations],
Dependency[circt.stage.phases.AddImplicitOutputFile],
Dependency[chisel3.stage.phases.AddImplicitOutputAnnotationFile],
Dependency[circt.stage.phases.Checks],
Expand Down
12 changes: 10 additions & 2 deletions src/test/scala-2/chiselTests/DedupSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
package chiselTests

import chisel3._
import chisel3.util._
import chisel3.util.{Counter, Decoupled, Queue}
import chisel3.experimental.{annotate, dedupGroup}
import chisel3.experimental.hierarchy.Definition
import chisel3.properties.Class
import circt.stage.ChiselStage
import firrtl.transforms.DedupGroupAnnotation
import chisel3.experimental.hierarchy._
import chisel3.util.circt.PlusArgsValue
Expand Down Expand Up @@ -121,13 +122,20 @@ class DedupSpec extends ChiselFlatSpec {
}) === 3)
}

it should "work natively for desiredNames" in {
it should "work natively for desiredNames with ChiselStage (the class)" in {
assert(countModules(compile {
val top = new SharedConstantValDedupTopDesiredName
top
}) === 3)
}

it should "work natively for desiredNames with ChiselStage$ (the object)" in {
assert(countModules(ChiselStage.emitSystemVerilog {
val top = new SharedConstantValDedupTopDesiredName
top
}) === 3)
}

it should "error on conflicting dedup groups" in {
a[Exception] should be thrownBy {
compile {
Expand Down
Loading