我有两个VHDL中有1000行的文本文件。每行包含一个浮点,例如0.1234。我想在两个文本文件中乘以每一行并创建一个新的文本文件。例如乘以第1001行的两个浮点数,并将结果写入新文本文件的第1001行。我的代码在这里,但它是不正确的。乘以VHDL中的两个文本文件
entity file_io is -- test bench
end file_io;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_textio.all;
use STD.textio.all;
architecture test of file_io is
file file_VECTORS1 : text;
file file_VECTORS2 : text;
file file_RESULTS1 : text;
file file_RESULTS2 : text;
file file_RESULTS3 : text;
--signal dataread1 : integer;
--signal dataread2 : integer;
signal d1,d2 : integer;
--signal aa : integer;
begin
read_file:
process
variable v_ILINE1 : line;
variable aa : line;
variable v_ILINE2 : line;
variable dataread1 : integer;
variable dataread2 : integer;
begin
file_open(file_VECTORS1, "a.txt", read_mode);
file_open(file_RESULTS1, "b.txt", write_mode);
file_open(file_VECTORS2, "c.txt", read_mode);
file_open(file_RESULTS2, "d.txt", write_mode);
file_open(file_RESULTS3, "e.txt", write_mode);
while not endfile(file_VECTORS1) loop
readline(file_VECTORS1, v_ILINE1);
readline(file_VECTORS2, v_ILINE2);
---------------------------------------------------------------------
read(v_ILINE1, dataread1);
read(v_ILINE2, dataread2);
d1 <= dataread1;
d2 <= dataread2;
aa <= (d1 * d2);
writeline(file_RESULTS3, aa);
----------------------------------------------------------------------
wait for 60 ns;
writeline(file_RESULTS1, v_ILINE1);
writeline(file_RESULTS2, v_ILINE2);
end loop;
-------------------------------------------------------------------------
--read(file_RESULTS1, dataread1);
--read(file_RESULTS2, dataread2);
-- d1 <= dataread1;
--d2 <= dataread2;
--aa <= (d1 - d2);
--writeline(file_RESULTS3, aa);
-------------------------------------------------------------------------
file_close(file_VECTORS1);
file_close(file_RESULTS1);
file_close(file_VECTORS2);
file_close(file_RESULTS2);
wait;
end process;
end architecture;
你说的文件包含浮动。那么为什么你把它们整理成整数? –