1 | --
|
---|
2 | -- VHDL Architecture FACT_FAD_test_devices_lib.ROM_from_file.beha
|
---|
3 | --
|
---|
4 | -- Created:
|
---|
5 | -- by - FPGA_Developer.UNKNOWN (EEPC8)
|
---|
6 | -- at - 09:21:32 22.01.2010
|
---|
7 | --
|
---|
8 | -- using Mentor Graphics HDL Designer(TM) 2008.1 (Build 17)
|
---|
9 | --
|
---|
10 | LIBRARY ieee;
|
---|
11 | USE ieee.std_logic_1164.all;
|
---|
12 | USE ieee.numeric_std.all;
|
---|
13 | USE ieee.std_logic_textio.all;
|
---|
14 | LIBRARY std;
|
---|
15 | USE std.textio.all;
|
---|
16 | LIBRARY FACT_FAD_test_devices_lib;
|
---|
17 | USE FACT_FAD_test_devices_lib.drs4_pack.all;
|
---|
18 |
|
---|
19 | ENTITY ROM_from_File IS
|
---|
20 | GENERIC(
|
---|
21 | INPUT_FILE : STRING := "filename";
|
---|
22 | WIDTH : INTEGER := 13; -- Breite des Datenworts
|
---|
23 | DEPTH : INTEGER := 1024 -- Tiefe des ROM - Speichers
|
---|
24 | );
|
---|
25 | PORT(
|
---|
26 | addr : IN std_logic_vector (ld(DEPTH)-1 DOWNTO 0);
|
---|
27 | dout : OUT std_logic_vector (WIDTH-1 DOWNTO 0)
|
---|
28 | );
|
---|
29 |
|
---|
30 | -- Declarations
|
---|
31 |
|
---|
32 | END ROM_from_File ;
|
---|
33 |
|
---|
34 | ARCHITECTURE beha OF ROM_from_File IS
|
---|
35 |
|
---|
36 | -- ROMTYPE muss wg. HREAD ein Vielfaches von 4 Bit sein, Berechnung erfolgt in 'drs4_pack'
|
---|
37 | TYPE ROMTYPE is array(0 to DEPTH) of std_logic_vector(hexalign(WIDTH)-1 downto 0);
|
---|
38 |
|
---|
39 | -- InitRomFromFile liest eine Zeile aus der angegebenen Datei und legt diesen Wert in
|
---|
40 | -- 'ROM(i)' ab
|
---|
41 | impure function InitRomFromFile (RomFileName : in STRING) return ROMTYPE is
|
---|
42 | FILE RomFile : text open read_mode is RomFileName;
|
---|
43 | variable RomFileLine : LINE;
|
---|
44 | variable ROM : ROMTYPE;
|
---|
45 | begin
|
---|
46 | for i in 0 to DEPTH-1 loop
|
---|
47 | READLINE(RomFile, RomFileLine);
|
---|
48 | HREAD(RomFileLine, ROM(i));
|
---|
49 | end loop;
|
---|
50 | return ROM;
|
---|
51 | end function InitRomFromFile;
|
---|
52 |
|
---|
53 | signal ROM : ROMTYPE := InitRomFromFile(INPUT_FILE);
|
---|
54 |
|
---|
55 | BEGIN
|
---|
56 |
|
---|
57 | -- nur die unteren WIDTH Bits werden ausgegeben
|
---|
58 | dout <= std_logic_vector(ROM(to_integer(unsigned(addr)))(WIDTH-1 downto 0));
|
---|
59 |
|
---|
60 | END ARCHITECTURE beha;
|
---|
61 |
|
---|