# Need to investigate why yosys is hitting verilator warnings, and eventually turn on -Wall
# --top-module toplevel
microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uart-verilator.c
- verilator -O3 -CFLAGS "-DCLK_FREQUENCY=$(CLK_FREQUENCY)" --assert --cc microwatt.v --exe verilator/microwatt-verilator.cpp verilator/uart-verilator.c -o $@ -Iuart16550 \
+ verilator -O3 -CFLAGS "-DCLK_FREQUENCY=$(CLK_FREQUENCY)" \
+ --assert \
+ --cc microwatt.v \
+ --exe verilator/microwatt-verilator.cpp verilator/uart-verilator.c \
+ -o $@ -Iuart16550 \
-Wno-fatal -Wno-CASEOVERLAP -Wno-UNOPTFLAT \
-Wno-BLKANDNBLK \
-Wno-COMBDLY \
-Wno-CASEINCOMPLETE \
-Wno-WIDTH \
- # --trace \
+ --savable \
+ --trace \
# --unroll-count 256 \
# --output-split 5000 \
# --output-split-cfuncs 500 \
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <time.h>
#include "Vmicrowatt.h"
#include "verilated.h"
#include "verilated_vcd_c.h"
putc('\n', dump);
}
+// save/restore of verilator model to/from file.
+void save_model(const char* filenamep, Vmicrowatt* topp)
+{
+ VerilatedSave os;
+ os.open(filenamep);
+ os << main_time; // user code must save the timestamp, etc
+ os << *topp;
+}
+
+void restore_model(const char* filenamep, Vmicrowatt* topp)
+{
+ VerilatedRestore os;
+ os.open(filenamep);
+ os >> main_time;
+ os >> *topp;
+}
+
+//save bram memory out to a file. use for snapshots
+int memdump(time_t time, unsigned char *mem, size_t sz)
+{
+ int fd = open("bram.snapshot.%ld", time, O_RDWR | O_CREAT, (mode_t)0600);
+ lseek(fd, sz, SEEK_SET);
+ write(fd, "", 1);
+ void *map = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ memcpy(map, mem, sz);
+ msync(map, sz, MS_SYNC);
+ munmap(map, sz);
+ close(fd);
+ return 0;
+}
+
// write (masked by sel) to internal mem offset by bram_addr line
static void mem_write(unsigned char *mem,
unsigned long bram_addr, unsigned long long bram_di,
if (trigger_occurrences == 1) {
traceme = true;
fprintf(dump, "trace trigger enabled\n");
- }
+ }
if (trigger_occurrences != 0) {
--trigger_occurrences;
}