From: Luke Kenneth Casson Leighton Date: Fri, 31 Dec 2021 21:22:33 +0000 (+0000) Subject: add microwatt-verilator.cpp local-memory-writer which seems to work X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d39213257ee364090cd07eb0e2fee2ed7940ce91;p=microwatt.git add microwatt-verilator.cpp local-memory-writer which seems to work discrepancies which used to show up after bram reads are no longer there --- diff --git a/verilator/microwatt-verilator.cpp b/verilator/microwatt-verilator.cpp index 46df43a..e62962f 100644 --- a/verilator/microwatt-verilator.cpp +++ b/verilator/microwatt-verilator.cpp @@ -63,6 +63,20 @@ static void ascii_dump(unsigned char *data, int len, FILE *dump) putc('\n', dump); } +// 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, + int bram_sel) +{ + unsigned char *mat = &(mem[bram_addr*8]); // 64-bit (8 byte) wide + unsigned char *data_in = (unsigned char*)&bram_di; // treat as bytes + for (int i = 0; i < 8; i++) { + if (bram_sel & (1<uart0_rxd = uart_rx(); if (top->bram_we) { + mem_write(mem, top->bram_addr, top->bram_di, top->bram_sel); fprintf(dump, "bram wr addr %08x dout %16lx sel %x ", top->bram_addr, top->bram_di, top->bram_sel); ascii_dump((unsigned char*)&top->bram_di, 8, dump);