-
Notifications
You must be signed in to change notification settings - Fork 641
Add IrrevocableIO alternative to DecoupledIO #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… .bits on a cycle after .valid is high and .ready is low
|
There's also the constraint that valid will stay high once it's asserted, right? Should probably be pedantic about the description in the comment. |
|
The subclassing seems improper since the subclassing contract fails, for example, when this is used for 'enqueue' sides of Modules. The underling issue is that IrrevocableIO is indicating (via subclassing) that it can be used any time you expect a DecoupledIO. class SensitiveSink extends Module {
val io = IO(new Bundle {
val enq = Flipped(IrrevocableIO(UInt(16)))
})
// do something
}
def driveFromUnreliableSource(enq: DecoupledIO[UInt]) = {
val parity = Reg(init = false.asBool)
val bits = Reg(init = 1.asUInt(16))
enq.valid := parity
enq.bits := Mux(parity, bits, 0.asUInt)
when(enq.valid && enq.ready) { bits := bits +% 1.asUInt }
}
class Test extends BasicTester {
val sink = Module(new SensitiveSink)
driveFromUnreliableSource(sink.io.enq) // will compile and elaborate fine
} |
|
Is your proposal to not make it descend from DecoupledIO but instead be a separate part of the type hierarchy? |
|
Yes On Tue, Sep 6, 2016 at 10:10 PM, Andrew Waterman notifications@github.com
|
|
I totally see your point. I was scared of making backwards-incompatible changes to QueueIO. Working on a solution that uses a common base class and some factory method cleverness. Too bad that flipped things are the same type :P |
…and add new Queue factory method
| { | ||
| def apply[T <: Data](gen: T): DecoupledIO[T] = new DecoupledIO(gen) | ||
|
|
||
| def apply[T <: Data](irr: IrrevocableIO[T]): DecoupledIO[T] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add scaladoc for the two apply methods? the new one should explain the use case and the invariant
|
I think this is ok now |
| deq.ready := irr.ready | ||
| irr | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at it, could we have 'flow' added as another defaulted argument on the Queue.methods?
… that promises not to change the contents of .bits on a cycle after .valid is high and .ready is low. This is useful for detecting whether queues have been correctly inserted in front of modules that require these additional semantics.