17 #ifndef __NVHLS_RAND__ 18 #define __NVHLS_RAND__ 20 #include <nvhls_int.h> 21 #include <nvhls_types.h> 22 #include <mem_array.h> 23 #include <TypeToBits.h> 62 unsigned int seed = time(NULL);
66 const char* env_rand_seed = std::getenv(
"RAND_SEED");
67 if (env_rand_seed != NULL) seed = atoi(env_rand_seed);
69 cout <<
"================================" << endl;
70 cout << dec <<
"SETTING RANDOM SEED = " << seed << endl;
71 cout <<
"================================" << endl;
93 template <
typename Payload>
96 NVUINTW(Payload::width) random = rand();
97 int num = Payload::width/32 + 1;
98 for (
int i = 0; i < num; i++) {
99 random = (random << 32) + rand();
101 sc_lv<Payload::width> payload_lv = TypeToBits<NVUINTW(Payload::width) > (random);
102 payload = BitsToType<Payload> (payload_lv);
123 template <
int bitw
idth>
125 NVUINTW(bitwidth) random = rand();
126 int num = bitwidth/32 + 1;
127 for (
int i = 0; i < num; i++) {
128 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.