blob: b83e93dbad09f8a5d3890cde5c488b145873cb2a [file] [log] [blame]
Alexander Chemeris082bbbf2017-04-02 12:45:36 +02001/*
2 * Copyright (C) 2017 Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "PRBS.h"
20#include <iostream>
21#include <cstdlib>
22#include <assert.h>
23
24void testPrbs(PRBS &prbs, uint64_t expectedPeriod)
25{
26 uint64_t period = 0;
27 do {
28 std::cout << prbs.generateBit();
29 period++;
30 } while (!prbs.isFinished());
31 std::cout << std::endl;
32 std::cout << "Period: " << period << std::endl;
33 assert(period == expectedPeriod);
34}
35
36int main(int argc, char *argv[])
37{
38 PRBS9 prbs9(0x01);
39 testPrbs(prbs9, (1<<9)-1);
40 PRBS15 prbs15(0x01);
41 testPrbs(prbs15, (1<<15)-1);
42}