Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Linear-feedback shift register
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Xorshift LFSRs == {{Main | Xorshift}} As shown by [[George Marsaglia]]<ref name="marsaglia">{{cite journal | first=George | last=Marsaglia | author-link=George Marsaglia | title=Xorshift RNGs | journal=[[Journal of Statistical Software]] | volume=8 | issue=14 | date=July 2003 | url=https://www.jstatsoft.org/v08/i14/paper | doi=10.18637/jss.v008.i14| doi-access=free}}</ref> and further analysed by [[Richard P. Brent]],<ref name="brent">{{cite journal | first=Richard P. | last=Brent | author-link=Richard P. Brent | title=Note on Marsaglia's Xorshift Random Number Generators | journal=[[Journal of Statistical Software]] | volume=11 | issue=5 | date=August 2004 | url=https://www.jstatsoft.org/v11/i05/paper | doi=10.18637/jss.v011.i05| doi-access=free| hdl=1885/34049| hdl-access=free}}</ref> linear feedback shift registers can be implemented using XOR and Shift operations. This approach lends itself to fast execution in software because these operations typically map efficiently into modern processor instructions. Below is a [[C (programming language)|C]] code example for a 16-bit maximal-period Xorshift LFSR using the 7,9,13 triplet from John Metcalf:<ref>{{cite web |last1=Metcalf |first1=John |title=16-Bit Xorshift Pseudorandom Numbers in Z80 Assembly |url=http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html |website=Retro Programming |access-date=5 January 2022|date=22 July 2017}}</ref> <syntaxhighlight lang="c"> #include <stdint.h> unsigned lfsr_xorshift(void) { uint16_t start_state = 0xACE1u; /* Any nonzero start state will work. */ uint16_t lfsr = start_state; unsigned period = 0; do { // 7,9,13 triplet from http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html lfsr ^= lfsr >> 7; lfsr ^= lfsr << 9; lfsr ^= lfsr >> 13; ++period; } while (lfsr != start_state); return period; } </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Linear-feedback shift register
(section)
Add topic