diff options
Diffstat (limited to 'icebram')
-rw-r--r-- | icebram/.gitignore | 2 | ||||
-rw-r--r-- | icebram/Makefile | 14 | ||||
-rw-r--r-- | icebram/icebram.cc | 26 |
3 files changed, 27 insertions, 15 deletions
diff --git a/icebram/.gitignore b/icebram/.gitignore index 10fbc8a..d329cf5 100644 --- a/icebram/.gitignore +++ b/icebram/.gitignore @@ -11,3 +11,5 @@ demo_tb.v icebram icebram.d icebram.o +icebram.exe +icebram.wasm diff --git a/icebram/Makefile b/icebram/Makefile index 34801da..219be59 100644 --- a/icebram/Makefile +++ b/icebram/Makefile @@ -4,24 +4,24 @@ ifeq ($(STATIC),1) LDFLAGS += -static endif -all: icebram$(EXE) +all: $(PROGRAM_PREFIX)icebram$(EXE) -icebram$(EXE): icebram.o +$(PROGRAM_PREFIX)icebram$(EXE): icebram.o $(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) -test: icebram +test: $(PROGRAM_PREFIX)icebram bash rundemo.sh install: all mkdir -p $(DESTDIR)$(PREFIX)/bin - cp icebram$(EXE) $(DESTDIR)$(PREFIX)/bin/icebram$(EXE) + cp $(PROGRAM_PREFIX)icebram$(EXE) $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)icebram$(EXE) uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/icebram$(EXE) + rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)icebram$(EXE) clean: - rm -f icebram$(EXE) - rm -f icebram.exe + rm -f $(PROGRAM_PREFIX)icebram$(EXE) + rm -f $(PROGRAM_PREFIX)icebram.exe rm -f demo.* demo_*.* rm -f *.o *.d diff --git a/icebram/icebram.cc b/icebram/icebram.cc index f585fcf..aacf00c 100644 --- a/icebram/icebram.cc +++ b/icebram/icebram.cc @@ -131,7 +131,7 @@ int main(int argc, char **argv) bool verbose = false; bool generate = false; bool seed = false; - uint32_t seed_nr = getpid(); + uint32_t seed_opt = 0; int opt; while ((opt = getopt(argc, argv, "vgs:")) != -1) @@ -146,7 +146,7 @@ int main(int argc, char **argv) break; case 's': seed = true; - seed_nr = atoi(optarg); + seed_opt = atoi(optarg); break; default: help(argv[0]); @@ -172,7 +172,21 @@ int main(int argc, char **argv) } if (verbose && seed) - fprintf(stderr, "Seed: %d\n", seed_nr); + fprintf(stderr, "Seed: %d\n", seed_opt); + + // If -s is provided: seed with the given value. + // If -s is not provided: seed with the PID and current time, which are unlikely + // to repeat simultaneously. + uint32_t seed_nr; + if (!seed) { +#if defined(__wasm) + seed_nr = 0; +#else + seed_nr = getpid(); +#endif + } else { + seed_nr = seed_opt; + } x = uint64_t(seed_nr) << 32; x ^= uint64_t(depth) << 16; @@ -182,16 +196,12 @@ int main(int argc, char **argv) xorshift64star(); xorshift64star(); - if (!seed){ + if (!seed) { struct timeval tv; gettimeofday(&tv, NULL); 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(); |