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

Subversion Repositories workwithfiles

[/] [workwithfiles/] [trunk/] [ToTextFile.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 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 ToTextFile is
10
        generic(BitLen : natural := 8;
11
        NameOfFile: string := "c:\noise.dat");
12
         port(
13
                 clk : in STD_LOGIC;
14
                 CE : in STD_LOGIC;
15
                 DataToSave : in STD_LOGIC_VECTOR(BitLen-1 downto 0)
16
             );
17
end ToTextFile;
18
 
19
 
20
architecture ToTextFile of ToTextFile is
21
 
22
FUNCTION rat( value : std_logic )
23
    RETURN std_logic IS
24
  BEGIN
25
    CASE value IS
26
      WHEN '0' | '1' => RETURN value;
27
      WHEN 'H' => RETURN '1';
28
      WHEN 'L' => RETURN '0';
29
      WHEN OTHERS => RETURN '0';
30
    END CASE;
31
END rat;
32
 
33
FUNCTION rats( value : std_logic_vector ) RETURN std_logic_vector IS
34
variable rtt:std_logic_vector(value'Range);
35
  BEGIN
36
    for i in value'Range loop
37
                rtt(i):=rat(value(i));
38
        end loop;
39
        return rtt;
40
END rats;
41
 
42
 
43
FILE RESULTS: TEXT OPEN WRITE_MODE IS NameOfFile;
44
begin
45
 
46
wrFile: process (clk) is
47
VARIABLE TX_LOC : LINE;
48
variable dataint:Integer;
49
begin
50
        if rising_edge(clk) then
51
                if CE='1' then
52
                        dataint:=CONV_INTEGER(UNSIGNED(rats(DataToSave)));
53
                        STD.TEXTIO.write(TX_LOC,dataint);
54
                        STD.TEXTIO.writeline(results, TX_LOC);
55
                        STD.TEXTIO.Deallocate(TX_LOC);
56
                end if;
57
        end if;
58
end process;
59
 
60
end ToTextFile;

powered by: WebSVN 2.1.0

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