# Linux
#MEMORY_SIZE=16777216 # 268435456
#RAM_INIT_FILE=dtbImage.microwatt.hex
-SIM_MAIN_BRAM=true
+SIM_MAIN_BRAM=false
FPGA_TARGET ?= ORANGE-CRAB
bram_we : out std_ulogic;
bram_re : out std_ulogic;
bram_addr : out std_logic_vector(log2ceil(MEMORY_SIZE) - 3- 1 downto 0);
- bram_di : inout std_logic_vector(63 downto 0);
- bram_do : out std_logic_vector(63 downto 0);
+ bram_di : out std_logic_vector(63 downto 0);
+ bram_do : in std_logic_vector(63 downto 0);
bram_sel : out std_logic_vector(7 downto 0)
);
end entity toplevel;
bram_we : out std_ulogic;
bram_re : out std_ulogic;
bram_addr : out std_logic_vector(log2ceil(MEMORY_SIZE) - 3- 1 downto 0);
- bram_di : inout std_logic_vector(63 downto 0);
- bram_do : out std_logic_vector(63 downto 0);
+ bram_di : out std_logic_vector(63 downto 0);
+ bram_do : in std_logic_vector(63 downto 0);
bram_sel : out std_logic_vector(7 downto 0);
-- UART0 signals:
}
}
+#define BRAM_DEBUG
+
int main(int argc, char **argv)
{
Verilated::commandArgs(argc, argv);
tick(top);
top->ext_rst = 1;
+ unsigned long long bram_do = 0;
+
while(!Verilated::gotFinish()) {
tick(top);
+ // read/write the memory to/from the mmap'd file (if given)
+ if (mem != NULL) {
+ top->bram_do = bram_do;
+ if (top->bram_re ) {
+ bram_do = ((unsigned long long*)mem)[top->bram_addr];
+ }
+ if (top->bram_we) {
+ mem_write(mem, top->bram_addr, top->bram_di, top->bram_sel);
+ }
+ }
+
uart_tx(top->uart0_txd);
top->uart0_rxd = uart_rx();
+#ifdef BRAM_DEBUG
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);
if (next_read) {
fprintf(dump, "bram rd addr %08x din %16lx sel %x ",
bram_addr, top->bram_do, top->bram_sel);
- if (bram_data1 != top->bram_do) { // check contents
+ if ((mem != NULL) && bram_data1 != top->bram_do) { // check contents
fprintf(dump, "bram != %16lx ", bram_data1 );
}
ascii_dump((unsigned char*)&top->bram_do, 8, dump);
if ((mem != NULL) && next_read) {
bram_data = ((unsigned long long*)mem)[bram_addr];
}
+#endif // BRAM_DEBUG
}
fclose(dump);
bram_we : out std_ulogic;
bram_re : out std_ulogic;
bram_addr : out std_logic_vector(log2ceil(MEMORY_SIZE) - 3- 1 downto 0);
- bram_di : inout std_logic_vector(63 downto 0);
- bram_do : out std_logic_vector(63 downto 0);
+ bram_di : out std_logic_vector(63 downto 0);
+ bram_do : in std_logic_vector(63 downto 0);
bram_sel : out std_logic_vector(7 downto 0)
);
-- Verilator access to bram signals
bram_sel <= wishbone_in.sel;
- bram_do <= wishbone_out.dat;
+ wishbone_out.dat <= bram_do;
bram_di <= wishbone_in.dat;
bram_addr <= ram_addr;
bram_we <= ram_we;