Reputation: 31
I saw a code in section 3.2 interlude in generator-bootcamp:
val io = IO(new Bundle {
val in = Flipped(Decoupled(UInt(8.W)))
val out = Decoupled(UInt(8.W))
})
Is there anyone who know the functionality of "Flipped"? I searched it in chisel3 doc, but it doesn't have this information.
https://chisel.eecs.berkeley.edu/api/#Chisel.package$$Flipped$
Thanks in advance
Upvotes: 3
Views: 2587
Reputation: 4051
Decoupled defaults to being an output, that is its argument, in this case the UInt(8.W) will bring data into the module. Decoupled adds ready and valid handshaking signals to in
.
The Flipped()
changes the direction of all fields of it's argument. So out
is suitable for communicating information out of the module.
The code here is equivalent to
val io = IO(new Bundle {
val in = new Bundle {
val valid = Input(Bool())
val ready = Output(Bool())
val bits = Input(UInt(8.W))
}
val out = new Bundle {
val valid = Output(Bool())
val ready = Input(Bool())
val bits = Output(UInt(8.W))
}
}
I will see that something gets added to chisel3 wiki.
Upvotes: 4