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
Observer aparna
Observer
8,614 Views
Registered: ‎10-17-2011

Importing a file and using its values in XILINX

Jump to solution

Hi

 

I am working on this project in which half my code is in MATLAB and half is in VHDL.

The MATLAB code produces a .txt file.

Is there a way to import this .txt file and use it in my vhdl code in xilinx?

 

If so how do I do it and how can I access individual values from the file?

 

 

0 Kudos
1 Solution

Accepted Solutions
Voyager
Voyager
10,880 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

yes i think it is beacuse you cannot synthesise this code.

You can only simulate it. This is NOT code you can use on an FPGA. You will need modelsim, activeHDL, GHDL or some other simulator like MODELSIM to see this working. File IO is intended for testing and behavioural models only.

View solution in original post

0 Kudos
10 Replies
Xilinx Employee
Xilinx Employee
8,611 Views
Registered: ‎08-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

Presumably, you're trying to use the .txt file as testbench stimulus.

 

Spend some time on google or a textbook for VHDL file I/O.

 

Here's one example:

http://www.stefanvhdl.com/vhdl/html/file_read.html

www.xilinx.com
0 Kudos
Observer aparna
Observer
8,588 Views
Registered: ‎10-17-2011

Re: Importing a file and using its values in XILINX

Jump to solution

This example is not working. There is an error:

 

HDLCompiler:1316 - "D:/code/fileread/file_read.vhd" Line 51: Index value <0> is out of range [1:2147483647] of array <string>

 

can you tell me how to fix this as online is says that the range of the string is wrong.

0 Kudos
Voyager
Voyager
8,583 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

HDLCompiler:1316 - "D:/code/fileread/file_read.vhd" Line 51: Index value <0> is out of range [1:2147483647] of array <string>

 

can you tell me how to fix this as online is says that the range of the string is wrong.

 

i had tried synthesizing your code & it seems you should use "use work.txt_util.all;" this library in FILE_READ.vhd file.

 

Also make sure that you have created/or "use work.txt_util.all;"  library is present in your project environment.

 

 

0 Kudos
Observer aparna
Observer
8,580 Views
Registered: ‎10-17-2011

Re: Importing a file and using its values in XILINX

Jump to solution

 

"use work.txt_util.all " has been added, but it still gives the same error.

0 Kudos
Voyager
Voyager
8,573 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

"use work.txt_util.all " has been added, but it still gives the same error.

The only thing now i can guess is  

strings have to be declared with natural ranges, and always ascending.

 so you have to declare: variable s : string(1 to 10); NOT string(0 to 9);  

0 Kudos
Voyager
Voyager
8,567 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

Actually you should modify variable s: string(y'range);  variable s : string(1 to 6);

 

 

 

 

 

 

 

0 Kudos
Voyager
Voyager
8,566 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

After this I tried again it shows "ERROR:Xst:842 - "E:/voip_ise/FILE_READ.vhd" line 47: Same wait conditions expected in all Multiple Waits."

 

So now you need to add wait at the end of the process, else it will loop forever. Im guessing you only want it to run once.  

0 Kudos
Voyager
Voyager
8,565 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

after i wrote wait; statement it gives me the following error. ERROR:Xst:841 - "C:/Design_path/test.vhd" line 47: Bad condition in wait statement, or only one clock per process.

0 Kudos
Voyager
Voyager
10,881 Views
Registered: ‎04-02-2011

Re: Importing a file and using its values in XILINX

Jump to solution

yes i think it is beacuse you cannot synthesise this code.

You can only simulate it. This is NOT code you can use on an FPGA. You will need modelsim, activeHDL, GHDL or some other simulator like MODELSIM to see this working. File IO is intended for testing and behavioural models only.

View solution in original post

0 Kudos
Observer aparna
Observer
3,171 Views
Registered: ‎10-17-2011

Re: Importing a file and using its values in XILINX

Jump to solution

thanks a ton!

0 Kudos