OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [core/] [neorv32_boot_rom.vhd] - Diff between revs 23 and 61

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 23 Rev 61
Line 40... Line 40...
use neorv32.neorv32_package.all;
use neorv32.neorv32_package.all;
use neorv32.neorv32_bootloader_image.all; -- this file is generated by the image generator
use neorv32.neorv32_bootloader_image.all; -- this file is generated by the image generator
 
 
entity neorv32_boot_rom is
entity neorv32_boot_rom is
  generic (
  generic (
    BOOTROM_BASE : std_ulogic_vector(31 downto 0) := x"FFFF0000"; -- boot ROM base address
    BOOTROM_BASE : std_ulogic_vector(31 downto 0) := x"FFFF0000" -- boot ROM base address
    BOOTROM_SIZE : natural := 4*1024  -- processor-internal boot ROM memory size in bytes
 
  );
  );
  port (
  port (
    clk_i  : in  std_ulogic; -- global clock line
    clk_i  : in  std_ulogic; -- global clock line
    rden_i : in  std_ulogic; -- read enable
    rden_i : in  std_ulogic; -- read enable
    addr_i : in  std_ulogic_vector(31 downto 0); -- address
    addr_i : in  std_ulogic_vector(31 downto 0); -- address
Line 54... Line 53...
  );
  );
end neorv32_boot_rom;
end neorv32_boot_rom;
 
 
architecture neorv32_boot_rom_rtl of neorv32_boot_rom is
architecture neorv32_boot_rom_rtl of neorv32_boot_rom is
 
 
  -- local types --
  -- determine required ROM size in bytes (expand to next power of two) --
  type boot_img_t is array (0 to BOOTROM_SIZE/4-1) of std_ulogic_vector(31 downto 0);
  constant boot_rom_size_index_c : natural := index_size_f((bootloader_init_image'length)); -- address with (32-bit entries)
 
  constant boot_rom_size_c       : natural := (2**boot_rom_size_index_c)*4; -- size in bytes
  -- init function --
 
  -- impure function: returns NOT the same result every time it is evaluated with the same arguments since the source file might have changed
  -- IO space: module base address --
  impure function init_boot_rom(init : bootloader_init_image_t) return boot_img_t is
  constant hi_abb_c : natural := 31; -- high address boundary bit
    variable mem_v : boot_img_t;
  constant lo_abb_c : natural := index_size_f(boot_rom_max_size_c); -- low address boundary bit
  begin
 
    mem_v := (others => (others => '0'));
 
    for i in 0 to init'length-1 loop -- init only in range of source data array
 
      mem_v(i) := init(i);
 
    end loop; -- i
 
    return mem_v;
 
  end function init_boot_rom;
 
 
 
  -- local signals --
  -- local signals --
  signal acc_en : std_ulogic;
  signal acc_en : std_ulogic;
  signal rden   : std_ulogic;
  signal rden   : std_ulogic;
  signal rdata  : std_ulogic_vector(31 downto 0);
  signal rdata  : std_ulogic_vector(31 downto 0);
  signal addr   : std_ulogic_vector(index_size_f(BOOTROM_SIZE/4)-1 downto 0);
  signal addr   : std_ulogic_vector(boot_rom_size_index_c-1 downto 0);
 
 
  -- bootloader image --
  -- ROM - initialized with executable code --
  constant boot_img : boot_img_t := init_boot_rom(bootloader_init_image);
  constant mem_rom : mem32_t(0 to boot_rom_size_c/4-1) := mem32_init_f(bootloader_init_image, boot_rom_size_c/4);
 
 
begin
begin
 
 
 
  -- Sanity Checks --------------------------------------------------------------------------
 
  -- -------------------------------------------------------------------------------------------
 
  assert false report "NEORV32 PROCESSOR CONFIG NOTE: Implementing internal bootloader ROM (" & natural'image(boot_rom_size_c) & " bytes)." severity note;
 
  assert not (boot_rom_size_c > boot_rom_max_size_c) report "NEORV32 PROCESSOR CONFIG ERROR! Boot ROM size out of range! Max "& natural'image(boot_rom_max_size_c) & " bytes." severity error;
 
 
 
 
  -- Access Control -------------------------------------------------------------------------
  -- Access Control -------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  acc_en <= '1' when (addr_i >= BOOTROM_BASE) and (addr_i < std_ulogic_vector(unsigned(BOOTROM_BASE) + BOOTROM_SIZE)) else '0';
  acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = BOOTROM_BASE(hi_abb_c downto lo_abb_c)) else '0';
  addr   <= addr_i(index_size_f(BOOTROM_SIZE/4)+1 downto 2); -- word aligned
  addr   <= addr_i(boot_rom_size_index_c+1 downto 2); -- word aligned
 
 
 
 
  -- Memory Access --------------------------------------------------------------------------
  -- Memory Access --------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  mem_file_access: process(clk_i)
  mem_file_access: process(clk_i)
  begin
  begin
    if rising_edge(clk_i) then
    if rising_edge(clk_i) then
      rden <= rden_i and acc_en;
      rden <= rden_i and acc_en;
      if (acc_en = '1') then -- reduce switching activity when not accessed
      if (acc_en = '1') then -- reduce switching activity when not accessed
        rdata <= boot_img(to_integer(unsigned(addr)));
        rdata <= mem_rom(to_integer(unsigned(addr)));
      end if;
      end if;
    end if;
    end if;
  end process mem_file_access;
  end process mem_file_access;
 
 
  -- output gate --
  -- output gate --

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.