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

Subversion Repositories workwithfiles

[/] [workwithfiles/] [trunk/] [FromTextFile.vhd] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 asjohnas
library IEEE;
2
use IEEE.STD_LOGIC_1164.all;
3
use IEEE.std_logic_arith.all;
4
library std;
5
use std.textio.all;
6
 
7
 
8
 
9
entity FromTextFile is
10
        generic(BitLen : natural := 8;
11
                        IsSigned: natural:=0; -- you can choose signed or unsigned value you have in text file
12
                        NameOfFile: string := "c:\noise.dat");
13
         port(
14
                 clk : in STD_LOGIC;
15
                 CE : in STD_LOGIC;
16
                 DataFromFile : out STD_LOGIC_VECTOR(BitLen-1 downto 0)
17
             );
18
end FromTextFile;
19
 
20
 
21
architecture FromTextFile of FromTextFile is
22
 
23
 
24
FILE RESULTS: TEXT OPEN READ_MODE IS NameOfFile;
25
begin
26
 
27
rxFile: process (clk) is
28
VARIABLE RX_LOC : LINE;
29
variable dataint:Integer;
30
begin
31
        if rising_edge(clk) then
32
                if CE='1' then
33
                STD.TEXTIO.readline(results, RX_LOC);
34
                STD.TEXTIO.read(RX_LOC,dataint);
35
                if (IsSigned=1) then
36
                        DataFromFile<=std_logic_vector(signed(CONV_STD_LOGIC_VECTOR(dataint,BitLen)));
37
                else
38
                        DataFromFile<=std_logic_vector(unsigned(CONV_STD_LOGIC_VECTOR(dataint,BitLen)));
39
                end if;
40
                STD.TEXTIO.Deallocate(RX_LOC);
41
                end if;
42
        end if;
43
end process;
44
 
45
end FromTextFile;

powered by: WebSVN 2.1.0

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