@@ -197,7 +197,7 @@ function(cocotb IP_LIB)
197197 ELABORATE_ARGS -access +rwc -timescale ${ARG_TIMESCALE} -loadvpi ${COCOTB_VPI_PATH} :vlog_startup_routines_bootstrap -loadvhpi ${COCOTB_VHPI_PATH} :cocotbvhpi_entry_point
198198 SV_COMPILE_ARGS -DCOCOTB_SIM=1
199199 )
200- set (sim_run_cmd ${SIM_RUN_CMD } ${ARG_RUN_ARGS} )
200+ set (sim_run_cmd ${SOCMAKE_SIM_RUN_CMD } ${ARG_RUN_ARGS} )
201201 set (sim_build_dep ${IP_LIB} _xcelium)
202202 message (DEBUG "COCOTB: Xcelium run command: ${sim_run_cmd} " )
203203 elseif (${ARG_SIM} STREQUAL modelsim OR ${ARG_SIM} STREQUAL questa)
@@ -233,7 +233,7 @@ function(cocotb IP_LIB)
233233 SV_COMPILE_ARGS +define+COCOTB_SIM=1
234234 RUN_ARGS +define+COCOTB_SIM=1
235235 )
236- set (sim_run_cmd ${SIM_RUN_CMD } ${ARG_RUN_ARGS} )
236+ set (sim_run_cmd ${S2IM_RUN_CMD } ${ARG_RUN_ARGS} )
237237 set (sim_build_dep ${IP_LIB} _vcs)
238238 message (DEBUG "COCOTB: VCS run command: ${sim_run_cmd} " )
239239 else ()
@@ -249,12 +249,23 @@ function(cocotb IP_LIB)
249249 # Default parameters based on cocotb Makefile.inc
250250 set (COCOTB_RESULTS_FILE ${OUTDIR} /results.xml)
251251
252- set (__sim_run_cmd
253- PYTHONPATH=${PYTHONPATH}
254- MODULE=${ARG_COCOTB_MODULE}
255- COCOTB_RESULTS_FILE=${COCOTB_RESULTS_FILE}
256- ${sim_run_cmd}
257- )
252+ set (__sim_run_cmd ${sim_run_cmd} )
253+ list (FIND __sim_run_cmd "&&" _and_index)
254+ if (_and_index GREATER -1)
255+ math (EXPR _insert_index "${_and_index} + 1" )
256+ list (INSERT __sim_run_cmd ${_insert_index}
257+ PYTHONPATH=${PYTHONPATH}
258+ MODULE=${ARG_COCOTB_MODULE}
259+ COCOTB_RESULTS_FILE=${COCOTB_RESULTS_FILE}
260+ )
261+ else ()
262+ set (__sim_run_cmd
263+ PYTHONPATH=${PYTHONPATH}
264+ MODULE=${ARG_COCOTB_MODULE}
265+ COCOTB_RESULTS_FILE=${COCOTB_RESULTS_FILE}
266+ ${sim_run_cmd}
267+ )
268+ endif ()
258269
259270 if (NOT ARG_NO_RUN_TARGET)
260271 if (ARG_RUN_TARGET_NAME)
@@ -293,12 +304,25 @@ function(cocotb IP_LIB)
293304 # Default parameters based on cocotb Makefile.inc
294305 set (COCOTB_RESULTS_FILE ${OUTDIR} /results.xml)
295306
296- set (__sim_run_cmd
297- PYTHONPATH=${PYTHONPATH}
298- MODULE=${ARG_COCOTB_MODULE}
299- COCOTB_RESULTS_FILE=${COCOTB_RESULTS_FILE}
300- ${sim_run_cmd}
301- )
307+ set (__sim_run_cmd ${sim_run_cmd} )
308+ list (FIND __sim_run_cmd "&&" _and_index)
309+ if (_and_index GREATER -1)
310+ math (EXPR _insert_index "${_and_index} + 1" )
311+ list (INSERT __sim_run_cmd ${_insert_index}
312+ PYTHONPATH=${PYTHONPATH}
313+ MODULE=${ARG_COCOTB_MODULE}
314+ COCOTB_RESULTS_FILE=${COCOTB_RESULTS_FILE}
315+ TESTCASE=${ARG_COCOTB_MODULE} _test_${test_num}
316+ )
317+ else ()
318+ set (__sim_run_cmd
319+ PYTHONPATH=${PYTHONPATH}
320+ MODULE=${ARG_COCOTB_MODULE}
321+ COCOTB_RESULTS_FILE=${COCOTB_RESULTS_FILE}
322+ TESTCASE=${ARG_COCOTB_MODULE} _test_${test_num}
323+ ${sim_run_cmd}
324+ )
325+ endif ()
302326
303327 if (NOT ARG_NO_RUN_TARGET)
304328 if (ARG_RUN_TARGET_NAME)
@@ -311,7 +335,7 @@ function(cocotb IP_LIB)
311335 # Add a custom target that depends on the executable and stamp file
312336 add_custom_target (${CUSTOM_TARGET_NAME}
313337 COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTDIR}
314- COMMAND TESTCASE=${ARG_COCOTB_MODULE}_test_${test_num} ${__sim_run_cmd}
338+ COMMAND ${__sim_run_cmd}
315339 BYPRODUCTS ${COCOTB_RESULTS_FILE}
316340 DEPENDS ${sim_build_dep} ${cocotb_custom_sim_deps}
317341 COMMENT ${DESCRIPTION}
@@ -325,3 +349,4 @@ function(cocotb IP_LIB)
325349 set (SIM_BUILD_DEP ${sim_build_dep} PARENT_SCOPE )
326350
327351endfunction ()
352+
0 commit comments