src/main/scala/chipsldpc/ConvergenceChecker.scala

Source from the repository checkout used to build these docs. Line numbers link to individual source lines.

 1package chipsldpc
 2
 3import chisel3._
 4import chipsldpc.graph.TannerGraph
 5
 6/** Combinational residual H * estimate + syndrome over GF(2). */
 7final class ConvergenceChecker(graph: TannerGraph) extends RawModule {
 8  val estimate  = IO(Input(Vec(graph.variableCount, Bool())))
 9  val syndrome  = IO(Input(Vec(graph.checkCount, Bool())))
10  val residual  = IO(Output(Vec(graph.checkCount, Bool())))
11  val converged = IO(Output(Bool()))
12
13  residual.zipWithIndex.foreach { case (bit, check) =>
14    val parity = VecInit(graph.rowOnes(check).map(estimate(_))).asUInt.xorR
15    bit := parity ^ syndrome(check)
16  }
17  converged := !residual.asUInt.orR
18}