UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor no_way1
Visitor
4,514 Views
Registered: ‎10-29-2009

[ModelSim SE] readline procedure problem

Hi, I have a problem with reading file which looks like this:

0011111111
0000000000
0000000000
0010000000
0000000001
0000000010
0000000011
0000000100
0000000101
0000000110
0000000111
0000001000
0000001001
0000001010
...


and here's vhdl code:


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use IEEE.std_logic_textio.all;
library STD;
use std.textio.all;


entity data_gen is
port(
fpga_clk : in std_logic;
data_out : out std_logic_vector(9 downto 0)
);
end data_gen;

architecture gen of data_gen is

function to_std_logic(c: character) return std_logic is
variable sl: std_logic;
begin
case c is
when 'U' =>
sl := 'U';
when 'X' =>
sl := 'X';
when '0' =>
sl := '0';
when '1' =>
sl := '1';
when 'Z' =>
sl := 'Z';
when 'W' =>
sl := 'W';
when 'L' =>
sl := 'L';
when 'H' =>
sl := 'H';
when '-' =>
sl := '-';
when others =>
sl := 'X';
end case;

return sl;
end to_std_logic;

function to_std_logic_vector(s: string) return std_logic_vector is
variable slv: std_logic_vector(s'high-s'low downto 0);
variable k: integer;
begin
k := s'high-s'low;
for i in s'range loop
slv(k) := to_std_logic(s(i));
k := k - 1;
end loop;
return slv;
end to_std_logic_vector;

begin
process
   
file IN_FILE : text open read_mode is "video_stream_very_short.txt";
variable DATA_LINE : line;
variable DATA_STRING : string(1 to 10);
variable TEMP : std_logic_vector(9 downto 0);
begin
loop
exit when endfile(IN_FILE);
readline(IN_FILE, DATA_LINE);
read(DATA_LINE, DATA_STRING);
TEMP := to_std_logic_vector(DATA_STRING);
wait until rising_edge(FPGA_CLK);
DATA_OUT <= TEMP;
end loop;
end process;

end gen;

 


ModelSim SE compiles this file without any errors or warnings but when I try to run simulation this message pops out:


** Fatal: (SIGSEGV) Bad pointer access.
# Time: 0 ps Iteration: 0 Process: /pixel_buffer_tb/pal_decoder/line__86 File: data_gen.vhd
# Fatal error in Process line__86 at data_gen.vhd line 93
#
# Executing ONERROR command at macro ./sim_data_gen.do line 79


Line 93 is:
readline(IN_FILE, DATA_LINE);

Any ideas what I'm doing wrong? I have read lots of examples describing how file reading should be done and according to them my code is just fine, but sim won't go. I'll be really greatful for any word of advice.

0 Kudos
2 Replies
Advisor eilert
Advisor
4,496 Views
Registered: ‎08-14-2007

Re: [ModelSim SE] readline procedure problem

Hi,

I can't say it for sure, but sometimes it's just a Carriage Return too much or missing.

 

So, check your data file at the end:

Are there empty lines?

Are there spaces after the data?

Is the last line a Data field without CR/NL?

 

Check your file, and try some variants.

Maybe it helps.

 

Have a nice simulation

  Eilert

 

 

 

0 Kudos
Visitor no_way1
Visitor
4,487 Views
Registered: ‎10-29-2009

Re: [ModelSim SE] readline procedure problem

Thanks for a reply. It turns out there's nothing wrong with my code or with txt file. Now, instead of ModelSim, I'm using ISim (on virtual machine - there's no support for ISim + 64bit systems) and it reads file just fine. I have to use ISim anyway, cause ModelSim has some problems with DCM_SP primitive and simiulation with it in design is impossible (for me, at least). And so battle continues...
0 Kudos