17 #ifndef __NVHLS_RAND__
18 #define __NVHLS_RAND__
20 #include <nvhls_int.h>
21 #include <nvhls_types.h>
22 #include <TypeToBits.h>
61 unsigned int seed = 0;
62 #ifdef NVHLS_RAND_SEED
63 seed = (NVHLS_RAND_SEED);
65 const char* env_rand_seed = std::getenv(
"NVHLS_RAND_SEED");
66 if (env_rand_seed != NULL) seed = atoi(env_rand_seed);
68 cout <<
"================================" << endl;
69 cout << dec <<
"SETTING RANDOM SEED = " << seed << endl;
70 cout <<
"================================" << endl;
92 template <
typename Payload>
95 NVUINTW(Payload::width) random = rand();
96 int num = Payload::width/32 + 1;
97 for (
int i = 0; i < num; i++) {
98 random = (random << 32) + rand();
100 sc_lv<Payload::width> payload_lv = TypeToBits<NVUINTW(Payload::width) > (random);
101 payload = BitsToType<Payload> (payload_lv);
122 template <
int bitw
idth>
124 NVUINTW(bitwidth) random = rand();
125 int num = bitwidth/32 + 1;
126 for (
int i = 0; i < num; i++) {
127 random = (random << 32) + rand();
NVUINTW(Wrapped< T >::width) TypeToNVUINT(T in)
Convert Type to NVUINT.
Payload gen_random_payload()
Generate Random payload of any type.
int set_random_seed()
Set random seed.