Created
March 29, 2014 14:59
-
-
Save basveeling/9856004 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LFSR | |
@state = 0; | |
@taps = 0; | |
def initialize(state, taps) | |
@state = state | |
@taps = taps | |
end | |
def step | |
@state = (@state >> 1) ^ (-(@state & 1) & @taps); | |
return ((@state & 0x400) > 0) ? 1 : 0 | |
end | |
end | |
lfsr = LFSR.new(0x100, 0x829) | |
(0...32).each do |i| | |
puts lfsr.step | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment