VHDL/ModelSim - Could Not Find Entity - simulation

I am trying to simulate my VHDL file, but am running into the following error:
# ** Error: (vcom-11) Could not find work.lab1.
#
# ** Error: (vcom-1195) Cannot find expanded name "work.lab1".
#
# ** Error: Unknown expanded name.
# ** Error: VHDL Compiler exiting
# ** Error: c:/altera/12.1/modelsim_ase/win32aloem/vcom failed.
# Error in macro ./DE2_TOP_run_msim_rtl_vhdl.do line 8
# c:/altera/12.1/modelsim_ase/win32aloem/vcom failed.
# while executing
# "vcom -93 -work work"
I compiled the code successfully through both Quartus II and the ModelSim compiler before attempting to simulate. I do have a lab1 entity and architecture in my code (I can even see it in the Design Units tab of the Quartus Project Navigator), so I don't really understand this error. Anyone know what's causing this?

When the simulator is compiling the toplevel (DE2_TOP) it want to know how the used components are like. So, you should have compiled the lowerlevel components before compiling the upperlevel components.
What I do most of the times to fix this is compiling all components in correct order and then use the 'vmake' ('vmake -work work > work.vmake') command of Modelsim to generate a makefile out of the library (work). Once you have the makefile you can execute it with (make -f work.vmake). And all files will be compiled in order.
Note: Verilog is much more relaxed in those things...

Related

How to fix error [USF-XSim-62] when simulating project with Vivado Xilinx (also using DPI-C)?

I have a Verilog project that makes use of a testbench written in SystemVerilog and a few imports/exports of functions through the DPI-C interface.
When attempting to simulate, I get an xsim error (as far as I can tell) and the simulation stops. I have struggled with this issue for a while, and there is no specific info given in the Vivado terminal together with the error.
The exact error received is:
ERROR: [USF-XSim-62] 'elaborate' step failed with error(s) while executing 'path/to/proj/<proj_name>/<proj_name>.sim/sim_1/behav/xsim/elaborate.bat' script. Please check that the file has the correct 'read/write/execute' permissions and the Tcl console output for any other possible errors or warnings.
ERROR: [Vivado 12-4473] Detected error while running simulation. Please correct the issue and retry this operation.
launch_simulation: Time (s): cpu = 00:00:01 ; elapsed = 00:00:06 . Memory (MB): peak = 1412.562 ; gain = 0.000
ERROR: [Common 17-39] 'launch_simulation' failed due to earlier errors.
Not only is the file created by Vivado (so it should have permissions to access it), but this error appears and disappears at random. For example, modifying the testbench file and then modifying it back to original (to force recompilation) sometimes allows the simulation to run, seemingly at random.
What is even more confusing is that there are some "safe states" of the testbench code that allow the simulation to always run. My initial hunch was that it was related to the DPI-C functions, but I tried altering the files in many ways and I didn't find any obvious correlation.
Mentions
I am using Vivado 2021.2
I have implemented an automated TCL script to compile the C files using xsc and insert them into the project directory
I am using xelab command line arguments to link the C code compiled with xsc: -sv_root path/to/xsc -sv_lib dpi.
Update
When I run xelab by itself (with -v), it gives the following output (after static elaboration and simulation data flow analysis passed):
SDG Object Count: 1284, SDG Object Memory Usage: 133 KB.
Time Resolution for simulation is 1ps
Compiling package std.std
ICR Memory Usage: 491KB, 8192KB
Compiling package xil_defaultlib.$unit_tb_sv
ICR Memory Usage: 491KB, 8192KB
Compiling module xil_defaultlib.decoder_interface
ICR Memory Usage: 500KB, 8192KB
Compiling module xil_defaultlib.lut_biases
ICR Memory Usage: 584KB, 8192KB
Compiling module xil_defaultlib.saturate_default
ICR Memory Usage: 758KB, 8192KB
Compiling module xil_defaultlib.variable_nodes_default
ICR Memory Usage: 1832KB, 8192KB
Compiling module xil_defaultlib.check_nodes_default
INFO: [XSIM 43-4009] "abs_prev_proc_elem", written at line 26 in file "D:/Projects/Matlab/NN_BP_BCH/nn-min-sum-decoding/hardware/check_nodes.v", has also been read in this always_comb/always_latch block and is not added to the sensitivity list.
INFO: [XSIM 43-4009] "reg_min", written at line 30 in file "D:/Projects/Matlab/NN_BP_BCH/nn-min-sum-decoding/hardware/check_nodes.v", has also been read in this always_comb/always_latch block and is not added to the sensitivity list.
INFO: [XSIM 43-4009] "reg_sign", written at line 31 in file "D:/Projects/Matlab/NN_BP_BCH/nn-min-sum-decoding/hardware/check_nodes.v", has also been read in this always_comb/always_latch block and is not added to the sensitivity list.
INFO: [XSIM 43-4009] "temp_reg", written at line 52 in file "D:/Projects/Matlab/NN_BP_BCH/nn-min-sum-decoding/hardware/check_nodes.v", has also been read in this always_comb/always_latch block and is not added to the sensitivity list.
ICR Memory Usage: 6896KB, 8192KB
Compiling module xil_defaultlib.interm_layer
ICR Memory Usage: 6902KB, 8192KB
Compiling module xil_defaultlib.llr_to_out_default
ICR Memory Usage: 6927KB, 8192KB
Compiling module xil_defaultlib.out_layer_default
ICR Memory Usage: 7674KB, 8192KB
Compiling module xil_defaultlib.decoder_top_default
ICR Memory Usage: 8281KB, 16384KB
Compiling module xil_defaultlib.tb
child killed: unknown signal

