Skip to content

Commit

Permalink
VCS and vivado_sim, check if elaborate targets already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Risto97 committed Jan 9, 2025
1 parent f74814a commit 82fecc3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 56 deletions.
50 changes: 26 additions & 24 deletions cmake/sim/synopsys/vcs.cmake
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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}
# $<$<BOOL:${ARG_GUI}>:-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}
# $<$<BOOL:${ARG_GUI}>:-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)
Expand Down
66 changes: 34 additions & 32 deletions cmake/sim/xilinx/vivado_sim.cmake
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 82fecc3

Please sign in to comment.