why the error and how to remove it : Could not open file variable. No such file or directory.

I am converting a matlab function to vhdl. During fixed point conversion I get the following error in Build Log.
Error using fileread (line 27) Could not open file variable. No such file or directory.
I have attached the function and testbench. Why it is not able to read the file?

3 Comments

Actually all these functions fread/fileread are not in my code. I guess MATLAB is using it itself.
Basically if you consider fcn.m as the main function and fcn_tb.m as test bench and then open the workflow advisor, then run till the task fixed point conversion. At that time you get this error. I'll post the entire red part.
Error using fileread (line 27) Could not open file variable. No such file or directory.
Error in C:\MatlabR2013a\R2013a\toolbox\coder\float2fixed\+coder\+internal\Float2FixedConverter.p>Float2FixedConverter.buildDesign/getUserWrittenFunction (line 1666)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\float2fixed\+coder\+internal\Float2FixedConverter.p>Float2FixedConverter.buildDesign (line 1654)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\coder\+coderprivate\Float2FixedManager.p>Float2FixedManager.buildFloatingPointCode (line 102)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\coder\private\fpBuildFloatingPointCode.p>fpBuildFloatingPointCode (line 4)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\coder\emlcprivate.p>emlcprivate (line 16)
Could not open file variable. No such file or directory.
Error in fileread at 27
Error in Float2FixedConverter>buildDesign/getUserWrittenFunction at 1666
Error in Float2FixedConverter>buildDesign at 1654
Error in Float2FixedManager>buildFloatingPointCode at 102
Error in fpBuildFloatingPointCode at 4
Error in emlcprivate at 16
Even i got the same erros: Error in Float2FixedConverter>buildDesign at 1699
Error in Float2FixedManager>buildFloatingPointCode at 102
Error in fpBuildFloatingPointCode at 4
Error in emlcprivate at 16
how to remove them? Its saying Float2FixedConverter.m doesnot exist do you want to create? Can i get it in net?
This happens when compiler is not configured; floating2fixedconverter.m needs the compiler;
in matlab command prompt run >>mex -setup command

Sign in to comment.

 Accepted Answer

Your code is hitting an internal error inside float to fixed conversion. Since you don't detail exactly what you were doing at the time of failure it's hard to understand what the issue is that you are having.
That said, the primary problem with your code, simply by inspection, is that it contains a while loop, which is not supported for HDL code generation. Try rewriting your code to not use any of the following constructs:
  • while
  • break
  • continue
  • return
  • parfor
The requirement to not use these constructs is clearly spelled out in the documentation on the MathWorks Support site for HDL Coder. The identical information is available in the installed help as well.

More Answers (2)

Those files don't mention fileread() and don't even have 27 lines. Please attach the entire error message - ALL THE RED TEXT - don't snip out just a small part of it like you did. Is there any chance in the actual code - the code that you forgot to attach - that you were supposed to use fread() instead of fileread()? What does it say when you do these in the command window:
which fread
which fileread

1 Comment

Actually all these functions fread/fileread are not in my code. I guess MATLAB is using it itself.
Basically if you consider fcn.m as the main function and fcn_tb.m as test bench and then open the workflow advisor, then run till the task fixed point conversion. At that time you get this error. I'll post the entire red part.
Error using fileread (line 27) Could not open file variable. No such file or directory.
Error in C:\MatlabR2013a\R2013a\toolbox\coder\float2fixed\+coder\+internal\Float2FixedConverter.p>Float2FixedConverter.buildDesign/getUserWrittenFunction (line 1666)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\float2fixed\+coder\+internal\Float2FixedConverter.p>Float2FixedConverter.buildDesign (line 1654)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\coder\+coderprivate\Float2FixedManager.p>Float2FixedManager.buildFloatingPointCode (line 102)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\coder\private\fpBuildFloatingPointCode.p>fpBuildFloatingPointCode (line 4)
Error in C:\MatlabR2013a\R2013a\toolbox\coder\coder\emlcprivate.p>emlcprivate (line 16)
Could not open file variable. No such file or directory.
Error in fileread at 27
Error in Float2FixedConverter>buildDesign/getUserWrittenFunction at 1666
Error in Float2FixedConverter>buildDesign at 1654
Error in Float2FixedManager>buildFloatingPointCode at 102
Error in fpBuildFloatingPointCode at 4
Error in emlcprivate at 16

Sign in to comment.

This happens when compiler is not configured; floating2fixedconverter.m needs the compiler;
in matlab command prompt run >>mex -setup command

8 Comments

What should be done if the error persists even after running the 'mex -setup' command? I got the following errors (pasted below) when I ran my code Gcode.m with testbench Gcode_testbench.m, even after running mex setup.
Error using Float2FixedConverter.Float2FixedConverter (line 143) Cannot find design 'Gcode' on the path Error in C:\Program Files\MATLAB\R2013a\toolbox\coder\coder\+coderprivate\Float2FixedManager.p>Float2FixedManager.buildFloatingPointCode (line 77) Error in C:\Program Files\MATLAB\R2013a\toolbox\coder\coder\private\fpBuildFloatingPointCode.p>fpBuildFloatingPointCode (line 4) Error in C:\Program Files\MATLAB\R2013a\toolbox\coder\coder\emlcprivate.p>emlcprivate (line 16) Cannot find design 'Gcode' on the path Error in Float2FixedConverter>Float2FixedConverter at 143 Error in Float2FixedManager>buildFloatingPointCode at 77 Error in fpBuildFloatingPointCode at 4 Error in emlcprivate at 16
-------------------
Cannot find design 'Gcode' on the path.
I would investigate this angle. With what has been provided here there is nothing else to go on. You don't even mention what release you are using.
Yes, I am using R2013a. The code runs fine in Matlab. In the HDL Coder Workflow Advisor, the Define Input Types step runs fine, but Fixed-Point Conversion throws this error.
I had successfully run the filter example (mlhdlc_sfir.m) given in the Getting Started Guide, in which I used the Xilinx (14.7) ISIM Simulator.
I am not able to figure out why the error 'Cannot find design 'Gcode' on the path.' is appearing.
The Gcode.m file calls several functions. I have verified that none of the constructs while, break, continue, return or parfor have been used in Gcode or any function called.
Please let me know if any other information is required.
The tool singled out the following errors: the use of .mexw32 scripts and some unsupported Matlab function calls (tic,toc,fwrite,impz). I will change the code suitably.
I need your confirmation that this is the right approach. Please correct me if I am using the wrong approach for checking HDL code-generation readiness.
Yes, this is the correct approach towards ensuring your code can pass through fixed point conversion. I don't know if it will address your original symptom or not.
Thank you very much for your answer.
About the first error - I had created the project (.prj) file in a separate directory, and this was causing the error 'Cannot find design 'Gcode' on the path.'. Now I have created a new .prj file within the directory containing Gcode.m and the associated functions. The fixed point conversion errors (that the tool had pointed out yesterday) are now directly appearing in the HDL coder screen.

Sign in to comment.

Products

Tags

Asked:

on 20 Jan 2014

Commented:

LRM
on 11 Dec 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!