mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-09 00:13:41 +00:00
partial eye diagram implementation
This commit is contained in:
parent
9a198217b8
commit
c7a99af820
17 changed files with 7404 additions and 25 deletions
43
Software/PC_Application/LibreVNA-GUI/Util/prbs.cpp
Normal file
43
Software/PC_Application/LibreVNA-GUI/Util/prbs.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include "prbs.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
PRBS::PRBS(unsigned int bits)
|
||||
{
|
||||
this->bits = bits;
|
||||
|
||||
// from https://www.eetimes.com/tutorial-linear-feedback-shift-registers-lfsrs-part-1/
|
||||
const std::array<unsigned int, 12> polynoms = {{
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000003,
|
||||
0x00000005,
|
||||
0x00000009,
|
||||
0x00000012,
|
||||
0x00000021,
|
||||
0x00000041,
|
||||
0x0000008E,
|
||||
0x00000108,
|
||||
0x00000204,
|
||||
0x00000402,
|
||||
}};
|
||||
if(bits < 2 || bits >= polynoms.size()) {
|
||||
throw std::runtime_error("Bit size not supported");
|
||||
}
|
||||
polynom = polynoms[bits];
|
||||
shiftReg = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
bool PRBS::next()
|
||||
{
|
||||
bool newbit = false;
|
||||
unsigned int mask = 0x01;
|
||||
for(unsigned int i=0;i<bits;i++) {
|
||||
if(polynom & mask & shiftReg) {
|
||||
newbit = !newbit;
|
||||
}
|
||||
mask <<= 1;
|
||||
}
|
||||
shiftReg = (shiftReg << 1) | (newbit ? 0x01 : 0x00);
|
||||
return newbit;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue