FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-19-2004, 10:06 PM
Pete Fraser
Guest
 
Posts: n/a
Default Help with file read please

I'm trying to read a list of stimulus files from a directory file.
This is described on page 527 of Ashenden's book.

At the start of file_loop, read(directory, file_name, file_name_length);
doesn't do what I expected. I assumed it would read an individual
string representing a file name, and would stop when it came to a <CR>
or <LF> . Then on the next pass of the loop it would read the
next filename. Instead, it fills file_name with 50 characters
(including <CR> and <LF>) on each pass.

What am I doing wrong?

Thanks




file_reader : process is
type directory_file is file of string;
file directory : directory_file open read_mode is "stimulus-directory";
variable file_name : string(1 to 50);
variable file_name_length : natural;
variable open_status : file_open_status;
variable char : character;
type char_file is file of character; -- one byte each
file stim_file : char_file;
begin
file_loop : while not endfile(directory) loop
read(directory, file_name, file_name_length);
if file_name_length > file_name'length then
report "file name too long: " & file_name & "... - file skipped"
severity warning;
next file_loop;
end if;
file_open (open_status, stim_file,
file_name(1 to file_name_length), read_mode);
if open_status /= open_ok then
report file_open_status'image(open_status) & " while opening file "
& file_name(1 to file_name_length) & " -file skipped"
severity warning;
next file_loop;
end if;
stimulus_loop : while not endfile(stim_file) loop
if (rst = '1') then
sig <= "00000000";
data_valid <= '0';
elsif (clk'event and clk='1') then
data_valid <= valid;
if (valid = '1') then
read(stim_file, char);
end if;
sig <= char2std(char);
end if;
end loop stimulus_loop;
file_close(stim_file);
end loop file_loop;
wait;
end process file_reader;


Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
read hex data from a file vinoth Verilog 2 03-30-2007 06:24 AM
Verilog 2001 File I/O: read large file? Davy Verilog 15 04-07-2006 03:03 AM
Call a file and read data from it [email protected] Verilog 4 02-27-2006 06:38 PM
[Verilog] How to read data from a file? Davy Verilog 0 07-07-2005 12:51 PM
How to read from file in Verilog Stew Verilog 2 11-08-2004 07:27 PM


All times are GMT +1. The time now is 11:36 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved