--This program reads the data.dat input file. It stores --the read 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 Std.Standard.all; --use STD_LOGIC_TEXTIO.ALL; use std.textio.all; entity read_file is Port ( Clk : in STD_LOGIC; --Rst : in STD_LOGIC; Go : in STD_LOGIC; filenum : in integer range 7 downto 0; Ain : in STD_LOGIC_VECTOR (7 downto 0); Wr : out STD_LOGIC; A : out STD_LOGIC_VECTOR (7 downto 0); D : out STD_LOGIC_VECTOR (7 downto 0); Done : out STD_LOGIC); end read_file; architecture stimuli of read_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 read_input_file: process (Clk,Go,En) variable inline:line; variable charvar1:character; variable var1 : std_logic_vector (3 downto 0); variable charvar2:character; variable var2 : std_logic_vector (3 downto 0); variable end_of_line:boolean; file myfile : text;-- is "InPacket.dat"; variable myfilename : string (1 to 16); variable file_status : file_open_status; begin case filenum is when 1 => myfilename := "InPacket1_R'.dat"; when 2 => myfilename := "InPacket2_Q_.dat"; when 3 => myfilename := "InPacket3_P_.dat"; when others => myfilename := "InPacket4___.dat"; end case; if falling_edge(En) then file_close(myfile); end if; if rising_edge(Go) then file_open(file_status, myfile, myfilename, read_mode); if (file_status=open_ok) then En <= '1'; end if; end if; if (Go='1') then --En <= '1'; Wr <= '0'; A_int <= Ain - X"01"; else -- A_int <= A_int; if (En='1') then if endfile(myfile) then Wr <= '0'; En <= '0'; else En <= En; if (rising_edge(Clk) and En='1') then readline(myfile,inline); read(inline,charvar1); read(inline,charvar2,end_of_line); --end_of_line is EOLN boolean flag -- while end_of_line loop -- read(inline,charvar,end_of_line); -- end loop; A_int <= A_int + X"01"; Wr <= '1'; --D <= conv_std_logic_vector(character'pos(charvar1),8); case charvar1 is when '0' => D(7 downto 4) <= x"0"; when '1' => D(7 downto 4) <= x"1"; when '2' => D(7 downto 4) <= x"2"; when '3' => D(7 downto 4) <= x"3"; when '4' => D(7 downto 4) <= x"4"; when '5' => D(7 downto 4) <= x"5"; when '6' => D(7 downto 4) <= x"6"; when '7' => D(7 downto 4) <= x"7"; when '8' => D(7 downto 4) <= x"8"; when '9' => D(7 downto 4) <= x"9"; when 'A' => D(7 downto 4) <= x"A"; when 'B' => D(7 downto 4) <= x"B"; when 'C' => D(7 downto 4) <= x"C"; when 'D' => D(7 downto 4) <= x"D"; when 'E' => D(7 downto 4) <= x"E"; when 'F' => D(7 downto 4) <= x"F"; when others => D(7 downto 4) <= x"0"; end case; case charvar2 is when '0' => D(3 downto 0) <= x"0"; when '1' => D(3 downto 0) <= x"1"; when '2' => D(3 downto 0) <= x"2"; when '3' => D(3 downto 0) <= x"3"; when '4' => D(3 downto 0) <= x"4"; when '5' => D(3 downto 0) <= x"5"; when '6' => D(3 downto 0) <= x"6"; when '7' => D(3 downto 0) <= x"7"; when '8' => D(3 downto 0) <= x"8"; when '9' => D(3 downto 0) <= x"9"; when 'A' => D(3 downto 0) <= x"A"; when 'B' => D(3 downto 0) <= x"B"; when 'C' => D(3 downto 0) <= x"C"; when 'D' => D(3 downto 0) <= x"D"; when 'E' => D(3 downto 0) <= x"E"; when 'F' => D(3 downto 0) <= x"F"; when others => D(3 downto 0) <= x"0"; end case; end if; end if; else A_int <= A_int; end if; end if; end process read_input_file; iEn <= not En; u1: pulser port map (Clk, iEn, Done); A <= A_int; end stimuli;