--- /dev/null
+library ieee;
+use ieee.std_logic_1164.all;
+
+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;
+ PLL_RESET_BITS : positive := 18;
+ EXTERNAL_CORE : boolean := false;
+ SIM_MAIN_BRAM : boolean := false;
+ SIM_BRAM_CHAINBOOT : positive := 0;
+ CLK_INPUT : positive := 100000000;
+ CLK_FREQUENCY : positive := 100000000;
+ HAS_FPU : boolean := true;
+ HAS_BTC : boolean := false;
+ LOG_LENGTH : natural := 512;
+ DISABLE_FLATTEN_CORE : boolean := false;
+ UART_IS_16550 : boolean := true;
+ HAS_UART1 : boolean := false
+ );
+ port(
+ ext_clk : in std_ulogic;
+ ext_rst : in std_ulogic;
+
+ -- UART0 signals:
+ uart0_txd : out std_ulogic;
+ uart0_rxd : in std_ulogic
+ );
+end entity toplevel;
+
+architecture behaviour of toplevel is
+
+ -- Reset signals:
+ signal soc_rst : std_ulogic;
+ signal pll_rst : std_ulogic;
+
+ -- Internal clock signals:
+ signal system_clk : std_ulogic;
+ signal system_clk_locked : std_ulogic;
+
+ -- BRAM verilator access
+ signal no_bram_we : std_ulogic;
+ signal no_bram_re : std_ulogic;
+ signal no_bram_addr : std_logic_vector(log2ceil(MEMORY_SIZE) - 3- 1 downto 0);
+ signal no_bram_di : std_logic_vector(63 downto 0);
+ signal no_bram_do : std_logic_vector(63 downto 0);
+ signal no_bram_sel : std_logic_vector(7 downto 0);
+
+ -- for verilator debugging
+ signal no_nia_req: std_ulogic;
+ signal no_nia: std_ulogic_vector(63 downto 0);
+ signal no_msr_o: std_ulogic_vector(63 downto 0);
+ signal no_insn: std_ulogic_vector(31 downto 0);
+ signal no_ldst_req: std_ulogic;
+ signal no_ldst_addr: std_ulogic_vector(63 downto 0);
+
+begin
+
+ reset_controller: entity work.soc_reset
+ generic map(
+ RESET_LOW => RESET_LOW,
+ PLL_RESET_BITS => PLL_RESET_BITS
+ )
+ port map(
+ ext_clk => ext_clk,
+ pll_clk => system_clk,
+ pll_locked_in => system_clk_locked,
+ ext_rst_in => ext_rst,
+ pll_rst_out => pll_rst,
+ rst_out => soc_rst
+ );
+
+ clkgen: entity work.clock_generator
+ generic map(
+ CLK_INPUT_HZ => CLK_INPUT,
+ CLK_OUTPUT_HZ => CLK_FREQUENCY
+ )
+ port map(
+ ext_clk => ext_clk,
+ pll_rst_in => pll_rst,
+ pll_clk_out => system_clk,
+ pll_locked_out => system_clk_locked
+ );
+
+ -- Main SoC
+ soc0: entity work.soc
+ generic map(
+ MEMORY_SIZE => MEMORY_SIZE,
+ SIM_BRAM_CHAINBOOT => SIM_BRAM_CHAINBOOT,
+ SIM_MAIN_BRAM => SIM_MAIN_BRAM,
+ EXTERNAL_CORE => EXTERNAL_CORE,
+ RAM_INIT_FILE => RAM_INIT_FILE,
+ SIM => false,
+ CLK_FREQ => CLK_FREQUENCY,
+ HAS_FPU => HAS_FPU,
+ HAS_BTC => HAS_BTC,
+ LOG_LENGTH => LOG_LENGTH,
+ DISABLE_FLATTEN_CORE => DISABLE_FLATTEN_CORE,
+ UART0_IS_16550 => UART_IS_16550,
+ HAS_UART1 => HAS_UART1
+ )
+ port map (
+ system_clk => system_clk,
+ rst => soc_rst,
+ uart0_txd => uart0_txd,
+ uart0_rxd => uart0_rxd,
+ bram_we => no_bram_we,
+ bram_re => no_bram_re,
+ bram_addr => no_bram_addr,
+ bram_di => no_bram_di,
+ bram_do => no_bram_do,
+ bram_sel => no_bram_sel,
+ nia_req => no_nia_req,
+ nia => no_nia,
+ msr_o => no_msr_o,
+ insn => no_insn,
+ ldst_req => no_ldst_req,
+ ldst_addr => no_ldst_addr
+ );
+
+end architecture behaviour;