Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Input from file and output to file - VHDL

Reply
Thread Tools

Input from file and output to file - VHDL

 
 
Emel
Guest
Posts: n/a
 
      01-19-2006
Hi,

what is the easiest way of taking inputs from a file and writing
outputs to a file? I need to take values from MATLAB. I also need to
plot the outputs in MATLAB. Can anyone suggest an appropriate way of
doing this?

Thanks in advance.

e.

 
Reply With Quote
 
 
 
 
Duane Clark
Guest
Posts: n/a
 
      01-19-2006
Emel wrote:
> Hi,
>
> what is the easiest way of taking inputs from a file and writing
> outputs to a file? I need to take values from MATLAB. I also need to
> plot the outputs in MATLAB. Can anyone suggest an appropriate way of
> doing this?


If you read and write the files as ascii, then you can do this in both
Matlab and VHDL in a portable fashion. I generally prefer to use binary
data files for this purpose. I don't think there is a standard for
binary file formats in VHDL, but Modelsim at least reads and writes 4
byte integers. I have no problem then importing that into Matlab and
plotting it.

But I have used the ascii method; sometimes it is nice to have an easily
readable file. For example, in VHDL:

constant telm_filename : String := "telm.out";
begin
data_ver_p: process is
variable L : line;
file telm_file : text open write_mode is telm_filename;
begin
loop
wait until rising_edge(USER_CLK);
if RX_SRC_RDY = '1' then
RX_CNT <= RX_CNT + 1;
hwrite(L, RX_DOUT);
writeline(telm_file, L);
deallocate(L);
end if;
end loop;
end process data_ver_p;

Then, in Matlab:

fid = fopen(strcat(telm,'telm.out'),'r');
for i = 1:range_samples
j = int32(fscanf(fid,'%x',1));
if j > 32767
telm2_r(i) = j-65536;
else
telm2_r(i) = j;
end
j = int32(fscanf(fid,'%x',1));
if j > 32767
telm2_i(i) = j-65536;
else
telm2_i(i) = j;
end
end
fclose(fid);
 
Reply With Quote
 
 
 
 
nish a nish a is offline
Junior Member
Join Date: Jan 2010
Posts: 1
 
      01-29-2010
actually i want to read an image (the pixel values) from the m-file using VHDL code.. how can i do that?
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL'87: avoiding FATAL ERROR when "Failed to open VHDL file" occurs sigwalt@gmx.net VHDL 2 09-04-2007 09:06 PM
VHDL-2002 vs VHDL-93 vs VHDL-87? afd VHDL 1 03-23-2007 09:33 AM
input and output questions about file Dic4000@163.com C++ 5 02-24-2007 09:10 PM
input and output questions about file Dic4000@163.com C Programming 6 02-24-2007 05:18 PM
java input and output stream to the same file at the same time? Krick Java 1 08-15-2003 05:55 PM



Advertisments