Line 104... |
Line 104... |
while (1) {
|
while (1) {
|
|
|
int u = 0, cell = 0, n = 0;
|
int u = 0, cell = 0, n = 0;
|
int x, y;
|
int x, y;
|
int trng_available = 0;
|
int trng_available = 0;
|
uint16_t trng_data;
|
uint8_t trng_data;
|
|
|
|
|
// initialize universe
|
// initialize universe
|
uint32_t generation = 0;
|
uint32_t generation = 0;
|
clear_universe(0);
|
clear_universe(0);
|
Line 121... |
Line 121... |
neorv32_uart_printf("You can pause/restart the simulation by pressing any key.\n");
|
neorv32_uart_printf("You can pause/restart the simulation by pressing any key.\n");
|
|
|
|
|
// check if TRNG was synthesized
|
// check if TRNG was synthesized
|
if (neorv32_trng_available()) {
|
if (neorv32_trng_available()) {
|
uint16_t trng_tap_config = neorv32_trng_find_tap_mask();
|
neorv32_uart_printf("\nTRNG detected. Using TRNG for universe initialization.\n");
|
neorv32_trng_setup(trng_tap_config);
|
neorv32_trng_enable();
|
neorv32_uart_printf("\nTRNG detected (tap mask 0x%x). Using TRNG for universe initialization.\n", (uint32_t)trng_tap_config);
|
|
trng_available = 1;
|
trng_available = 1;
|
}
|
}
|
|
|
|
|
// randomize until key pressed
|
// randomize until key pressed
|
Line 138... |
Line 137... |
|
|
// initialize universe using random data
|
// initialize universe using random data
|
for (x=0; x<NUM_CELLS_X/8; x++) {
|
for (x=0; x<NUM_CELLS_X/8; x++) {
|
for (y=0; y<NUM_CELLS_Y; y++) {
|
for (y=0; y<NUM_CELLS_Y; y++) {
|
if (trng_available) {
|
if (trng_available) {
|
if (neorv32_trng_get(&trng_data)) {
|
while (1) {
|
neorv32_uart_printf("TRNG error!\n");
|
int err = neorv32_trng_get(&trng_data);
|
return 1;
|
if (err) {
|
|
neorv32_uart_printf("TRNG error (%i)! Restarting TRNG...\n", err);
|
|
continue;
|
|
}
|
|
else {
|
|
break;
|
|
}
|
}
|
}
|
universe[0][x][y] = (uint8_t)trng_data; // use data from TRNG
|
universe[0][x][y] = trng_data; // use data from TRNG
|
}
|
}
|
else {
|
else {
|
universe[0][x][y] = (uint8_t)xorshift32(); // use data from PRNG
|
universe[0][x][y] = (uint8_t)xorshift32(); // use data from PRNG
|
}
|
}
|
}
|
}
|