Hi guys,requesting some help with my vhdl code,i am writing a Data Encryption Standard using VHDL.I have a problem with reading from a file.I can write to a file if I entered the inputs manually in my testbench but I cant write to a file when I try to read the inputs from a file.Below is a portion of my code and the input/output files.Any help would be greatly appreciated and thanks for your time! Input File(.txt) _________________ 785AC3A4BD0FE12D 123456789ABCDEF0 785AC3A4BD0FE12D Output File(.txt) _________________ 1335 ns FD9CBA5D26331F38 2135 ns 17EA4A8B48C14DA0 2935 ns FD9CBA5D26331F38 Code(data_in<=input,data_out<=output) ____________________________________________ -- data_in <= x"785AC3A4BD0FE12D", -- x"123456789ABCDEF0" after 1400 ns, -- x"785AC3A4BD0FE12D" after 2200 ns;
process use std.textio.all; use ieee.numeric_std.all; file inputfile:text open read_mode is "input.txt"; variable ipa:std_logic_vector(63 downto 0); variable inline:line; begin while not(endfile(inputfile))loop readline(inputfile,inline); read(inline,ipa); data_in<=ipa; wait for 4000 ns; end loop; wait; end process; function_select <= '1'; --'0' after 2100 ns, --'1' after 4550 ns, --'0' after 5800 ns; tb: PROCESS BEGIN key <= x"38A84FF898B90B8F"; wait for 1400 ns; end process; process use std.textio.all; use ieee.numeric_std.all; file resultfile:text open write_mode is "result.txt"; variable outline:line; begin wait on data_out; wait for 50 ns; write(outline,now,right, 2); hwrite(outline,data_out,right, 40); writeline(resultfile,outline); end process; end key;
: Edited by Moderator
Darren Seow wrote: > but I cant write to a file when I try to read the inputs from a file. Why not? What error message do you get?
Hi there,sorry for the late reply,issue has been solved.I forgotten to add a "h"in front of read.Hence,it wasnt able to read hexadecimal inputs.Thanks for your time!