src/main/scala/chipsldpc/Config.scala
Source from the repository checkout used to build these docs. Line numbers link to individual source lines.
1package chipsldpc
2
3final case class Quantization(magnitudeBits: Int, accumulatorBits: Int) {
4 require(magnitudeBits > 0)
5 require(accumulatorBits >= magnitudeBits + 1)
6}
7
8object RelayDefaults {
9 /** Legacy accumulator profile used by the existing vanilla benchmarks. */
10 val q = Quantization(4, 7)
11 val scale: CheckScale = RampScale(q.magnitudeBits)
12 val priorScale = 2
13 val memoryScale = 8
14
15 /** Named FPGA-paper profile; kept separate so vanilla results do not drift. */
16 val paperQ = Quantization(4, 5)
17 val paperFormat = RelayFormat(betaBits = 4, fractionalBits = 3)
18}
19
20sealed trait CheckScale { def controlBits: Int = 1 }
21case object NoScale extends CheckScale
22final case class VallsScale(a: Int, b: Int) extends CheckScale {
23 require(a >= 0 && b >= 0)
24}
25final case class RampScale(maxShift: Int) extends CheckScale {
26 require(maxShift > 0)
27 override val controlBits: Int = math.max(1, BigInt(maxShift).bitLength)
28}
29
30final case class CheckConfig(degree: Int, q: Quantization, scale: CheckScale = NoScale) {
31 require(degree >= 2)
32}
33
34final case class VariableConfig(degree: Int, q: Quantization) {
35 require(degree > 0)
36 val workBits: Int = q.accumulatorBits + math.max(1, BigInt(degree).bitLength)
37}
38
39final case class RelayFormat(betaBits: Int, fractionalBits: Int) {
40 require(fractionalBits >= 0 && betaBits > fractionalBits)
41}