Integrating Cocotb to Quartus using Native link
To integrate cocotb to Quartus Prime Native link and Questa, among a few environment variables needed, one has to set the following `vsim` option:
`-foreign "cocotb_init $(cocotb-config --lib-name-path fli questa)"`
see here:
https://docs.cocotb.org/en/stable/custom_flows.html
This needs to be actually slightly adapted to questa, and the following option should be used instead:
`-foreign \"cocotb_init [exec cocotb-config --lib-name-path fli questa]\"`
With all this information in hand, I try to add `questa=-foreign \"cocotb_init [exec cocotb-config --lib-name-path fli questa]\"` in Assignments >> Settings >> EDA Tools Settings >> Simulation Flow Settings >> Simulation Options, and I get the following error in Quartus:
Info(125063): set_global_assignment -name EDA_EXTRA_SIM_OPTION "questa=-foreign \\\"cocotb_init [exec cocotb-config --lib-name-path fli questa]\\\"" -section_id eda_simulation
Error(125048): Error reading Quartus Prime Settings file /home/msilvaol/LATOME_HLS/firmware/src/latome_fw/s2p_bram/s2p_bram.qsf, line 49 And then when I try to start the simulation, I get the following error:
Error(23031): Evaluation of Tcl script /home/sw/intel/25.3/quartus/common/tcl/internal/nativelink/qnativesim.tcl unsuccessfulThe workaround I have at the moment is to do the following:
I set Assignments >> Settings >> EDA Tools Settings >> Simulation Flow Settings >> Simulation Options to `questa=COCOTB_CFG`
Then, I start the simulation that fails because COCOTB_CFG is not a valid vsim option.
I open the file `./simulation/questa/rtlsim/s2p_bram_run_msim_rtl_vhdl.do`, and I replace the line 42
from:
`
eval "vsim -t 1ps $pd_libs -L work -L rtl_work -voptargs=\"+acc\" COCOTB_CFG $ELAB_OPTIONS $DPI_LIBRARIES_ELAB s2p_bram_showahead"
`
to the actual option that I tried to set in Quartus Prime, as follows:
eval "vsim -t 1ps $pd_libs -L work -L rtl_work -voptargs=\"+acc\" -foreign \"cocotb_init [exec cocotb-config --lib-name-path fli questa]\" $ELAB_OPTIONS $DPI_LIBRARIES_ELAB s2p_bram_showahead"
Then, I run the .do script again in questa and the simulation with cocotb works using Quartus Prime as the build flow. However, every time the simulation is started again from Quartus Prime, the generated scripts are overwritten, and I have to edit the automatically generated file again.
It seems Quartus is parsing the simulation option and adding escape characters in a way that the automatically generated TCL code no longer works.
Can you please point out a way that I can set the simulation option correctly?