How to solve Taskhash mismatch and metadata is not deterministic in Yocto project build?

I am facing "Taskhash mismatch" & "The metadata is not deterministic and this needs to be fixed" error in Yocto project build. This issue arises without any obvious reasons. With a perfectly good source code repo, the build is success sometime, while it fails some time. There is no change in source code/recipe or any other build parameters.
Error log:
ERROR: When reparsing /home/user/my_project/yocto/sub_project-yocto/meta-subproject/meta-base/recipes-core/sub_project-rootfs-base/sub_project-rootfs-base.bb:do_populate_lic, the basehash value changed from e0bfa2ad64f24d189d23f9d84918c74a7253e0d7e9c7fea4e3346cbc473d43da to c108c533ec82c43aa15730e4ca9c9838f87133e63417f40af0de8ca8cb43f51a. The metadata is not deterministic and this needs to be fixed.
ERROR: The following commands may help:
ERROR: $ bitbake sub_project-rootfs-base -cdo_populate_lic -Snone
ERROR: Then:
ERROR: $ bitbake sub_project-rootfs-base -cdo_populate_lic -Sprintdiff
ERROR: sub_project-rootfs-base-1.0+gitAUTOINC+db239d9f5b-r2 do_package_qa: Taskhash mismatch 87d8616452c2be01481a9034e9147f0270a57a3f64f85cde65076863b8123c7c versus 9a7fd3b27e62140001d77ab75dbc2026dac8e6c8ca93a487b1857a76f2b6b2yy for /home/user/my_project/yocto/sub_project-yocto/meta-subproject/meta-base/recipes-core/sub_project-rootfs-base/sub_project-rootfs-base.bb:do_package_qa
ERROR: Taskhash mismatch 87d8616452c2be01481a9034e9147f0270a57a3f64f85cde65076863b8123c7c versus 9a7fd3b27e62140001d77ab75dbc2026dac8e6c8ca93a487b1857a76f2b6b2yy for /home/user/my_project/yocto/sub_project-yocto/meta-subproject/meta-base/recipes-core/sub_project-rootfs-base/sub_project-rootfs-base.bb:do_package_qa
ERROR: sub_project-rootfs-base-1.0+gitAUTOINC+db239d9f5b-r2 do_package_write_rpm: Taskhash mismatch 9a7fd3b27e62140001d77ab75dbc2026dac88qc8ca93a487b1857a76f2b6b2yy versus 9a7fd3b27e6217l0001d77ab75dbc2026dac8e6c8ca93a487b1857a76f2b6b2yy for /home/user/my_project/yocto/sub_project-yocto/meta-subproject/meta-base/recipes-core/sub_project-rootfs-base/sub_project-rootfs-base.bb:do_package_write_rpm
ERROR: Taskhash mismatch 9a7fd3b27e62140001d77ab75dbc2026dac88qc8ca93a487b1857a76f2b6b2yy versus 9a7fd3b27e6217l0001d77ab75dbc2026dac8e6c8ca93a487b1857a76f2b6b2yy for /home/user/my_project/yocto/sub_project-yocto/meta-subproject/meta-base/recipes-core/sub_project-rootfs-base/sub_project-rootfs-base.bb:do_package_write_rpm
I resolved this issue by doing two of the following action.
Clean the recipe which throws error during build using following command
bitbake -c cleansstate sub_project-rootfs-base
Update the bb file timestamp by doing empty write or by touching file.
Open the bb file using your editor - vim /home/user/my_project/yocto/sub_project-yocto/meta-subproject/meta-base/recipes-core/sub_project-rootfs-base/sub_project-rootfs-base.bb
Write the file by clicking save button or in vim writing ":w" command
Close the file using "x" button or ":q" command.
Rebuild the project as usual.
Edit : In case there are multiple bitbake recipes showing this error, you can touch all bb files and build again. Go into your yocto folder and run following command. This will take some to touch all file and significantly higher time to rebuild the project.
find . -type f -name "*.bb" -exec touch {} +

