2019-02-21 13:20:55 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
2019-02-22 09:18:41 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2019-02-21 13:20:55 +00:00
|
|
|
|
2019-02-22 03:43:39 +00:00
|
|
|
uint32_t xorshift32(uint32_t x)
|
|
|
|
{
|
|
|
|
/* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */
|
|
|
|
x = x ^ (x << 13);
|
|
|
|
x = x ^ (x >> 17);
|
|
|
|
x = x ^ (x << 5);
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t get_rand(uint32_t x) {
|
|
|
|
uint32_t out = 0;
|
2019-02-21 13:20:55 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < 32; i++) {
|
2019-02-22 03:43:39 +00:00
|
|
|
x = xorshift32(x);
|
|
|
|
if ((x & 1) == 1)
|
|
|
|
out = out | (1<< i);
|
2019-02-21 13:20:55 +00:00
|
|
|
}
|
2019-02-22 03:43:39 +00:00
|
|
|
return out;
|
2019-02-21 13:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
int i;
|
|
|
|
|
2019-02-22 09:18:41 +00:00
|
|
|
int fd = open("rom.bin", O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
2019-02-22 03:43:39 +00:00
|
|
|
uint32_t init = 1;
|
|
|
|
for (i = 0; i < 2048; i++) {
|
|
|
|
init = get_rand(init);
|
2019-02-22 09:18:41 +00:00
|
|
|
// printf("%08x\n", init);
|
|
|
|
write(fd, &init, sizeof(init));
|
2019-02-21 13:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|