Giter VIP home page Giter VIP logo

Comments (4)

poweihuang17 avatar poweihuang17 commented on July 3, 2024
class DelayBy1(resetValue: Option[UInt] = None) extends Module {
    val io = IO(new Bundle {
        val in  = Input( UInt(16.W))
        val out = Output(UInt(16.W))
    })
    val reg = if (resetValue.isDefined) { // resetValue = Some(number)
        RegInit(resetValue.get)
    } else { //resetValue = None
        Reg(UInt())
    }
    reg := io.in
    io.out := reg
}

println(getVerilog(new DelayBy1))
println(getVerilog(new DelayBy1(Some(3.U))))

from chisel-bootcamp.

poweihuang17 avatar poweihuang17 commented on July 3, 2024

This is the original code.

from chisel-bootcamp.

grebe avatar grebe commented on July 3, 2024

What you are describing is the desired behavior.

Registers without resets are synthesizable. As you say, it may introduce bugs if the garbage initial value is used in some undesirable way, but in some situations registers without reset values may be OK.

In the case of this module, imagine that there is a block that reads the value of io.out, but only does so several cycles after io.in is valid data (perhaps io.in is valid 2 cycles after reset and io.out is read 3 cycles after reset).

Resets can add extra overhead, especially because chisel resets are synchronous.

from chisel-bootcamp.

poweihuang17 avatar poweihuang17 commented on July 3, 2024

@grebe Thank you for your explanation!

from chisel-bootcamp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.