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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sim/] [simple/] [neorv32_imem.simple.vhd] - Blame information for rev 70

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 64 zero_gravi
-- #################################################################################################
2
-- # << NEORV32 - Processor-internal instruction memory (IMEM) >>                                  #
3
-- # ********************************************************************************************* #
4
-- # This version is intended for SIMULATION ONLY!                                                 #
5
-- # It only allows an implementation as ROM and is initialized using "application_init_image".    #
6
-- # Optimized for simulation to allow LARGE read-only IMEMs.                                      #
7
-- # ********************************************************************************************* #
8
-- # BSD 3-Clause License                                                                          #
9
-- #                                                                                               #
10 70 zero_gravi
-- # Copyright (c) 2022, Stephan Nolting. All rights reserved.                                     #
11 64 zero_gravi
-- #                                                                                               #
12
-- # Redistribution and use in source and binary forms, with or without modification, are          #
13
-- # permitted provided that the following conditions are met:                                     #
14
-- #                                                                                               #
15
-- # 1. Redistributions of source code must retain the above copyright notice, this list of        #
16
-- #    conditions and the following disclaimer.                                                   #
17
-- #                                                                                               #
18
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
19
-- #    conditions and the following disclaimer in the documentation and/or other materials        #
20
-- #    provided with the distribution.                                                            #
21
-- #                                                                                               #
22
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
23
-- #    endorse or promote products derived from this software without specific prior written      #
24
-- #    permission.                                                                                #
25
-- #                                                                                               #
26
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
27
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
28
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
29
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
30
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
31
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
32
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
33
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
34
-- # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
35
-- # ********************************************************************************************* #
36
-- # The NEORV32 Processor - https://github.com/stnolting/neorv32              (c) Stephan Nolting #
37
-- #################################################################################################
38
 
39
library ieee;
40
use ieee.std_logic_1164.all;
41
use ieee.numeric_std.all;
42
 
43
library neorv32;
44
use neorv32.neorv32_package.all;
45
use neorv32.neorv32_application_image.all; -- this file is generated by the image generator
46
 
47
architecture neorv32_imem_rtl of neorv32_imem is
48
 
49
  -- IO space: module base address --
50
  constant hi_abb_c : natural := 31; -- high address boundary bit
51
  constant lo_abb_c : natural := index_size_f(IMEM_SIZE); -- low address boundary bit
52
 
53
  -- local signals --
54
  signal acc_en : std_ulogic;
55
  signal rdata  : std_ulogic_vector(31 downto 0);
56
  signal rden   : std_ulogic;
57
  signal addr   : std_ulogic_vector(index_size_f(IMEM_SIZE/4)-1 downto 0);
58
 
59
begin
60
 
61
  -- Sanity Checks --------------------------------------------------------------------------
62
  -- -------------------------------------------------------------------------------------------
63 70 zero_gravi
  assert false report "NEORV32 PROCESSOR CONFIG NOTE: Implementing processor-internal [SIM-only!] IMEM as ROM (" & natural'image(IMEM_SIZE) &
64
  " bytes), pre-initialized with application (" & natural'image(application_init_image'length * 4) & " bytes)." severity note;
65 64 zero_gravi
  assert not (IMEM_AS_IROM = false) report "NEORV32 PROCESSOR CONFIG ERROR! Simulation-optimized IMEM can only be used as pre-initialized ROM!" severity error;
66
 
67
 
68
  -- Access Control -------------------------------------------------------------------------
69
  -- -------------------------------------------------------------------------------------------
70
  acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = IMEM_BASE(hi_abb_c downto lo_abb_c)) else '0';
71
  addr   <= addr_i(index_size_f(IMEM_SIZE/4)+1 downto 2); -- word aligned
72
 
73
 
74
  -- Memory Access --------------------------------------------------------------------------
75
  -- -------------------------------------------------------------------------------------------
76
  imem_file_access: process(clk_i)
77 70 zero_gravi
    variable addr_v : integer range 0 to (IMEM_SIZE/4)-1;
78 64 zero_gravi
  begin
79
    if rising_edge(clk_i) then
80 70 zero_gravi
      rden   <= acc_en and rden_i;
81
      ack_o  <= acc_en and (rden_i or wren_i);
82
      addr_v := to_integer(unsigned(addr));
83
      --
84
      rdata <= (others => '0');
85
      if (addr_v <= application_init_image'length) then
86
        rdata <= application_init_image(addr_v);
87 64 zero_gravi
      end if;
88
    end if;
89
  end process imem_file_access;
90
 
91
  -- output gate --
92
  data_o <= rdata when (rden = '1') else (others => '0');
93
 
94
 
95
end neorv32_imem_rtl;

powered by: WebSVN 2.1.0

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