util: add the IdentityModule, useful to dedup wires
This commit is contained in:
parent
1a87ed1193
commit
5626cdd18f
24
src/main/scala/util/IdentityModule.scala
Normal file
24
src/main/scala/util/IdentityModule.scala
Normal file
@ -0,0 +1,24 @@
|
||||
// See LICENSE.SiFive for license details.
|
||||
|
||||
package freechips.rocketchip.tilelink
|
||||
|
||||
import Chisel._
|
||||
|
||||
class IdentityModule[T <: Data](gen: T) extends Module
|
||||
{
|
||||
val io = new Bundle {
|
||||
val in = gen.cloneType.flip
|
||||
val out = gen.cloneType
|
||||
}
|
||||
|
||||
io.out := io.in
|
||||
}
|
||||
|
||||
object IdentityModule
|
||||
{
|
||||
def apply[T <: Data](x: T): T = {
|
||||
val identity = Module(new IdentityModule(x))
|
||||
identity.io.in := x
|
||||
identity.io.out
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user