--This program writes the data.dat input file. It stores --the write line characters (one by one) into a character --variable. It processes line by line of the input file --until EOF is encountered. library std; library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all; use IEEE.STD_LOGIC_UNSIGNED.all; use IEEE.numeric_std.all; use IEEE.STD_LOGIC_TEXTIO.all; use STD.TEXTIO.all; entity write_file is port ( Clk : in STD_LOGIC; --Rst : in STD_LOGIC; Go : in STD_LOGIC; --filenum : in integer range 7 downto 0; Astart : in STD_LOGIC_VECTOR (7 downto 0); Astop : in STD_LOGIC_VECTOR (7 downto 0); A : out STD_LOGIC_VECTOR (7 downto 0); Din : in STD_LOGIC_VECTOR (7 downto 0); Done : out STD_LOGIC ); end write_file; architecture stimuli of write_file is component pulser is port ( Clk : in STD_LOGIC; D : in STD_LOGIC; Q : out STD_LOGIC ); end component; signal En : STD_LOGIC := '0'; signal iEn : STD_LOGIC; signal A_int : STD_LOGIC_VECTOR (7 downto 0); begin write_input_file: process (Clk,Go,En) variable line_out:line; variable charvar:character; variable var1 : std_logic_vector (3 downto 0); file myfile : text; variable myfilename : string (1 to 13); variable file_status : file_open_status; begin -- case filenum is -- when 1 => myfilename := "OutPacket1.dat"; -- when 2 => myfilename := "OutPacket2.dat"; -- when 3 => myfilename := "OutPacket3.dat"; -- when others => myfilename := "OutPacket4.dat"; -- end case; myfilename := "OutPacket.dat"; if falling_edge(En) then file_close(myfile); end if; if rising_edge(Go) then file_open(file_status, myfile, myfilename, write_mode); if (file_status=open_ok) then En <= '1'; end if; end if; if (Go='1') then A_int <= Astart; else if (falling_edge(Clk) and En='1') then hwrite(line_out,Din); writeline(myfile, line_out); if (A_int=Astop) then En <= '0'; else En <= En; A_int <= A_int + X"01"; end if; else En <= En; A_int <= A_int; end if; end if; end process write_input_file; iEn <= not En; u1: pulser port map (Clk, iEn, Done); A <= A_int; end stimuli;