GNU Radio Manual and C++ API Reference
3.9.1.0
The Free & Open Software Radio Ecosystem
lfsr_15_1_0.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2004 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* SPDX-License-Identifier: GPL-3.0-or-later
8
*
9
*/
10
11
#ifndef INCLUDED_GRI_LFSR_15_1_0_H
12
#define INCLUDED_GRI_LFSR_15_1_0_H
13
14
#include <
gnuradio/blocks/api.h
>
15
16
namespace
gr
{
17
namespace
blocks {
18
19
/*!
20
* \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1
21
* \ingroup misc
22
*
23
* \details
24
* Generates a maximal length pseudo-random sequence of length
25
* 2^15 - 1 bits.
26
*/
27
class
BLOCKS_API
lfsr_15_1_0
28
{
29
private
:
30
unsigned
long
d_sr;
// shift register
31
32
public
:
33
lfsr_15_1_0
() { reset(); }
34
35
void
reset
() { d_sr = 0x7fff; }
36
37
int
next_bit
()
38
{
39
d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1);
40
return
d_sr & 0x1;
41
}
42
43
int
next_byte
()
44
{
45
int
v
= 0;
46
for
(
int
i = 0; i < 8; i++) {
47
v
>>= 1;
48
if
(next_bit())
49
v
|= 0x80;
50
}
51
return
v
;
52
}
53
};
54
55
}
/* namespace blocks */
56
}
/* namespace gr */
57
58
#endif
/* INCLUDED_GRI_LFSR_15_1_0_H */
api.h
gr::blocks::lfsr_15_1_0::next_bit
int next_bit()
Definition:
lfsr_15_1_0.h:37
gr::blocks::lfsr_15_1_0
Linear Feedback Shift Register using primitive polynomial x^15 + x + 1.
Definition:
lfsr_15_1_0.h:27
gr::blocks::lfsr_15_1_0::lfsr_15_1_0
lfsr_15_1_0()
Definition:
lfsr_15_1_0.h:33
BLOCKS_API
#define BLOCKS_API
Definition:
gr-blocks/include/gnuradio/blocks/api.h:18
gr::blocks::lfsr_15_1_0::reset
void reset()
Definition:
lfsr_15_1_0.h:35
v
Definition:
cc_common.h:35
gr
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition:
basic_block.h:29
gr::blocks::lfsr_15_1_0::next_byte
int next_byte()
Definition:
lfsr_15_1_0.h:43
gr-blocks
include
gnuradio
blocks
lfsr_15_1_0.h
Generated by
1.8.17