lfsr 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.markdown +96 -0
- data/Rakefile +67 -0
- data/examples/sample.rb +38 -0
- data/ext/lfsr/extconf.rb +6 -0
- data/ext/lfsr/lfsr.c +974 -0
- data/ext/lfsr/lfsr.h +6 -0
- data/lfsr.gemspec +38 -0
- data/lib/lfsr.rb +38 -0
- data/lib/lfsr/fast.rb +4 -0
- data/lib/lfsr/pure.rb +665 -0
- data/scripts/bench +21 -0
- data/scripts/genc.rb +55 -0
- data/scripts/genruby.rb +72 -0
- data/scripts/taps.rb +69 -0
- data/test/lfsr_test.rb +44 -0
- metadata +65 -0
data/ext/lfsr/lfsr.h
ADDED
data/lfsr.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'lfsr'
|
5
|
+
s.version = '1.0.0'
|
6
|
+
s.summary = "Generate sequences of pseudo random numbers"
|
7
|
+
s.description = <<-EOF
|
8
|
+
The generation of random numbers is too important to be left to chance.
|
9
|
+
A Linear Feedback Shift Register is an automaton that
|
10
|
+
can be used to generate a long sequence of different pseudo-random numbers.
|
11
|
+
EOF
|
12
|
+
s.email = 'emmanueloga@gmail.com'
|
13
|
+
s.homepage = 'http://github.com/EmmanuelOga/lfsr'
|
14
|
+
s.authors = ["Emmanuel Oga"]
|
15
|
+
|
16
|
+
s.files = %w[
|
17
|
+
scripts/genc.rb
|
18
|
+
scripts/bench
|
19
|
+
scripts/genruby.rb
|
20
|
+
scripts/taps.rb
|
21
|
+
examples/sample.rb
|
22
|
+
test/lfsr_test.rb
|
23
|
+
LICENSE
|
24
|
+
lfsr.gemspec
|
25
|
+
ext/lfsr/extconf.rb
|
26
|
+
ext/lfsr/lfsr.c
|
27
|
+
ext/lfsr/lfsr.h
|
28
|
+
Rakefile
|
29
|
+
lib/lfsr.rb
|
30
|
+
lib/lfsr/fast.rb
|
31
|
+
lib/lfsr/pure.rb
|
32
|
+
README.markdown
|
33
|
+
]
|
34
|
+
s.test_files = ["test/lfsr_test.rb"]
|
35
|
+
s.extra_rdoc_files = ["LICENSE"]
|
36
|
+
s.extensions = ["ext/lfsr/extconf.rb"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
end
|
data/lib/lfsr.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module LFSR
|
2
|
+
VERSION = "1.0.0"
|
3
|
+
|
4
|
+
class Base
|
5
|
+
attr_reader :reg
|
6
|
+
attr_accessor :max
|
7
|
+
attr_reader :seed
|
8
|
+
|
9
|
+
def initialize(max = nil, seed = nil)
|
10
|
+
# The C code depends on this being the first ivar to work properly.
|
11
|
+
@reg = 1
|
12
|
+
|
13
|
+
# This should be the second variable.
|
14
|
+
@max = (max || self.class.const_get(:MASK) - 1) + 1
|
15
|
+
|
16
|
+
reset seed
|
17
|
+
end
|
18
|
+
|
19
|
+
def reset(new_seed)
|
20
|
+
@reg = @seed = (new_seed || Time.now.utc.to_i) & self.class.const_get(:MASK)
|
21
|
+
raise ArgumentError, "The seed #{new_seed} is unacceptable for this register size" if new_seed && @reg == 0
|
22
|
+
@reg = @seed = (new_seed || Time.now.utc.to_i) & self.class.const_get(:MASK) while @reg == 0
|
23
|
+
end
|
24
|
+
|
25
|
+
alias peek reg
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get a LFSR with the appropriate number of bits to reach the maximum needed.
|
29
|
+
def self.gen(max, namespace = LFSR)
|
30
|
+
bits = Math.log2(max + 2).ceil
|
31
|
+
namespace.const_get("Size#{bits < 3 ? 3 : bits}").new(max)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.default_to(namespace)
|
35
|
+
2.upto(61) { |n| remove_const("Size#{n}")} if defined? LFSR::Size2
|
36
|
+
2.upto(61) { |n| const_set("Size#{n}", namespace.const_get("Size#{n}")) }
|
37
|
+
end
|
38
|
+
end
|
data/lib/lfsr/fast.rb
ADDED
data/lib/lfsr/pure.rb
ADDED
@@ -0,0 +1,665 @@
|
|
1
|
+
require 'lfsr'
|
2
|
+
|
3
|
+
module LFSR::Pure
|
4
|
+
end
|
5
|
+
|
6
|
+
class LFSR::Pure::Size2 < LFSR::Base
|
7
|
+
MASK = 0x3
|
8
|
+
|
9
|
+
def next_i
|
10
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]) << 0x1)
|
11
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]) << 0x1) while @reg > @max
|
12
|
+
@reg - 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
class LFSR::Pure::Size3 < LFSR::Base
|
18
|
+
MASK = 0x7
|
19
|
+
|
20
|
+
def next_i
|
21
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]) << 0x2)
|
22
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]) << 0x2) while @reg > @max
|
23
|
+
@reg - 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
class LFSR::Pure::Size4 < LFSR::Base
|
29
|
+
MASK = 0xf
|
30
|
+
|
31
|
+
def next_i
|
32
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]) << 0x3)
|
33
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]) << 0x3) while @reg > @max
|
34
|
+
@reg - 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
class LFSR::Pure::Size5 < LFSR::Base
|
40
|
+
MASK = 0x1f
|
41
|
+
|
42
|
+
def next_i
|
43
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x4)
|
44
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x4) while @reg > @max
|
45
|
+
@reg - 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
class LFSR::Pure::Size6 < LFSR::Base
|
51
|
+
MASK = 0x3f
|
52
|
+
|
53
|
+
def next_i
|
54
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x5)
|
55
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x5) while @reg > @max
|
56
|
+
@reg - 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
class LFSR::Pure::Size7 < LFSR::Base
|
62
|
+
MASK = 0x7f
|
63
|
+
|
64
|
+
def next_i
|
65
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x6)
|
66
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x6) while @reg > @max
|
67
|
+
@reg - 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
class LFSR::Pure::Size8 < LFSR::Base
|
73
|
+
MASK = 0xff
|
74
|
+
|
75
|
+
def next_i
|
76
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[4]) << 0x7)
|
77
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[4]) << 0x7) while @reg > @max
|
78
|
+
@reg - 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
class LFSR::Pure::Size9 < LFSR::Base
|
84
|
+
MASK = 0x1ff
|
85
|
+
|
86
|
+
def next_i
|
87
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x8)
|
88
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x8) while @reg > @max
|
89
|
+
@reg - 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
class LFSR::Pure::Size10 < LFSR::Base
|
95
|
+
MASK = 0x3ff
|
96
|
+
|
97
|
+
def next_i
|
98
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x9)
|
99
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x9) while @reg > @max
|
100
|
+
@reg - 1
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
class LFSR::Pure::Size11 < LFSR::Base
|
106
|
+
MASK = 0x7ff
|
107
|
+
|
108
|
+
def next_i
|
109
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[4]) << 0xa)
|
110
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[4]) << 0xa) while @reg > @max
|
111
|
+
@reg - 1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
class LFSR::Pure::Size12 < LFSR::Base
|
117
|
+
MASK = 0xfff
|
118
|
+
|
119
|
+
def next_i
|
120
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0xb)
|
121
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0xb) while @reg > @max
|
122
|
+
@reg - 1
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
class LFSR::Pure::Size13 < LFSR::Base
|
128
|
+
MASK = 0x1fff
|
129
|
+
|
130
|
+
def next_i
|
131
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0xc)
|
132
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0xc) while @reg > @max
|
133
|
+
@reg - 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
class LFSR::Pure::Size14 < LFSR::Base
|
139
|
+
MASK = 0x3fff
|
140
|
+
|
141
|
+
def next_i
|
142
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[5]) << 0xd)
|
143
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[5]) << 0xd) while @reg > @max
|
144
|
+
@reg - 1
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
class LFSR::Pure::Size15 < LFSR::Base
|
150
|
+
MASK = 0x7fff
|
151
|
+
|
152
|
+
def next_i
|
153
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[4]) << 0xe)
|
154
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[4]) << 0xe) while @reg > @max
|
155
|
+
@reg - 1
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
class LFSR::Pure::Size16 < LFSR::Base
|
161
|
+
MASK = 0xffff
|
162
|
+
|
163
|
+
def next_i
|
164
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[5]) << 0xf)
|
165
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[5]) << 0xf) while @reg > @max
|
166
|
+
@reg - 1
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
class LFSR::Pure::Size17 < LFSR::Base
|
172
|
+
MASK = 0x1ffff
|
173
|
+
|
174
|
+
def next_i
|
175
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x10)
|
176
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x10) while @reg > @max
|
177
|
+
@reg - 1
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
class LFSR::Pure::Size18 < LFSR::Base
|
183
|
+
MASK = 0x3ffff
|
184
|
+
|
185
|
+
def next_i
|
186
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x11)
|
187
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x11) while @reg > @max
|
188
|
+
@reg - 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
class LFSR::Pure::Size19 < LFSR::Base
|
194
|
+
MASK = 0x7ffff
|
195
|
+
|
196
|
+
def next_i
|
197
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x12)
|
198
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x12) while @reg > @max
|
199
|
+
@reg - 1
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
class LFSR::Pure::Size20 < LFSR::Base
|
205
|
+
MASK = 0xfffff
|
206
|
+
|
207
|
+
def next_i
|
208
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x13)
|
209
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x13) while @reg > @max
|
210
|
+
@reg - 1
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
class LFSR::Pure::Size21 < LFSR::Base
|
216
|
+
MASK = 0x1fffff
|
217
|
+
|
218
|
+
def next_i
|
219
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x14)
|
220
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x14) while @reg > @max
|
221
|
+
@reg - 1
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
class LFSR::Pure::Size22 < LFSR::Base
|
227
|
+
MASK = 0x3fffff
|
228
|
+
|
229
|
+
def next_i
|
230
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[4]^@reg[5]) << 0x15)
|
231
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[4]^@reg[5]) << 0x15) while @reg > @max
|
232
|
+
@reg - 1
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
class LFSR::Pure::Size23 < LFSR::Base
|
238
|
+
MASK = 0x7fffff
|
239
|
+
|
240
|
+
def next_i
|
241
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[5]) << 0x16)
|
242
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[5]) << 0x16) while @reg > @max
|
243
|
+
@reg - 1
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
class LFSR::Pure::Size24 < LFSR::Base
|
249
|
+
MASK = 0xffffff
|
250
|
+
|
251
|
+
def next_i
|
252
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x17)
|
253
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x17) while @reg > @max
|
254
|
+
@reg - 1
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
|
259
|
+
class LFSR::Pure::Size25 < LFSR::Base
|
260
|
+
MASK = 0x1ffffff
|
261
|
+
|
262
|
+
def next_i
|
263
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x18)
|
264
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x18) while @reg > @max
|
265
|
+
@reg - 1
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
class LFSR::Pure::Size26 < LFSR::Base
|
271
|
+
MASK = 0x3ffffff
|
272
|
+
|
273
|
+
def next_i
|
274
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[6]) << 0x19)
|
275
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[6]) << 0x19) while @reg > @max
|
276
|
+
@reg - 1
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
class LFSR::Pure::Size27 < LFSR::Base
|
282
|
+
MASK = 0x7ffffff
|
283
|
+
|
284
|
+
def next_i
|
285
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x1a)
|
286
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x1a) while @reg > @max
|
287
|
+
@reg - 1
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
|
292
|
+
class LFSR::Pure::Size28 < LFSR::Base
|
293
|
+
MASK = 0xfffffff
|
294
|
+
|
295
|
+
def next_i
|
296
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x1b)
|
297
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x1b) while @reg > @max
|
298
|
+
@reg - 1
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
|
303
|
+
class LFSR::Pure::Size29 < LFSR::Base
|
304
|
+
MASK = 0x1fffffff
|
305
|
+
|
306
|
+
def next_i
|
307
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[4]) << 0x1c)
|
308
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[4]) << 0x1c) while @reg > @max
|
309
|
+
@reg - 1
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
|
314
|
+
class LFSR::Pure::Size30 < LFSR::Base
|
315
|
+
MASK = 0x3fffffff
|
316
|
+
|
317
|
+
def next_i
|
318
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x1d)
|
319
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x1d) while @reg > @max
|
320
|
+
@reg - 1
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
class LFSR::Pure::Size31 < LFSR::Base
|
326
|
+
MASK = 0x7fffffff
|
327
|
+
|
328
|
+
def next_i
|
329
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x1e)
|
330
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x1e) while @reg > @max
|
331
|
+
@reg - 1
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
|
336
|
+
class LFSR::Pure::Size32 < LFSR::Base
|
337
|
+
MASK = 0xffffffff
|
338
|
+
|
339
|
+
def next_i
|
340
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[6]^@reg[7]) << 0x1f)
|
341
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[6]^@reg[7]) << 0x1f) while @reg > @max
|
342
|
+
@reg - 1
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
|
347
|
+
class LFSR::Pure::Size33 < LFSR::Base
|
348
|
+
MASK = 0x1ffffffff
|
349
|
+
|
350
|
+
def next_i
|
351
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x20)
|
352
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x20) while @reg > @max
|
353
|
+
@reg - 1
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
|
358
|
+
class LFSR::Pure::Size34 < LFSR::Base
|
359
|
+
MASK = 0x3ffffffff
|
360
|
+
|
361
|
+
def next_i
|
362
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[4]^@reg[8]) << 0x21)
|
363
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[4]^@reg[8]) << 0x21) while @reg > @max
|
364
|
+
@reg - 1
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
|
369
|
+
class LFSR::Pure::Size35 < LFSR::Base
|
370
|
+
MASK = 0x7ffffffff
|
371
|
+
|
372
|
+
def next_i
|
373
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[7]^@reg[8]) << 0x22)
|
374
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[7]^@reg[8]) << 0x22) while @reg > @max
|
375
|
+
@reg - 1
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
|
380
|
+
class LFSR::Pure::Size36 < LFSR::Base
|
381
|
+
MASK = 0xfffffffff
|
382
|
+
|
383
|
+
def next_i
|
384
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[7]^@reg[8]) << 0x23)
|
385
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[7]^@reg[8]) << 0x23) while @reg > @max
|
386
|
+
@reg - 1
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
|
391
|
+
class LFSR::Pure::Size37 < LFSR::Base
|
392
|
+
MASK = 0x1fffffffff
|
393
|
+
|
394
|
+
def next_i
|
395
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x24)
|
396
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[6]) << 0x24) while @reg > @max
|
397
|
+
@reg - 1
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
|
402
|
+
class LFSR::Pure::Size38 < LFSR::Base
|
403
|
+
MASK = 0x3fffffffff
|
404
|
+
|
405
|
+
def next_i
|
406
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[5]^@reg[6]) << 0x25)
|
407
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[5]^@reg[6]) << 0x25) while @reg > @max
|
408
|
+
@reg - 1
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
|
413
|
+
class LFSR::Pure::Size39 < LFSR::Base
|
414
|
+
MASK = 0x7fffffffff
|
415
|
+
|
416
|
+
def next_i
|
417
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[7]) << 0x26)
|
418
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[7]) << 0x26) while @reg > @max
|
419
|
+
@reg - 1
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
class LFSR::Pure::Size40 < LFSR::Base
|
425
|
+
MASK = 0xffffffffff
|
426
|
+
|
427
|
+
def next_i
|
428
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[4]^@reg[5]) << 0x27)
|
429
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[4]^@reg[5]) << 0x27) while @reg > @max
|
430
|
+
@reg - 1
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
|
435
|
+
class LFSR::Pure::Size41 < LFSR::Base
|
436
|
+
MASK = 0x1ffffffffff
|
437
|
+
|
438
|
+
def next_i
|
439
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x28)
|
440
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[3]) << 0x28) while @reg > @max
|
441
|
+
@reg - 1
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
|
446
|
+
class LFSR::Pure::Size42 < LFSR::Base
|
447
|
+
MASK = 0x3ffffffffff
|
448
|
+
|
449
|
+
def next_i
|
450
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[5]^@reg[7]) << 0x29)
|
451
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[5]^@reg[7]) << 0x29) while @reg > @max
|
452
|
+
@reg - 1
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
|
457
|
+
class LFSR::Pure::Size43 < LFSR::Base
|
458
|
+
MASK = 0x7ffffffffff
|
459
|
+
|
460
|
+
def next_i
|
461
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[5]^@reg[6]) << 0x2a)
|
462
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[5]^@reg[6]) << 0x2a) while @reg > @max
|
463
|
+
@reg - 1
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
|
468
|
+
class LFSR::Pure::Size44 < LFSR::Base
|
469
|
+
MASK = 0xfffffffffff
|
470
|
+
|
471
|
+
def next_i
|
472
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[5]^@reg[6]) << 0x2b)
|
473
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[5]^@reg[6]) << 0x2b) while @reg > @max
|
474
|
+
@reg - 1
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
|
479
|
+
class LFSR::Pure::Size45 < LFSR::Base
|
480
|
+
MASK = 0x1fffffffffff
|
481
|
+
|
482
|
+
def next_i
|
483
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x2c)
|
484
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[4]) << 0x2c) while @reg > @max
|
485
|
+
@reg - 1
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
|
490
|
+
class LFSR::Pure::Size46 < LFSR::Base
|
491
|
+
MASK = 0x3fffffffffff
|
492
|
+
|
493
|
+
def next_i
|
494
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[6]^@reg[7]^@reg[8]) << 0x2d)
|
495
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[6]^@reg[7]^@reg[8]) << 0x2d) while @reg > @max
|
496
|
+
@reg - 1
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
|
501
|
+
class LFSR::Pure::Size47 < LFSR::Base
|
502
|
+
MASK = 0x7fffffffffff
|
503
|
+
|
504
|
+
def next_i
|
505
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[5]) << 0x2e)
|
506
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[4]^@reg[5]) << 0x2e) while @reg > @max
|
507
|
+
@reg - 1
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
|
512
|
+
class LFSR::Pure::Size48 < LFSR::Base
|
513
|
+
MASK = 0xffffffffffff
|
514
|
+
|
515
|
+
def next_i
|
516
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[4]^@reg[7]^@reg[9]) << 0x2f)
|
517
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[4]^@reg[7]^@reg[9]) << 0x2f) while @reg > @max
|
518
|
+
@reg - 1
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
|
523
|
+
class LFSR::Pure::Size49 < LFSR::Base
|
524
|
+
MASK = 0x1ffffffffffff
|
525
|
+
|
526
|
+
def next_i
|
527
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[4]^@reg[5]^@reg[6]) << 0x30)
|
528
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[4]^@reg[5]^@reg[6]) << 0x30) while @reg > @max
|
529
|
+
@reg - 1
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
|
534
|
+
class LFSR::Pure::Size50 < LFSR::Base
|
535
|
+
MASK = 0x3ffffffffffff
|
536
|
+
|
537
|
+
def next_i
|
538
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[4]) << 0x31)
|
539
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[4]) << 0x31) while @reg > @max
|
540
|
+
@reg - 1
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
|
545
|
+
class LFSR::Pure::Size51 < LFSR::Base
|
546
|
+
MASK = 0x7ffffffffffff
|
547
|
+
|
548
|
+
def next_i
|
549
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[6]) << 0x32)
|
550
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[6]) << 0x32) while @reg > @max
|
551
|
+
@reg - 1
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
|
556
|
+
class LFSR::Pure::Size52 < LFSR::Base
|
557
|
+
MASK = 0xfffffffffffff
|
558
|
+
|
559
|
+
def next_i
|
560
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[6]) << 0x33)
|
561
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[3]^@reg[6]) << 0x33) while @reg > @max
|
562
|
+
@reg - 1
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
|
567
|
+
class LFSR::Pure::Size53 < LFSR::Base
|
568
|
+
MASK = 0x1fffffffffffff
|
569
|
+
|
570
|
+
def next_i
|
571
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[6]) << 0x34)
|
572
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[6]) << 0x34) while @reg > @max
|
573
|
+
@reg - 1
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
|
578
|
+
class LFSR::Pure::Size54 < LFSR::Base
|
579
|
+
MASK = 0x3fffffffffffff
|
580
|
+
|
581
|
+
def next_i
|
582
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[6]^@reg[8]) << 0x35)
|
583
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[3]^@reg[6]^@reg[8]) << 0x35) while @reg > @max
|
584
|
+
@reg - 1
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
|
589
|
+
class LFSR::Pure::Size55 < LFSR::Base
|
590
|
+
MASK = 0x7fffffffffffff
|
591
|
+
|
592
|
+
def next_i
|
593
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[6]) << 0x36)
|
594
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[6]) << 0x36) while @reg > @max
|
595
|
+
@reg - 1
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
|
600
|
+
class LFSR::Pure::Size56 < LFSR::Base
|
601
|
+
MASK = 0xffffffffffffff
|
602
|
+
|
603
|
+
def next_i
|
604
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[4]^@reg[7]) << 0x37)
|
605
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[4]^@reg[7]) << 0x37) while @reg > @max
|
606
|
+
@reg - 1
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
|
611
|
+
class LFSR::Pure::Size57 < LFSR::Base
|
612
|
+
MASK = 0x1ffffffffffffff
|
613
|
+
|
614
|
+
def next_i
|
615
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[5]) << 0x38)
|
616
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[3]^@reg[5]) << 0x38) while @reg > @max
|
617
|
+
@reg - 1
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
621
|
+
|
622
|
+
class LFSR::Pure::Size58 < LFSR::Base
|
623
|
+
MASK = 0x3ffffffffffffff
|
624
|
+
|
625
|
+
def next_i
|
626
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[5]^@reg[6]) << 0x39)
|
627
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[5]^@reg[6]) << 0x39) while @reg > @max
|
628
|
+
@reg - 1
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
|
633
|
+
class LFSR::Pure::Size59 < LFSR::Base
|
634
|
+
MASK = 0x7ffffffffffffff
|
635
|
+
|
636
|
+
def next_i
|
637
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[4]^@reg[7]) << 0x3a)
|
638
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[4]^@reg[7]) << 0x3a) while @reg > @max
|
639
|
+
@reg - 1
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
|
644
|
+
class LFSR::Pure::Size60 < LFSR::Base
|
645
|
+
MASK = 0xfffffffffffffff
|
646
|
+
|
647
|
+
def next_i
|
648
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[4]^@reg[5]) << 0x3b)
|
649
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[2]^@reg[4]^@reg[5]) << 0x3b) while @reg > @max
|
650
|
+
@reg - 1
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
|
655
|
+
class LFSR::Pure::Size61 < LFSR::Base
|
656
|
+
MASK = 0x1fffffffffffffff
|
657
|
+
|
658
|
+
def next_i
|
659
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x3c)
|
660
|
+
@reg = (@reg >> 1) | ((@reg[0]^@reg[1]^@reg[2]^@reg[5]) << 0x3c) while @reg > @max
|
661
|
+
@reg - 1
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
LFSR.default_to(LFSR::Pure)
|