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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [techmap/] [mem/] [romimage_inferred.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
-----------------------------------------------------------------------------
2
--! @file
3
--! @copyright  Copyright 2015 GNSS Sensor Ltd. All right reserved.
4
--! @author     Sergey Khabarov - sergeykhbr@gmail.com
5
--! @brief      ROM Image with the Firmware
6
------------------------------------------------------------------------------
7
library ieee;
8
use ieee.std_logic_1164.all;
9
use ieee.numeric_std.ALL;
10
use IEEE.STD_LOGIC_TEXTIO.ALL;
11
use std.textio.all;
12
library commonlib;
13
use commonlib.types_common.all;
14
--! AMBA system bus specific library.
15
library ambalib;
16
--! AXI4 configuration constants.
17
use ambalib.types_amba4.all;
18
 
19
entity RomImage_inferred is
20
  generic (
21
    hex_filename : string
22
  );
23
  port (
24
    clk     : in  std_ulogic;
25
    address : in  global_addr_array_type;
26
    data    : out std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0)
27
  );
28
end;
29
 
30
architecture rtl of RomImage_inferred is
31
 
32
constant ROM_ADDR_WIDTH : integer := 18;
33
constant ROM_LENGTH : integer := 2**(ROM_ADDR_WIDTH - log2(CFG_NASTI_DATA_BYTES));
34
 
35
type rom_block is array (0 to ROM_LENGTH-1) of std_logic_vector(31 downto 0);
36
type rom_type is array (0 to CFG_WORDS_ON_BUS-1) of rom_block;
37
 
38
type local_addr_arr is array (0 to CFG_WORDS_ON_BUS-1) of integer;
39
 
40
impure function init_rom(file_name : in string) return rom_type is
41
    file rom_file : text open read_mode is file_name;
42
    variable rom_line : line;
43
    variable temp_bv : std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
44
    variable temp_mem : rom_type;
45
begin
46
    --report "!!!!!!The value 'ROM_LENGTH' is " & integer'image(ROM_LENGTH);
47
    for i in 0 to (ROM_LENGTH-1) loop
48
        readline(rom_file, rom_line);
49
        hread(rom_line, temp_bv);
50
        for n in 0 to (CFG_WORDS_ON_BUS-1) loop
51
          temp_mem(n)(i) := temp_bv((n+1)*32-1 downto 32*n);
52
        end loop;
53
    end loop;
54
    return temp_mem;
55
end function;
56
 
57
constant rom : rom_type := init_rom(hex_filename);
58
 
59
begin
60
 
61
  reg : process (clk)
62
    variable t_adr : local_addr_arr;
63
  begin
64
    if rising_edge(clk) then
65
        for n in 0 to (CFG_WORDS_ON_BUS-1) loop
66
            t_adr(n) := conv_integer(address(n)(ROM_ADDR_WIDTH-1 downto log2(CFG_NASTI_DATA_BYTES)));
67
            data(8*CFG_ALIGN_BYTES*(n+1)-1 downto 8*CFG_ALIGN_BYTES*n) <= rom(n)(t_adr(n));
68
        end loop;
69
    end if;
70
  end process;
71
 
72
 
73
end;

powered by: WebSVN 2.1.0

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