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;
1 | process
|
2 | use std.textio.all;
|
3 | use ieee.numeric_std.all;
|
4 | file inputfile:text open read_mode is "input.txt";
|
5 |
|
6 | variable ipa:std_logic_vector(63 downto 0);
|
7 | variable inline:line;
|
8 |
|
9 | begin
|
10 | while not(endfile(inputfile))loop
|
11 | readline(inputfile,inline);
|
12 | read(inline,ipa);
|
13 | data_in<=ipa;
|
14 | wait for 4000 ns;
|
15 | end loop;
|
16 | wait;
|
17 | end process;
|
18 |
|
19 | function_select <= '1';
|
20 | --'0' after 2100 ns,
|
21 | --'1' after 4550 ns,
|
22 | --'0' after 5800 ns;
|
23 |
|
24 |
|
25 | tb: PROCESS
|
26 | BEGIN
|
27 | key <= x"38A84FF898B90B8F";
|
28 | wait for 1400 ns;
|
29 |
|
30 |
|
31 | end process;
|
32 |
|
33 | process
|
34 | use std.textio.all;
|
35 | use ieee.numeric_std.all;
|
36 | file resultfile:text open write_mode is "result.txt";
|
37 | variable outline:line;
|
38 | begin
|
39 | wait on data_out;
|
40 | wait for 50 ns;
|
41 | write(outline,now,right, 2);
|
42 | hwrite(outline,data_out,right, 40);
|
43 | writeline(resultfile,outline);
|
44 | end process;
|
45 | end key;
|