Skip to content

Commit

Permalink
[CRC.scala] Note CRC's object explicit+1 notation
Browse files Browse the repository at this point in the history
#2963 just so users can follow the CRC object's API a bit better. 


Perhaps #2960 should include a scala doc
  • Loading branch information
michael-etzkorn authored Apr 14, 2022
1 parent 045d03c commit 481dadb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/scala/util/CRC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import Chisel._

object CRC
{
// A divisor of 0x1d5 is interpretted to be x^8 + x^7 + x^6 + x^4 + x^2 + 1
// A divisor is interpretted using an explicit+1 CRC notation where bit 0 is required to be one.
// For example, a divisor of 0x1d5 is interpretted to be x^8 + x^7 + x^6 + x^4 + x^2 + 1
// Let n be the highest term in the divisor; n=8 in 0x1d5.
// Then, this function calculates c mod d, returning an n-bit UInt.
// coefficient.width must be <= width
Expand All @@ -30,6 +31,6 @@ object CRC
Cat(Seq.tabulate(n) { i => (UInt(array(i)) & coefficient).xorR } .reverse)
}

// Find more great CRC polynomials here: https://users.ece.cmu.edu/~koopman/crc/
val CRC_16F_4_2 = BigInt(0x1a2eb) // HD=4 for <32751 bits and HD=6 for <93 bits
// Find more great CRC polynomials (using implicit+1 notation) here: https://users.ece.cmu.edu/~koopman/crc/
val CRC_16F_4_2 = BigInt(0x1a2eb) // HD=4 for <32751 bits and HD=6 for <93 bits, 0xd175 in implicit+1 notation
}

0 comments on commit 481dadb

Please sign in to comment.