How to load shared library created in Matlab

I tried to create an OpenModelica model with liquid flow and Media.
And I have a function in Matlab that calculates the PDE (partial differential equation) in pdetool.
I would like to create a shared dynamic library (.so file) in Matlab by MCR and load it in the model.
My platform: OpenModelica used on Linux or Mac OS. MCR on Linux and Mac OS installed.
In Matlab I can generate only DLL (may be it's possible to generate libmyfunc.so?).
When I try to compile the model with extern C function I got an error:
#omc +s test_matlab_so.mo func_mathlab.mo
#make -f test_matlab_so.makefile
/usr/bin/clang -Wimplicit-function-declaration -O0 -falign-functions -march=native -I"/opt/openmodelica/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o test_matlab_so_functions.o test_matlab_so_functions.c
clang: warning: optimization flag '-falign-functions' is not supported
clang: warning: argument unused during compilation: '-falign-functions'
In file included from test_matlab_so_functions.c:7:
In file included from ./test_matlab_so_includes.h:4:
./shared_train/src/lib_summ.c:90:8: warning: implicit declaration of function 'GetModuleFileName' is invalid in C99 [-Wimplicit-function-declaration]
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:90:26: warning: implicit declaration of function 'GetModuleHandle' is invalid in C99 [-Wimplicit-function-declaration]
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:90:55: error: use of undeclared identifier 'path_to_dll'
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:90:68: error: use of undeclared identifier '_MAX_PATH'
if (!GetModuleFileName(GetModuleHandle("lib_summ"), path_to_dll, _MAX_PATH))
^
./shared_train/src/lib_summ.c:94:37: error: use of undeclared identifier 'path_to_dll'
mclGetEmbeddedCtfStream(path_to_dll);
^
test_matlab_so_functions.c:19:16: warning: implicit declaration of function '_mlfSumm' is invalid in C99 [-Wimplicit-function-declaration]
_v_out_ext = _mlfSumm(_v_a_ext, _v_b_ext);
^
3 warnings and 3 errors generated.
make: *** [test_matlab_so_functions.o] Error 1
Can someone help me with integrating OpenModelica and Matlab?
I don't have much experience with Linux but I did the same thing in Windows using MCR. Check this out:
http://de.mathworks.com/matlabcentral/answers/94471-how-do-i-create-a-c-c-shared-library-with-matlab-compiler-that-can-be-used-in-a-microsoft-visual-c
When you do this, you will get a DLL as well as a static library. You need to copy both of them into the folder that your modelica code is located at and then set the library in the "Library" attibute of your modelica function which calls the external function.
Keep in mind that if you are using a 64 or 32 bit dymola, you are supposed to create the DLL using the same version of matlab correspondingly.

Unexpected EOF when linking Arduino project in Eclipse on OS X

I have been trying to link Arduino and Eclipse, and I feel like I'm close.
Where should I start looking for this?
Similar errors have been caused by extra/incomplete quote blocks (according to google searches). I have already dug through my AVR linker settings looking for quotes, but haven't had much luck.
Am I looking in the right place?
Which files should I check?
I have already looked in the file I have written myself (in this case, the basic Arduino blink program).
**** Build of configuration Release for project C64_Arduino1 ****
make all
Building target: C64_Arduino1.elf
Invoking: AVR C++ Linker
avr-gcc --cref -s -Os -o"C64_Arduino1.elf" ./C64_Arduino1.o ./CDC.o ./HID.o
./HardwareSerial.o ./Print.o ./Stream.o ./Tone.o ./USBCore.o ./WInterrupts.o ./WMath.o ./WString.o ./malloc.o ./wiring.o ./wiring_analog.o ./wiring_digital.o ./wiring_pulse.o
./wiring_shift.o -l"Arduino_Mega_2560_or_Mega_ADK" -lm -L/Users/Chet/Desktop/Chet's Shit/Side Projects/Programming/C64_Arduino1/Release -L"/Users/Chet/Desktop/Chet's Shit/Side
Projects/Programming/C64_Arduino1" -mmcu=atmega2560
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [C64_Arduino1.elf] Error 2
**** Build Finished ****
EDIT:
I have commented out all of my code (including #include's) except the main (which is empty) and I still get the error. I have set up my IDE as specified Here and also Here. Still nothing.
Looking at the actual error message:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
I can see that the problem is most likely due to some kind of Makefile syntax error.
When you write a make rule such like:
foo:
touch foo
What make does, it first checkes whether file called foo exists already, if not, then it runs command /bin/sh -c 'touch foo'. So the line where we said touch foo should have valid shell script syntax.
Looking at the command that you ended up running:
avr-gcc --cref -s -Os -o"C64_Arduino1.elf" ./C64_Arduino1.o ./CDC.o ./HID.o
./HardwareSerial.o ./Print.o ./Stream.o ./Tone.o ./USBCore.o ./WInterrupts.o ./WMath.o ./WString.o ./malloc.o ./wiring.o ./wiring_analog.o ./wiring_digital.o ./wiring_pulse.o
./wiring_shift.o -l"Arduino_Mega_2560_or_Mega_ADK" -lm -L/Users/Chet/Desktop/Chet's Shit/Side Projects/Programming/C64_Arduino1/Release -L"/Users/Chet/Desktop/Chet's Shit/Side
Projects/Programming/C64_Arduino1" -mmcu=atmega2560
I can see that the issue is with the ' character in some of the directory paths. You should either escape it (as in "/Users/Chet/Desktop/Chet\'s Shit") or, as a quick work-around symlink or move the directory.
As a general methodology tip, you should first check whether everything works in CLI, and then move on to teaching Eclipse what commands it should run.
Also, I would consider using the tool called ino instead of make, it might just work with minimum configuration. I have had some experience replacing Arduino IDE with just a Makefile, but it gets hairy when you need to use different boards and perhaps several connected at the same time. Give ino a try, it looks quite promising.

Perl Cross Compilation: MAKE

I've been trying to Cross Compile Perl-5.14.2 for NetBSD target from Linux machine.
Configure script successfully invoked with following options,
./Configure -des -Dusecrosscompile
-Dtargetarch=netbsd
-Dosvers=3.0.0
-Dtargethost=10.184.22.48
-Dtargetuser=username
-Dusrinc=.../sb1-mips/usr/include
-Dlibpth=.../xc-sb1-mips/netbsd/Lib/lib
-Dcc=.../mips64-netbsdelf-gcc
Once after Configured, make wasn't successful.
It breaks at different places right from creating miniperlmain.o file.
For example following error occurred while generating gv.o file:
gv.c: In function `Perl_try_amagic_un':
gv.c:2018: error: void value not ignored as it ought to be
gv.c:2029: error: void value not ignored as it ought to be
gv.c:2029: warning: cast from pointer to integer of different size
gv.c: In function `Perl_try_amagic_bin':
gv.c:2061: error: void value not ignored as it ought to be
gv.c:2063: error: void value not ignored as it ought to be
make: *** [gv.o] Error 1
Now to get rid of these errors I've passed two flags namely -DPERL_IMPLICIT_CONTEXT and -DPERL_GCC_BRACE_GROUPS_FORBIDDEN to C Compiler CCFLAGS which solved the problem.
Since it is a custom build, want to know about all of the CCFLAGS that have to be passed in order to achieve a successful build?
What does each flag mean?
Is their any documentation available?
Use vagrant. It has some OpenBSD and FreeBSD images. Hopefuly those will be compatible with NetBSD.
You can get a build environment very fast with that. Then you can transfer and build your code happily :)