Use val instead of def in ECC calculations
This allows nicer-looking code to avoid generating lots of redundant nodes.
This commit is contained in:
parent
635f119422
commit
2e23d46631
@ -38,10 +38,10 @@ class ParityCode extends Code
|
|||||||
def width(w0: Int) = w0+1
|
def width(w0: Int) = w0+1
|
||||||
def encode(x: UInt) = Cat(x.xorR, x)
|
def encode(x: UInt) = Cat(x.xorR, x)
|
||||||
def decode(y: UInt) = new Decoding {
|
def decode(y: UInt) = new Decoding {
|
||||||
def uncorrected = y(y.getWidth-2,0)
|
val uncorrected = y(y.getWidth-2,0)
|
||||||
def corrected = uncorrected
|
val corrected = uncorrected
|
||||||
def correctable = Bool(false)
|
val correctable = Bool(false)
|
||||||
def uncorrectable = y.xorR
|
val uncorrectable = y.xorR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ class SECCode extends Code
|
|||||||
}).asUInt
|
}).asUInt
|
||||||
|
|
||||||
private def swizzle(z: UInt) = (1 to n).filter(i => !isPow2(i)).map(i => z(i-1)).asUInt
|
private def swizzle(z: UInt) = (1 to n).filter(i => !isPow2(i)).map(i => z(i-1)).asUInt
|
||||||
def uncorrected = swizzle(y)
|
val uncorrected = swizzle(y)
|
||||||
def corrected = swizzle(((y << 1) ^ UIntToOH(syndrome)) >> 1)
|
val corrected = swizzle(((y << 1) ^ UIntToOH(syndrome)) >> 1)
|
||||||
def correctable = syndrome.orR
|
val correctable = syndrome.orR
|
||||||
def uncorrectable = syndrome > UInt(n)
|
val uncorrectable = syndrome > UInt(n)
|
||||||
}
|
}
|
||||||
private def mapping(i: Int) = i-1-log2Up(i)
|
private def mapping(i: Int) = i-1-log2Up(i)
|
||||||
}
|
}
|
||||||
@ -97,10 +97,10 @@ class SECDEDCode extends Code
|
|||||||
val secdec = sec.decode(x(x.getWidth-2,0))
|
val secdec = sec.decode(x(x.getWidth-2,0))
|
||||||
val pardec = par.decode(x)
|
val pardec = par.decode(x)
|
||||||
|
|
||||||
def uncorrected = secdec.uncorrected
|
val uncorrected = secdec.uncorrected
|
||||||
def corrected = secdec.corrected
|
val corrected = secdec.corrected
|
||||||
def correctable = pardec.uncorrectable
|
val correctable = pardec.uncorrectable
|
||||||
def uncorrectable = !pardec.uncorrectable && secdec.correctable
|
val uncorrectable = !pardec.uncorrectable && secdec.correctable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user