azonenberg_work has quit [Ping timeout: 246 seconds]
emeb has quit [Quit: Leaving.]
emeb_mac has joined #yosys
<awygle>
ZipCPU: you wrote a bunch of great articles about LFSRs - do you know if there's a derivation for a maximal length polynomial or is it just trial and error to find them?
<awygle>
That is, I'm looking for a function which takes a shreg length and returns a maximal length polynomial of that size.
<sorear>
awygle: there's no derivation, but the number of maximal length polynomials is fairly large (\phi(something))
<sorear>
this is one of those riemann-hypothesis-tangential things
<sorear>
are you familiar with the relationship between LFSRs and finite fields?
<awygle>
sorear: ah cool... wonder if there's a cheap test, a la statistical primality testing or something
<awygle>
sorear: I know there is one (they're polynomials on GF(n)) but my theoretical math background is weak.
<sorear>
a LFSR, let's say binary with 32 bits of state, stores a number in GF(2^32) and repeatedly multiplies it by an element of the finite field
<sorear>
a polynomial is maximal length if the x element is a generator of the multiplicative group of the finite field
<sorear>
for *prime order* finite fields, the existance of small generators is a consequence of the generalized riemann hypothesis; i don't know what the situation in small characteristic (2^n, 3^n) is
<sorear>
there's a fairly cheap test
<sorear>
you can easily prove that the period of a LFSR is a divisor of 2^n-1
<sorear>
a LFSR is linear, so you can represent it as a matrix over GF(2) with no real cleverness required, and take large powers
<sorear>
if the Kth power is non-identity for all proper divisors of 2^n-1, then the period must be exactly 2^n-1
<sorear>
this requires you to have a prime factorization of 2^n-1, which could be tricky if n is much more than 500
<sorear>
you can optimize this by using field exponentiation instead of matrix exponentiation, but it's harder to explain that way
<awygle>
I am struggling to keep up... but I think I get it. So for my hypothetical generator I'd need to factor 2^n-1, then pick a random polynomial represented as a matrix... Then.... Raise it to a big number and make sure it's not divisible by any of the prime factors?
<awygle>
Is n the number of bits? The length I mean?
<sorear>
yes
<awygle>
Okay and if it's divisible just pick a new one
<sorear>
the correspondence is easier to see for the "Galois form" of LFSRs; each step multiplies by x mod the generating polynomial
<sorear>
so if you can implement finite field arithmetic mod an arbitrary polynomial, then you calculate x^K for K = all proper maximal divisors of 2^n-1
<sorear>
if all x^K != 1, then your polynomial is maximal length
<awygle>
Oh okay that makes more sense.
<sorear>
galois form is state = (state << 1) ^ (state & HIGH ? poly : 0);
<awygle>
And odds are good that I'll randomly pick a good one because of squinting at the riemann hypothesis
<sorear>
x^(2^n-1) = 1 (closely related to Fermat's little theorem), but you may or may not have x^K=1 for a proper divisor
<awygle>
This seems fairly amenable to a gperf style build time calculator. Except maybe the factoring, that could take a long time.
<awygle>
I guess this isn't really a problem anyone has though, just look up a table
<sorear>
you statically know that there's no remainder, so the division by 3 can be replaced by a multiplication by the ring inverse in Z/(2^32)Z
<sorear>
the procedure for calculating that is Newton's method over the 2-adic numbers; it's *exactly the same* as a Newton iteration to calculate a FP inverse
azonenberg_work has joined #yosys
rohitksingh_work has joined #yosys
azonenberg_work has quit [Quit: Leaving.]
azonenberg_work has joined #yosys
digshadow has joined #yosys
azonenberg_work has quit [Ping timeout: 245 seconds]
<awygle>
shapr: any chance you're still awake?
azonenberg_work has joined #yosys
seldridge has quit [Ping timeout: 252 seconds]
NB0X-Matt-CA has quit [Excess Flood]
NB0X-Matt-CA has joined #yosys
emeb_mac has quit [Ping timeout: 240 seconds]
m4ssi has joined #yosys
fsasm has joined #yosys
<edmoore>
[NARRATOR: He was asleep.]
GuzTech has joined #yosys
FL4SHK has quit [Ping timeout: 250 seconds]
FL4SHK has joined #yosys
pie__ has joined #yosys
pie_ has quit [Ping timeout: 245 seconds]
pie__ is now known as pie_
xdeller has quit [Ping timeout: 250 seconds]
xdeller has joined #yosys
xdeller has quit [Remote host closed the connection]
xdeller has joined #yosys
SpaceCoaster has quit [Quit: ZNC 1.6.5+deb1+deb9u1 - http://znc.in]
rohitksingh_work has quit [Read error: Connection reset by peer]
seldridge has joined #yosys
rohitksingh has joined #yosys
emeb has joined #yosys
seldridge has quit [Ping timeout: 276 seconds]
rohitksingh has quit [Ping timeout: 240 seconds]
maikmerten has joined #yosys
maikmerten has quit [Remote host closed the connection]
seldridge has joined #yosys
maikmerten has joined #yosys
<awygle>
good morning!
<ZipCPU>
awygle: Speak for yourself.
<ZipCPU>
;)
<awygle>
ZipCPU: we wish you a ~merry Christmas~ good morning
mwk has quit [Ping timeout: 272 seconds]
* ZipCPU
needs to touch up his ORCONF presentation before leaving town.
mwk has joined #yosys
mwk has quit [Ping timeout: 252 seconds]
mwk has joined #yosys
rohitksingh has joined #yosys
rohitksingh has quit [Client Quit]
mwk has quit [Read error: Connection reset by peer]
mwk has joined #yosys
m4ssi has quit [Remote host closed the connection]
dys has joined #yosys
fsasm has quit [Ping timeout: 250 seconds]
digshadow has quit [Ping timeout: 246 seconds]
azonenberg_work has quit [Ping timeout: 252 seconds]
digshadow has joined #yosys
azonenberg_work has joined #yosys
rohitksingh has joined #yosys
maikmerten has quit [Remote host closed the connection]
rohitksingh has quit [Client Quit]
maikmerten has joined #yosys
develonepi3 has quit [Quit: Leaving]
seldridge has quit [Ping timeout: 252 seconds]
seldridge has joined #yosys
maikmerten has quit [Remote host closed the connection]