diff --git a/cmake/sim/synopsys/vcs.cmake b/cmake/sim/synopsys/vcs.cmake index 0964998..5884778 100644 --- a/cmake/sim/synopsys/vcs.cmake +++ b/cmake/sim/synopsys/vcs.cmake @@ -1,7 +1,7 @@ include_guard(GLOBAL) function(vcs IP_LIB) - cmake_parse_arguments(ARG "TARGET_PER_IP;NO_RUN_TARGET;GUI" "OUTDIR;EXECUTABLE_NAME;RUN_TARGET_NAME" "VLOGAN_ARGS;VHDLAN_ARGS;VCS_ARGS;RUN_ARGS" ${ARGN}) + cmake_parse_arguments(ARG "TARGET_PER_IP;NO_RUN_TARGET;GUI" "OUTDIR;EXECUTABLE_NAME;RUN_TARGET_NAME;TOP_MODULE" "VLOGAN_ARGS;VHDLAN_ARGS;VCS_ARGS;RUN_ARGS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -75,31 +75,33 @@ function(vcs IP_LIB) set(SIM_EXEC_PATH ${OUTDIR}/${ARG_EXECUTABLE_NAME}) ## VCS command for compiling executable - set(__vcs_cmd vcs - -full64 - -q - ${__lib_args} - -o ${SIM_EXEC_PATH} - ${ARG_VCS_ARGS} - ${LIBRARY}.${ARG_TOP_MODULE} - # $<$:-gui> + if(NOT TARGET ${IP_LIB}_vcs) + set(__vcs_cmd vcs + -full64 + -q + ${__lib_args} + -o ${SIM_EXEC_PATH} + ${ARG_VCS_ARGS} + ${LIBRARY}.${ARG_TOP_MODULE} + # $<$:-gui> + ) + set(DESCRIPTION "Compile testbench ${IP_LIB} with ${CMAKE_CURRENT_FUNCTION}") + set(STAMP_FILE "${BINARY_DIR}/${IP_LIB}_vcs.stamp") + add_custom_command( + OUTPUT ${SIM_EXEC_PATH} ${STAMP_FILE} + COMMAND ${__vcs_cmd} + COMMAND touch ${STAMP_FILE} + COMMENT ${DESCRIPTION} + BYPRODUCTS ${OUTDIR}/csrc ${OUTDIR}/${ARG_EXECUTABLE_NAME}.daidir + WORKING_DIRECTORY ${OUTDIR} + DEPENDS ${__comp_tgts} ${VCS_COMPLIB_STAMP_FILE} ) - set(DESCRIPTION "Compile testbench ${IP_LIB} with ${CMAKE_CURRENT_FUNCTION}") - set(STAMP_FILE "${BINARY_DIR}/${IP_LIB}_vcs.stamp") - add_custom_command( - OUTPUT ${SIM_EXEC_PATH} ${STAMP_FILE} - COMMAND ${__vcs_cmd} - COMMAND touch ${STAMP_FILE} - COMMENT ${DESCRIPTION} - BYPRODUCTS ${OUTDIR}/csrc ${OUTDIR}/${ARG_EXECUTABLE_NAME}.daidir - WORKING_DIRECTORY ${OUTDIR} - DEPENDS ${__comp_tgts} ${VCS_COMPLIB_STAMP_FILE} - ) - add_custom_target(${IP_LIB}_vcs - DEPENDS ${STAMP_FILE} ${IP_LIB} - ) - set_property(TARGET ${IP_LIB}_vcs PROPERTY DESCRIPTION ${DESCRIPTION}) + add_custom_target(${IP_LIB}_vcs + DEPENDS ${STAMP_FILE} ${IP_LIB} + ) + set_property(TARGET ${IP_LIB}_vcs PROPERTY DESCRIPTION ${DESCRIPTION}) + endif() set(__vcsrun_cmd ${SIM_EXEC_PATH} ${ARG_RUN_ARGS}) if(NOT ARG_NO_RUN_TARGET) diff --git a/cmake/sim/xilinx/vivado_sim.cmake b/cmake/sim/xilinx/vivado_sim.cmake index f67f962..db68f7e 100644 --- a/cmake/sim/xilinx/vivado_sim.cmake +++ b/cmake/sim/xilinx/vivado_sim.cmake @@ -1,7 +1,7 @@ include_guard(GLOBAL) function(vivado_sim IP_LIB) - cmake_parse_arguments(ARG "TARGET_PER_IP;NO_RUN_TARGET;GUI" "RUN_TARGET_NAME" "XVLOG_ARGS;XVHDL_ARGS;XELAB_ARGS;XSIM_ARGS;RUN_ARGS" ${ARGN}) + cmake_parse_arguments(ARG "TARGET_PER_IP;NO_RUN_TARGET;GUI" "RUN_TARGET_NAME;TOP_MODULE" "XVLOG_ARGS;XVHDL_ARGS;XELAB_ARGS;XSIM_ARGS;RUN_ARGS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -68,41 +68,43 @@ function(vivado_sim IP_LIB) endif() endforeach() - get_ip_sources(SOURCES ${IP_LIB} SYSTEMVERILOG VERILOG VHDL) - ## Xelab command for elaborating simulation - set(__xelab_cmd COMMAND xelab - ${ARG_XELAB_ARGS} - ${__lib_args} - work.${IP_NAME} - # -work ${OUTDIR}/${LIBRARY} + if(NOT TARGET ${IP_LIB}_vivado_sim) + get_ip_sources(SOURCES ${IP_LIB} SYSTEMVERILOG VERILOG VHDL) + ## Xelab command for elaborating simulation + set(__xelab_cmd COMMAND xelab + ${ARG_XELAB_ARGS} + ${__lib_args} + ${LIBRARY}.${ARG_TOP_MODULE} + # -work ${OUTDIR}/${LIBRARY} + ) + + ### Clean files: + # * xelab.log, xelab.pb + set(__clean_files + ${OUTDIR}/xelab.log + ${OUTDIR}/xelab.pb + ${OUTDIR}/xsim.dir/${LIBRARY}.${IP_NAME} ) - ### Clean files: - # * xelab.log, xelab.pb - set(__clean_files - ${OUTDIR}/xelab.log - ${OUTDIR}/xelab.pb - ${OUTDIR}/xsim.dir/${LIBRARY}.${IP_NAME} - ) + set(DESCRIPTION "Compile testbench ${IP_LIB} with ${CMAKE_CURRENT_FUNCTION} xelab") + set(STAMP_FILE "${BINARY_DIR}/${IP_LIB}_${CMAKE_CURRENT_FUNCTION}.stamp") + add_custom_command( + # OUTPUT ${SIM_EXEC_PATH} ${STAMP_FILE} + OUTPUT ${STAMP_FILE} + COMMAND ${__xelab_cmd} + COMMAND touch ${STAMP_FILE} + COMMENT ${DESCRIPTION} + BYPRODUCTS ${__clean_files} + WORKING_DIRECTORY ${OUTDIR} + DEPENDS ${__comp_tgts} ${SOURCES} + COMMAND_EXPAND_LISTS + ) - set(DESCRIPTION "Compile testbench ${IP_LIB} with ${CMAKE_CURRENT_FUNCTION} xelab") - set(STAMP_FILE "${BINARY_DIR}/${IP_LIB}_${CMAKE_CURRENT_FUNCTION}.stamp") - add_custom_command( - # OUTPUT ${SIM_EXEC_PATH} ${STAMP_FILE} - OUTPUT ${STAMP_FILE} - COMMAND ${__xelab_cmd} - COMMAND touch ${STAMP_FILE} - COMMENT ${DESCRIPTION} - BYPRODUCTS ${__clean_files} - WORKING_DIRECTORY ${OUTDIR} - DEPENDS ${__comp_tgts} ${SOURCES} - COMMAND_EXPAND_LISTS + add_custom_target(${IP_LIB}_vivado_sim + DEPENDS ${STAMP_FILE} ${IP_LIB} ) - - add_custom_target(${IP_LIB}_vivado_sim - DEPENDS ${STAMP_FILE} ${IP_LIB} - ) - set_property(TARGET ${IP_LIB}_vivado_sim PROPERTY DESCRIPTION ${DESCRIPTION}) + set_property(TARGET ${IP_LIB}_vivado_sim PROPERTY DESCRIPTION ${DESCRIPTION}) + endif() ### Clean files: