rndgen.cpp 490 Bytes
Newer Older
Andrei Tosa's avatar
Andrei Tosa committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "rndgen.hpp"

void rndgen(
		const unsigned int seed,
		const unsigned int count,
		stream<unsigned> &out
	)
{

	ap_uint<REG_SIZE> X, Y;
	X = seed;

	generator: for (int i = 0; i < count; i++) {
	#pragma HLS pipeline II=1

		for (int j = 1; j < REG_SIZE - 1; j++) {
		#pragma HLS unroll factor=30

			Y[j] = F(X[j - 1], X[j], X[j+1]);
		}

		Y[0] = F(X[REG_SIZE - 1], X[0], X[1]);
		Y[REG_SIZE - 1] = F(X[REG_SIZE - 2], X[REG_SIZE - 1], X[0]);

		out << Y.to_uint();
		X = Y;
	}
}