Skip to content

Polynomial

Snoopy87 edited this page Aug 18, 2017 · 3 revisions

Definition

Polynomial is used for having a code more readable. It is used for instance by LFSR, CRC, Galois field, ...

Declaration

There is three different ways of creating a polynomial:

  1. String format
  2. Hexadecimal format
  3. Binary format

String format

The string format is composed only of the following characters : '+' '0-9' '^' 'x'

val polynomial = p"x^4 + x^2 + x + 1"

Hexadecimal format

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"  

Binary format

val polynomial = p"b10011" // x^4 + x + 1 

Example

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"
Clone this wiki locally