Skip to content

Commit

Permalink
Add IOHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
rmac-sifive committed Feb 8, 2020
1 parent 319b6c4 commit a0277e7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/scala/prci/IOHelper.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// See LICENSE.SiFive for license details.
// See LICENSE.Berkeley for license details.
package freechips.rocketchip.prci

import Chisel._
import chisel3.experimental.IO
import freechips.rocketchip.diplomacy._

object IOHelper {

def forNonSynchronous[T <: Data](gen: => T, xs: Seq[ClockCrossingType], prefix: String): Seq[Option[ModuleValue[T]]] = {
xs.zipWithIndex.map { case (x, i) => forNonSynchronous(gen, x, prefix + s"_$i") }
}

def forNonSynchronous[T <: Data](gen: => T, x: ClockCrossingType, name: String): Option[ModuleValue[T]] = {
x match {
case SynchronousCrossing(_) => None
case _ => Some(InModuleBody(IO(gen.asInput).suggestName(name)))
}
}
}

0 comments on commit a0277e7

Please sign in to comment.