root / gnuradio-core / src / lib / general / gri_glfsr.cc @ d65ae424
History | View | Annotate | Download (2.4 kB)
| 1 | a39870d9 | jcorgan | /* -*- c++ -*- */
|
|---|---|---|---|
| 2 | a39870d9 | jcorgan | /*
|
| 3 | a39870d9 | jcorgan | * Copyright 2007 Free Software Foundation, Inc. |
| 4 | a39870d9 | jcorgan | * |
| 5 | a39870d9 | jcorgan | * This file is part of GNU Radio |
| 6 | a39870d9 | jcorgan | * |
| 7 | a39870d9 | jcorgan | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | a39870d9 | jcorgan | * it under the terms of the GNU General Public License as published by |
| 9 | 937b719d | eb | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | a39870d9 | jcorgan | * any later version. |
| 11 | a39870d9 | jcorgan | * |
| 12 | a39870d9 | jcorgan | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | a39870d9 | jcorgan | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | a39870d9 | jcorgan | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | a39870d9 | jcorgan | * GNU General Public License for more details. |
| 16 | a39870d9 | jcorgan | * |
| 17 | a39870d9 | jcorgan | * You should have received a copy of the GNU General Public License |
| 18 | a39870d9 | jcorgan | * along with GNU Radio; see the file COPYING. If not, write to |
| 19 | a39870d9 | jcorgan | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | a39870d9 | jcorgan | * Boston, MA 02110-1301, USA. |
| 21 | a39870d9 | jcorgan | */ |
| 22 | a39870d9 | jcorgan | |
| 23 | a39870d9 | jcorgan | #include <gri_glfsr.h> |
| 24 | a39870d9 | jcorgan | #include <stdexcept> |
| 25 | a39870d9 | jcorgan | |
| 26 | a39870d9 | jcorgan | static int s_polynomial_masks[] = { |
| 27 | a39870d9 | jcorgan | 0x00000000,
|
| 28 | a39870d9 | jcorgan | 0x00000001, // x^1 + 1 |
| 29 | a39870d9 | jcorgan | 0x00000003, // x^2 + x^1 + 1 |
| 30 | a39870d9 | jcorgan | 0x00000005, // x^3 + x^1 + 1 |
| 31 | a39870d9 | jcorgan | 0x00000009, // x^4 + x^1 + 1 |
| 32 | a39870d9 | jcorgan | 0x00000012, // x^5 + x^2 + 1 |
| 33 | a39870d9 | jcorgan | 0x00000021, // x^6 + x^1 + 1 |
| 34 | a39870d9 | jcorgan | 0x00000041, // x^7 + x^1 + 1 |
| 35 | a39870d9 | jcorgan | 0x0000008E, // x^8 + x^4 + x^3 + x^2 + 1 |
| 36 | a39870d9 | jcorgan | 0x00000108, // x^9 + x^4 + 1 |
| 37 | a39870d9 | jcorgan | 0x00000204, // x^10 + x^4 + 1 |
| 38 | a39870d9 | jcorgan | 0x00000402, // x^11 + x^2 + 1 |
| 39 | a39870d9 | jcorgan | 0x00000829, // x^12 + x^6 + x^4 + x^1 + 1 |
| 40 | a39870d9 | jcorgan | 0x0000100D, // x^13 + x^4 + x^3 + x^1 + 1 |
| 41 | a39870d9 | jcorgan | 0x00002015, // x^14 + x^5 + x^3 + x^1 + 1 |
| 42 | a39870d9 | jcorgan | 0x00004001, // x^15 + x^1 + 1 |
| 43 | a39870d9 | jcorgan | 0x00008016, // x^16 + x^5 + x^3 + x^2 + 1 |
| 44 | a39870d9 | jcorgan | 0x00010004, // x^17 + x^3 + 1 |
| 45 | a39870d9 | jcorgan | 0x00020013, // x^18 + x^5 + x^2 + x^1 + 1 |
| 46 | a39870d9 | jcorgan | 0x00040013, // x^19 + x^5 + x^2 + x^1 + 1 |
| 47 | a39870d9 | jcorgan | 0x00080004, // x^20 + x^3 + 1 |
| 48 | a39870d9 | jcorgan | 0x00100002, // x^21 + x^2 + 1 |
| 49 | a39870d9 | jcorgan | 0x00200001, // x^22 + x^1 + 1 |
| 50 | a39870d9 | jcorgan | 0x00400010, // x^23 + x^5 + 1 |
| 51 | a39870d9 | jcorgan | 0x0080000D, // x^24 + x^4 + x^3 + x^1 + 1 |
| 52 | a39870d9 | jcorgan | 0x01000004, // x^25 + x^3 + 1 |
| 53 | a39870d9 | jcorgan | 0x02000023, // x^26 + x^6 + x^2 + x^1 + 1 |
| 54 | a39870d9 | jcorgan | 0x04000013, // x^27 + x^5 + x^2 + x^1 + 1 |
| 55 | a39870d9 | jcorgan | 0x08000004, // x^28 + x^3 + 1 |
| 56 | a39870d9 | jcorgan | 0x10000002, // x^29 + x^2 + 1 |
| 57 | a39870d9 | jcorgan | 0x20000029, // x^30 + x^4 + x^1 + 1 |
| 58 | a39870d9 | jcorgan | 0x40000004, // x^31 + x^3 + 1 |
| 59 | a39870d9 | jcorgan | 0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1 |
| 60 | a39870d9 | jcorgan | }; |
| 61 | a39870d9 | jcorgan | |
| 62 | a39870d9 | jcorgan | int gri_glfsr::glfsr_mask(int degree) |
| 63 | a39870d9 | jcorgan | {
|
| 64 | a39870d9 | jcorgan | if (degree < 1 || degree > 32) |
| 65 | a39870d9 | jcorgan | throw std::runtime_error("gri_glfsr::glfsr_mask(): degree must be between 1 and 32 inclusive"); |
| 66 | a39870d9 | jcorgan | return s_polynomial_masks[degree];
|
| 67 | a39870d9 | jcorgan | } |