source: FPGA/FAD/FACT_FAD_test_devices_lib/ROM_from_file_beha.vhd@ 226

Last change on this file since 226 was 215, checked in by dneise, 14 years ago
initial commit (2nd part): only VHDL and UCF files were commited.
  • Property svn:executable set to *
File size: 1.8 KB
Line 
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--
10LIBRARY ieee;
11USE ieee.std_logic_1164.all;
12USE ieee.numeric_std.all;
13USE ieee.std_logic_textio.all;
14LIBRARY std;
15USE std.textio.all;
16LIBRARY FACT_FAD_test_devices_lib;
17USE FACT_FAD_test_devices_lib.drs4_pack.all;
18
19ENTITY 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
32END ROM_from_File ;
33
34ARCHITECTURE 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
55BEGIN
56
57 -- nur die unteren WIDTH Bits werden ausgegeben
58 dout <= std_logic_vector(ROM(to_integer(unsigned(addr)))(WIDTH-1 downto 0));
59
60END ARCHITECTURE beha;
61
Note: See TracBrowser for help on using the repository browser.