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

Subversion Repositories neo430

[/] [neo430/] [trunk/] [neo430/] [rtl/] [core/] [neo430_boot_rom.vhd] - Blame information for rev 198

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
-- #################################################################################################
2
-- #  << NEO430 - Bootloader ROM >>                                                                #
3
-- # ********************************************************************************************* #
4
-- # This memory includes the in-place executable image of the NEO430 bootloader. See the          #
5
-- # processor's documentary to get more information.                                              #
6
-- # ********************************************************************************************* #
7
-- # BSD 3-Clause License                                                                          #
8
-- #                                                                                               #
9
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved.                                     #
10
-- #                                                                                               #
11
-- # Redistribution and use in source and binary forms, with or without modification, are          #
12
-- # permitted provided that the following conditions are met:                                     #
13
-- #                                                                                               #
14
-- # 1. Redistributions of source code must retain the above copyright notice, this list of        #
15
-- #    conditions and the following disclaimer.                                                   #
16
-- #                                                                                               #
17
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
18
-- #    conditions and the following disclaimer in the documentation and/or other materials        #
19
-- #    provided with the distribution.                                                            #
20
-- #                                                                                               #
21
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
22
-- #    endorse or promote products derived from this software without specific prior written      #
23
-- #    permission.                                                                                #
24
-- #                                                                                               #
25
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
26
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
27
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
28
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
29
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
30
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
31
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
32
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
33
-- # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
34
-- # ********************************************************************************************* #
35
-- # The NEO430 Processor - https://github.com/stnolting/neo430                                    #
36
-- #################################################################################################
37
 
38
library ieee;
39
use ieee.std_logic_1164.all;
40
use ieee.numeric_std.all;
41
 
42
library neo430;
43
use neo430.neo430_package.all;
44
use neo430.neo430_bootloader_image.all; -- this file is generated by the image generator
45
 
46
entity neo430_boot_rom is
47
  port (
48
    clk_i  : in  std_ulogic; -- global clock line
49
    rden_i : in  std_ulogic; -- read enable
50
    addr_i : in  std_ulogic_vector(15 downto 0); -- address
51
    data_o : out std_ulogic_vector(15 downto 0)  -- data out
52
  );
53
end neo430_boot_rom;
54
 
55
architecture neo430_boot_rom_rtl of neo430_boot_rom is
56
 
57
  -- local types --
58
  type boot_img_t is array (0 to boot_size_c/2-1) of std_ulogic_vector(15 downto 0);
59
 
60
  -- init function --
61
  impure function init_boot_rom(init : bootloader_init_image_t) return boot_img_t is
62
    variable mem_v : boot_img_t;
63
  begin
64
    for i in 0 to boot_size_c/2-1 loop
65
      mem_v(i) := init(i);
66
    end loop; -- i
67
    return mem_v;
68
  end function init_boot_rom;
69
 
70
  -- local signals --
71
  signal acc_en : std_ulogic;
72
  signal rden   : std_ulogic;
73
  signal rdata  : std_ulogic_vector(15 downto 0);
74
  signal addr   : natural range 0 to boot_size_c/2-1;
75
 
76
  -- bootloader image --
77
  constant boot_img : boot_img_t := init_boot_rom(bootloader_init_image);
78
 
79
begin
80
 
81
  -- Access Control -----------------------------------------------------------
82
  -- -----------------------------------------------------------------------------
83
  acc_en <= '1' when (addr_i >= boot_base_c) and (addr_i < std_ulogic_vector(unsigned(boot_base_c) + boot_size_c)) else '0';
84
  addr <= to_integer(unsigned(addr_i(index_size_f(boot_size_c/2) downto 1))); -- word aligned
85
 
86
 
87
  -- Memory Access ------------------------------------------------------------
88
  -- -----------------------------------------------------------------------------
89
  mem_file_access: process(clk_i)
90
  begin
91
    -- check max size --
92
    if (boot_size_c > boot_max_size_c) then
93
      assert false report "Boot ROM size out of range! Max 2kB!" severity error;
94
    end if;
95
    if rising_edge(clk_i) then
96
      rden <= rden_i and acc_en;
97
      if (acc_en = '1') then -- reduce switching activity when not accessed
98
        rdata <= boot_img(addr);
99
      end if;
100
    end if;
101
  end process mem_file_access;
102
 
103
  -- output gate --
104
  data_o <= rdata when (rden = '1') else (others => '0');
105
 
106
 
107
end neo430_boot_rom_rtl;

powered by: WebSVN 2.1.0

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