function(add_verilog_sim)
    set(options "")
    set(onevalueargs NAME TOP_MODULE)
    set(multivalueargs FILES OPTIONS)
    cmake_parse_arguments(ADD_VERILOG_SIM "${options}" "${onevalueargs}" "${multivalueargs}" ${ARGN})
    if (ADD_VERILOG_SIM_TOP_MODULE)
        set(ADD_VERILOG_SIM_TOP_MODULE "-s${ADD_VERILOG_SIM_TOP_MODULE}")
    endif()
    add_custom_command(OUTPUT ${ADD_VERILOG_SIM_NAME}
                      COMMAND ${IVERILOG} -o ${CMAKE_BINARY_DIR}/${ADD_VERILOG_SIM_NAME} ${ADD_VERILOG_SIM_TOP_MODULE} ${ADD_VERILOG_SIM_FILES} ${IVERILOG_FLAGS} ${ADD_VERILOG_SIM_OPTIONS}
                      DEPENDS ${ADD_VERILOG_SIM_FILES})
endfunction()
