blob: 800028843a2ed07a8b6447e6e1ad3e38b680d3a2 [file] [log] [blame]
Alexander Chemeris082bbbf2017-04-02 12:45:36 +02001/*
2 * Copyright (C) 2017 Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
3 *
Pau Espin Pedrol21d03d32019-07-22 12:05:52 +02004 * SPDX-License-Identifier: LGPL-2.1+
5 *
Alexander Chemeris082bbbf2017-04-02 12:45:36 +02006 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
Alexander Chemeris082bbbf2017-04-02 12:45:36 +020015 */
16
17#include "PRBS.h"
18#include <iostream>
19#include <cstdlib>
20#include <assert.h>
21
22void testPrbs(PRBS &prbs, uint64_t expectedPeriod)
23{
24 uint64_t period = 0;
25 do {
26 std::cout << prbs.generateBit();
27 period++;
28 } while (!prbs.isFinished());
29 std::cout << std::endl;
30 std::cout << "Period: " << period << std::endl;
31 assert(period == expectedPeriod);
32}
33
34int main(int argc, char *argv[])
35{
36 PRBS9 prbs9(0x01);
37 testPrbs(prbs9, (1<<9)-1);
38 PRBS15 prbs15(0x01);
39 testPrbs(prbs15, (1<<15)-1);
40}