Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Input from file and output to file - VHDL

 
Thread Tools Search this Thread
Old 01-19-2006, 01:25 AM   #1
Default Input from file and output to file - VHDL


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.



Emel
  Reply With Quote
Old 01-19-2006, 06:07 PM   #2
Duane Clark
 
Posts: n/a
Default Re: Input from file and output to file - VHDL
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);


Duane Clark
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Physical sythesis tool PALAC is not supported by Formal Verification tool Conf bbiandov Software 0 12-22-2008 05:25 AM
Help .... How to read a log file using c++... EngSara Software 0 05-17-2008 06:10 PM
Help on auto conversion from Matlab to vhdl on filter design hardheart Hardware 0 12-07-2007 09:19 AM
Very slow recognising DVD disc Terry Pinnell DVD Video 1 03-28-2006 06:53 PM
Now I introduce some popular software of multimedia eightsome@gmail.com DVD Video 0 03-28-2006 02:29 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46