readmemb verilog
In my case the input file "code.vec" is stored in the same folder as the testbench. This is working fine for several designs which I simulate with ModelSim.
Everyone has there own setup ideas for ModelSim. My particular setup is to copy all the source code, vector files, and and testbench into a common folder. I point ModelSim at that folder. The ModelSim program will create a subdirectory called "work" which contains its own data and compiled versions of my code. I do not use this folder for any actual FPGA builds. The reason is that ModelSim has a nasty habit of trashing its folder and project on a crash. By having my FPGA build in Xilinx separate, I am able to quickly recover.
Use the $fread and $ferror commands from my previous post. If you do not have an error on opening the file, then the issue is NOT where the file is but reading from the already open file.
---- Steve
Added after 1 hours 12 minutes:
A couple other things occurred to me.
1. I checked my project settings. Under each source code file, you can choose the language version to use. I am writing in Verilog and I chose the "default" setting rather an explicitly choosing the Verilog version.
2. If you are new to ModelSim, it has a rather annoying feature. If you add an existing source code file, then it has two options. A: Reference from current location, or B: Copy to Project Directory. I have been burnt several times by choosing the "Copy to Project Directory" . When you choose this, you MUST use ModelSim to do ALL future edits. The reason is it copies the file to a subfolder in the project directory and does NOT monitor when the original file has changed. Therefore, you end up building with the old original file and not the new edits, so nothing you try ever fixes anything. When you change a source code file, the tree view MUST should this file changing from a green check mark to a blue question mark. It can take a few seconds for the PC to recognize the change, but it must change. If editting files do not show up with the question mark, then it is NOT building with the file you are editting.
---- Steve