I tried to attach the file, but I guess it didn't work becuase it was the wrong extension. Let me try to attach it again and paste it just in case.
signal ClkBR : std_logic;
signal Counter_BR : INTEGER;
Baud_rate: process
begin
ClkBR <= '0'; -- 19200 bits per second
wait for 52 us;
ClkBR <= '1';
wait for 52 us;
end process;
--------------------------------------
-- Generate 1MHz clock (1uS)
--------------------------------------
Counter_BR_p
rocess (ResetNotIn, ClkBR)
begin
if ResetNotIn='0' then
Counter_BR <= 0;
elsif rising_edge(ClkBR) then
if Counter_BR < 20 then
Counter_BR <= Counter_BR + 1;
else
Counter_BR <= 0 ;
end if;
end if;
end process;
read_input: process (ClkBR)
FILE file_in : text;
VARIABLE line_in : INTEGER;
VARIABLE buff: line;
variable line_in_vec: std_logic_vector(15 downto 0);
variable Dout_LSByte: std_logic_vector(9 downto 0);
variable Dout_MSByte: std_logic_vector(9 downto 0);
variable SDout: std_logic;
-- function conv_std_logic_vector(line_in: 16
return std_logic_vector;
begin
file_open(file_in, "prf_data.txt", READ_MODE);
if rising_edge(ClkBR) then
if Counter_BR = 0 then
-- Read lines until you get an EOF then break out and close file
readline(file_in, buff); -- file
READ(buff, line_in); -- read integer from file
line_in_vec := conv_std_logic_vector(line_in, 16);
Dout_LSByte := STOPBIT & line_in_vec(7 downto 0) & STARTBIT;
Dout_MSByte := STOPBIT & line_in_vec(15 downto 8) & STARTBIT;
elsif Counter_BR > 0 and Counter_BR < 20 then
-- shift register for 20 bits of serial data (shift one bit at a time)
SDout := Dout_LSByte(0); -- shift LSB of LSByte first
Dout_LSByte(8 downto 0) := Dout_LSByte(9 downto 1); -- shift LSByte next
Dout_LSByte(9) := Dout_MSByte(0); -- shift LSB of MSByte next
Dout_MSByte(8 downto 0) := Dout_MSByte(9 downto 1); -- shift MSByte last
end if;
end if;
file_close(file_in);
end process;