Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Add support for the PresetRegAnnotation #329

Open
ekiwi opened this issue May 20, 2021 · 2 comments
Open

Add support for the PresetRegAnnotation #329

ekiwi opened this issue May 20, 2021 · 2 comments

Comments

@ekiwi
Copy link
Collaborator

ekiwi commented May 20, 2021

This annotation is emitted by the PropagatePresetAnnotations pass from firrtl and should result in the annotated register starting at its init value at the start of simulation. It would be great if treadle could automatically detect this annotation and use it similar to how memory initialization is already supported.

@chick
Copy link
Collaborator

chick commented May 20, 2021

@ekiwi can you provide, or point me to, an example module and test?

@ekiwi
Copy link
Collaborator Author

ekiwi commented May 20, 2021

Here is an example where you would expect the output to always be 123 and never 0: https://scastie.scala-lang.org/TlYbM54hSLOShAxPYTvlOQ

import chisel3._
import chisel3.experimental._
import firrtl.annotations.PresetAnnotation
import chisel3.stage.ChiselStage

class Foo extends MultiIOModule with RequireAsyncReset {
  annotate(new ChiselAnnotation {
    override def toFirrtl = PresetAnnotation(reset.toTarget)
  })
  
  val out = IO(Output(UInt(8.W)))
  
  val r = RegInit(123.U(8.W))
  dontTouch(r)

  out := r
}

println(ChiselStage.emitVerilog(new Foo))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants