mirror of https://github.com/YosysHQ/icestorm.git
Merge pull request #149 from tomverbeure/seed
icebram: add option to specify seed for repeatable outcomes.
This commit is contained in:
commit
bb0307a5ab
|
|
@ -94,7 +94,7 @@ void help(const char *cmd)
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Usage: %s [options] <from_hexfile> <to_hexfile>\n", cmd);
|
printf("Usage: %s [options] <from_hexfile> <to_hexfile>\n", cmd);
|
||||||
printf(" %s [options] -g <width> <depth>\n", cmd);
|
printf(" %s [options] -g [-s <seed>] <width> <depth>\n", cmd);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Replace BRAM initialization data in a .asc file. This can be used\n");
|
printf("Replace BRAM initialization data in a .asc file. This can be used\n");
|
||||||
printf("for example to replace firmware images without re-running synthesis\n");
|
printf("for example to replace firmware images without re-running synthesis\n");
|
||||||
|
|
@ -105,6 +105,9 @@ void help(const char *cmd)
|
||||||
printf(" use this to generate the hex file used during synthesis, then\n");
|
printf(" use this to generate the hex file used during synthesis, then\n");
|
||||||
printf(" use the same file as <from_hexfile> later.\n");
|
printf(" use the same file as <from_hexfile> later.\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
printf(" -s <seed>\n");
|
||||||
|
printf(" seed random generator with fixed value.\n");
|
||||||
|
printf("\n");
|
||||||
printf(" -v\n");
|
printf(" -v\n");
|
||||||
printf(" verbose output\n");
|
printf(" verbose output\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
@ -127,9 +130,11 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool generate = false;
|
bool generate = false;
|
||||||
|
bool seed = false;
|
||||||
|
uint32_t seed_nr = getpid();
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "vg")) != -1)
|
while ((opt = getopt(argc, argv, "vgs:")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
|
|
@ -139,6 +144,10 @@ int main(int argc, char **argv)
|
||||||
case 'g':
|
case 'g':
|
||||||
generate = true;
|
generate = true;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
seed = true;
|
||||||
|
seed_nr = atoi(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
help(argv[0]);
|
help(argv[0]);
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +171,10 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = uint64_t(getpid()) << 32;
|
if (verbose && seed)
|
||||||
|
fprintf(stderr, "Seed: %d\n", seed_nr);
|
||||||
|
|
||||||
|
x = uint64_t(seed_nr) << 32;
|
||||||
x ^= uint64_t(depth) << 16;
|
x ^= uint64_t(depth) << 16;
|
||||||
x ^= uint64_t(width) << 10;
|
x ^= uint64_t(width) << 10;
|
||||||
|
|
||||||
|
|
@ -170,10 +182,16 @@ int main(int argc, char **argv)
|
||||||
xorshift64star();
|
xorshift64star();
|
||||||
xorshift64star();
|
xorshift64star();
|
||||||
|
|
||||||
struct timeval tv;
|
if (!seed){
|
||||||
gettimeofday(&tv, NULL);
|
struct timeval tv;
|
||||||
x ^= uint64_t(tv.tv_sec) << 20;
|
gettimeofday(&tv, NULL);
|
||||||
x ^= uint64_t(tv.tv_usec);
|
x ^= uint64_t(tv.tv_sec) << 20;
|
||||||
|
x ^= uint64_t(tv.tv_usec);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x ^= uint64_t(seed) << 20;
|
||||||
|
x ^= uint64_t(seed);
|
||||||
|
}
|
||||||
|
|
||||||
xorshift64star();
|
xorshift64star();
|
||||||
xorshift64star();
|
xorshift64star();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue