+# merge conflict at
+
GHDL ?= ghdl
GHDLFLAGS=--std=08
CFLAGS=-O3 -Wall
$(VERILATOR) $(VERILATOR_FLAGS) -CFLAGS "$(VERILATOR_CFLAGS) -DCLK_FREQUENCY=$(CLK_FREQUENCY)" -Iuart16550 --assert --cc --exe --build $^ -o $@ -top-module toplevel
@cp -f obj_dir/microwatt-verilator microwatt-verilator
+
+#MEMORY_SIZE=16777216 # 268435456
+#RAM_INIT_FILE=dtbImage.microwatt.hex
+SIM_MAIN_BRAM=true
+
# 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
library work;
use work.wishbone_types.all;
+use work.utils.all;
entity toplevel is
generic (
MEMORY_SIZE : positive := (384*1024);
RAM_INIT_FILE : string := "firmware.hex";
RESET_LOW : boolean := true;
+ SIM_MAIN_BRAM : boolean := false;
CLK_INPUT : positive := 100000000;
CLK_FREQUENCY : positive := 100000000;
HAS_FPU : boolean := true;
-- UART0 signals:
uart0_txd : out std_ulogic;
- uart0_rxd : in std_ulogic
+ uart0_rxd : in std_ulogic;
+
+ -- BRAM verilator access
+ 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_sel : out std_logic_vector(7 downto 0)
);
end entity toplevel;
soc0: entity work.soc
generic map(
MEMORY_SIZE => MEMORY_SIZE,
+ SIM_MAIN_BRAM => SIM_MAIN_BRAM,
RAM_INIT_FILE => RAM_INIT_FILE,
SIM => false,
CLK_FREQ => CLK_FREQUENCY,
system_clk => system_clk,
rst => soc_rst,
uart0_txd => uart0_txd,
- uart0_rxd => uart0_rxd
+ uart0_rxd => uart0_rxd,
+ bram_we => bram_we,
+ bram_re => bram_re,
+ bram_addr => bram_addr,
+ bram_di => bram_di,
+ bram_do => bram_do,
+ bram_sel => bram_sel
);
end architecture behaviour;
library work;
use work.common.all;
+use work.utils.all;
use work.wishbone_types.all;
DISABLE_FLATTEN_CORE : boolean := false;
ALT_RESET_ADDRESS : std_logic_vector(63 downto 0) := (23 downto 0 => '0', others => '1');
HAS_DRAM : boolean := false;
+ SIM_MAIN_BRAM : boolean := false;
DRAM_SIZE : integer := 0;
DRAM_INIT_SIZE : integer := 0;
HAS_SPI_FLASH : boolean := false;
ext_irq_eth : in std_ulogic := '0';
ext_irq_sdcard : in std_ulogic := '0';
+ -- BRAM verilator access
+ 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_sel : out std_logic_vector(7 downto 0);
+
-- UART0 signals:
uart0_txd : out std_ulogic;
uart0_rxd : in std_ulogic := '0';
bram0: entity work.wishbone_bram_wrapper
generic map(
MEMORY_SIZE => MEMORY_SIZE,
- RAM_INIT_FILE => RAM_INIT_FILE
+ RAM_INIT_FILE => RAM_INIT_FILE,
+ SIM_MAIN_BRAM => SIM_MAIN_BRAM
)
port map(
clk => system_clk,
rst => rst_bram,
wishbone_in => wb_bram_in,
- wishbone_out => wb_bram_out
+ wishbone_out => wb_bram_out,
+ bram_we => bram_we,
+ bram_re => bram_re,
+ bram_addr => bram_addr,
+ bram_di => bram_di,
+ bram_do => bram_do,
+ bram_sel => bram_sel
);
end generate;
}
}
-#define BRAM_DEBUG
+//#define BRAM_DEBUG
+//GUESS: signals missing
// sigh yes, all these should be runtime commandline options
#define TRIGGER_ENABLE
tick(top, traceme);
// read/write the memory to/from the mmap'd file (if given)
+ #warning this us untested
if (mem != NULL) {
top->bram_do = bram_do;
if (top->bram_re ) {
mem_write(mem, top->bram_addr, top->bram_di, top->bram_sel);
}
}
-
+
uart_tx(top->uart0_txd);
top->uart0_rxd = uart_rx();
entity wishbone_bram_wrapper is
generic(
MEMORY_SIZE : natural := 4096; --! Memory size in bytes.
- RAM_INIT_FILE : string
+ RAM_INIT_FILE : string;
+ SIM_MAIN_BRAM : boolean := false
);
port(
clk : in std_logic;
-- Wishbone interface:
wishbone_in : in wishbone_master_out;
- wishbone_out : out wishbone_slave_out
+ wishbone_out : out wishbone_slave_out;
+
+ -- BRAM verilator access
+ 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_sel : out std_logic_vector(7 downto 0)
+
);
end entity wishbone_bram_wrapper;