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

HDL Coderhdlerror

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?

Best 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.