-
Notifications
You must be signed in to change notification settings - Fork 19
Polynomial
Snoopy87 edited this page Aug 18, 2017
·
3 revisions
Polynomial is used for having a code more readable. It is used for instance by LFSR, CRC, Galois field, ...
There is three different ways of creating a polynomial:
- String format
- Hexadecimal format
- Binary format
The string format is composed only of the following characters : '+' '0-9' '^' 'x'
val polynomial = p"x^4 + x^2 + x + 1"
For writting hexadecimal polynomial you have to give the order of the polynomial and then the hexadecimal value
// Polynomial used by CRC-32 (x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1 )
val polynomial = p"32'x04C11DB7"
val polynomial = p"b10011" // x^4 + x + 1
The following three polynomial are exactly the same :
val p1 = p"x^8 + x^7 + x^6 + x^4 + x^2 + 1"
val p2 = p"8'xD5"
val p3 = p"b111010101"