Z
Zhi
I am learning how to use textio. I wrote a program
src.txt
{00000000
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000}
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;
use ieee.std_logic_textio.all;
use std.textio.all;
entity check is
port (clk:in std_logic;
aut std_logic_vector(7 downto 0));
end check;
architecture serial of check is
file from_file:text open READ_MODE is "src.txt";
file to_text:text open WRITE_MODE is " text1.txt";
begin
process (clk)
variable buf_out,buf_in:line;
variable num: std_logic_vector(7 downto 0):=(others=>'0');
begin
if clk'event and clk='1' then
while not ENDFILE(from_file)loop
READLINE(from_file,buf_out);
READ(buf_out,num);
a<= num;
WRITE (buf_in,num);
WRITELINE(to_text,buf_in);
end loop;
end if;
end process;
end serial;
Why the ModemSim always runs except I stop it.
When I simulate it in ModelSim, 'a' only shows the last value
(10000000) of the 'from_file'. If I remove the sensitivity list
(clk)
begin
while not ENDFILE(from_file)loop
READLINE(from_file,buf_out);
READ(buf_out,num);
a<= num;
wait for 10 ps;
WRITE (buf_in,num);
WRITELINE(to_text,buf_in);
end loop;
end process;
end serial;
The last value "10000000" cannot write into to_text. What is the
problem? And Simulation lasts 80 ps and shows each output value at
every 10 ps. When the clk is going to 90ns. The ModelSim is running
like going to stop.
src.txt
{00000000
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000}
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;
use ieee.std_logic_textio.all;
use std.textio.all;
entity check is
port (clk:in std_logic;
aut std_logic_vector(7 downto 0));
end check;
architecture serial of check is
file from_file:text open READ_MODE is "src.txt";
file to_text:text open WRITE_MODE is " text1.txt";
begin
process (clk)
variable buf_out,buf_in:line;
variable num: std_logic_vector(7 downto 0):=(others=>'0');
begin
if clk'event and clk='1' then
while not ENDFILE(from_file)loop
READLINE(from_file,buf_out);
READ(buf_out,num);
a<= num;
WRITE (buf_in,num);
WRITELINE(to_text,buf_in);
end loop;
end if;
end process;
end serial;
Why the ModemSim always runs except I stop it.
When I simulate it in ModelSim, 'a' only shows the last value
(10000000) of the 'from_file'. If I remove the sensitivity list
(clk)
begin
while not ENDFILE(from_file)loop
READLINE(from_file,buf_out);
READ(buf_out,num);
a<= num;
wait for 10 ps;
WRITE (buf_in,num);
WRITELINE(to_text,buf_in);
end loop;
end process;
end serial;
The last value "10000000" cannot write into to_text. What is the
problem? And Simulation lasts 80 ps and shows each output value at
every 10 ps. When the clk is going to 90ns. The ModelSim is running
like going to stop.