libatomprobe
Library for Atom Probe Tomography (APT) computation
lfsr.h
Go to the documentation of this file.
1 /*
2  * helper/maths/lfsr.h - Linear shift feedback register
3  * Copyright (C) 2015, D Haley
4 
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include <cstdlib>
20 
21 namespace AtomProbe
22 {
23 
25 
31 {
32  size_t lfsr;
33  size_t maskVal;
34  size_t totalMask;
35  public:
37  size_t clock();
39  void setState(size_t newState) { lfsr=newState;};
41  void setMaskPeriod(unsigned int newMask);
42 
44  bool verifyTable(size_t maxLen=0);
45 };
46 }
This class implements a Linear Feedback Shift Register (in software)
Definition: lfsr.h:30
void setState(size_t newState)
Set the internal lfsr state. Note 0 is the lock-up state.
Definition: lfsr.h:39
void setMaskPeriod(unsigned int newMask)
Set the mask to use such that the period is 2^n-1. 3 is minimum 60 is maximum.
Definition: lfsr.cpp:98
size_t clock()
Get a value from the shift register, and advance.
Definition: lfsr.cpp:152
bool verifyTable(size_t maxLen=0)
Check the validity of the table.
Definition: lfsr.cpp:113