diff --git a/integration_test/CMakeLists.txt b/integration_test/CMakeLists.txt index b33d6eeb3a30..6d0782b2aafc 100644 --- a/integration_test/CMakeLists.txt +++ b/integration_test/CMakeLists.txt @@ -30,8 +30,6 @@ llvm_canonicalize_cmake_booleans(ESI_RUNTIME) if (ESI_RUNTIME) list(APPEND CIRCT_INTEGRATION_TEST_DEPENDS ESIRuntime - ESIPythonRuntime - esiquery esitester ) diff --git a/integration_test/lit.site.cfg.py.in b/integration_test/lit.site.cfg.py.in index 4d63e8ff3b28..d3cd2c3fcf0d 100644 --- a/integration_test/lit.site.cfg.py.in +++ b/integration_test/lit.site.cfg.py.in @@ -49,7 +49,7 @@ config.iverilog_path = "@IVERILOG_PATH@" config.clang_tidy_path = "@CLANG_TIDY_PATH@" config.have_systemc = "@HAVE_SYSTEMC@" config.esi_runtime = "@ESI_RUNTIME@" -config.esi_runtime_path = "@ESIRuntimePath@" +config.esi_runtime_path = "@ESICppRuntimePath@" config.bindings_python_enabled = @CIRCT_BINDINGS_PYTHON_ENABLED@ config.bindings_tcl_enabled = @CIRCT_BINDINGS_TCL_ENABLED@ config.lec_enabled = "@CIRCT_LEC_ENABLED@" diff --git a/lib/Dialect/ESI/runtime/CMakeLists.txt b/lib/Dialect/ESI/runtime/CMakeLists.txt index adf2e1de0755..24d406e3bf0c 100644 --- a/lib/Dialect/ESI/runtime/CMakeLists.txt +++ b/lib/Dialect/ESI/runtime/CMakeLists.txt @@ -104,7 +104,7 @@ if(ESI_COSIM) find_package(gRPC REQUIRED CONFIG) endif() - add_subdirectory(cosim) + add_subdirectory(cosim_dpi_server) # Inform the runtime code that Cosimulation is enabled. Kinda hacky since all # backends should only need to be linked in. # TODO: Once the hack in the python bindings is remidied, remove this. @@ -112,18 +112,13 @@ if(ESI_COSIM) set(ESICppRuntimeSources ${ESICppRuntimeSources} ${CMAKE_CURRENT_SOURCE_DIR}/cpp/lib/backends/Cosim.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cpp/lib/backends/RpcServer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cosim.proto ) set(ESICppRuntimeBackendHeaders ${ESICppRuntimeBackendHeaders} ${CMAKE_CURRENT_SOURCE_DIR}/cpp/include/esi/backends/Cosim.h - ) - set(ESICppRuntimeLinkLibraries - ${ESICppRuntimeLinkLibraries} - EsiCosimGRPC - ) - set(ESICppRuntimeIncludeDirs - ${ESICppRuntimeIncludeDirs} - ${CMAKE_CURRENT_SOURCE_DIR}/cosim/include + ${CMAKE_CURRENT_SOURCE_DIR}/cpp/include/esi/backends/RpcServer.h ) else() message("-- ESI cosim disabled") @@ -198,6 +193,21 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(ESICppRuntime PRIVATE -Wno-covered-switch-default) endif() +if(ESI_COSIM) + target_link_libraries(ESICppRuntime PUBLIC protobuf::libprotobuf gRPC::grpc++) + set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") + target_include_directories(ESICppRuntime PUBLIC "$") + protobuf_generate( + TARGET ESICppRuntime + PROTOC_OUT_DIR "${PROTO_BINARY_DIR}") + protobuf_generate( + TARGET ESICppRuntime + LANGUAGE grpc + GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc + PLUGIN "protoc-gen-grpc=\$" + PROTOC_OUT_DIR "${PROTO_BINARY_DIR}") +endif() + # The esiquery tool is a simple wrapper around the SysInfo API. add_executable(esiquery ${CMAKE_CURRENT_SOURCE_DIR}/cpp/tools/esiquery.cpp diff --git a/lib/Dialect/ESI/runtime/cosim/cosim.proto b/lib/Dialect/ESI/runtime/cosim.proto similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/cosim.proto rename to lib/Dialect/ESI/runtime/cosim.proto diff --git a/lib/Dialect/ESI/runtime/cosim/CMakeLists.txt b/lib/Dialect/ESI/runtime/cosim/CMakeLists.txt deleted file mode 100644 index c0a1e8857e47..000000000000 --- a/lib/Dialect/ESI/runtime/cosim/CMakeLists.txt +++ /dev/null @@ -1,70 +0,0 @@ -##===- CMakeLists.txt - ESI cosim support ---------------------*- cmake -*-===// -## -##===----------------------------------------------------------------------===// - -set(cosim_collateral - Cosim_DpiPkg.sv - Cosim_Endpoint.sv - Cosim_Manifest.sv - Cosim_MMIO.sv - - driver.sv - driver.cpp -) - -install(FILES - ${cosim_collateral} - DESTINATION cosim - COMPONENT ESIRuntime -) - -add_custom_target(esi-cosim - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_CURRENT_SOURCE_DIR}/esi-cosim.py - ${CIRCT_TOOLS_DIR}/esi-cosim.py) -foreach (cf ${cosim_collateral}) - add_custom_command(TARGET esi-cosim POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_CURRENT_SOURCE_DIR}/${cf} - ${CIRCT_TOOLS_DIR}/../cosim/${cf} - ) -endforeach() -install(FILES - esi-cosim.py - DESTINATION bin - PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ - GROUP_EXECUTE GROUP_READ - WORLD_EXECUTE WORLD_READ - COMPONENT ESIRuntime -) - -add_library(EsiCosimGRPC SHARED "${CMAKE_CURRENT_LIST_DIR}/cosim.proto") -install(TARGETS EsiCosimGRPC DESTINATION lib COMPONENT ESIRuntime) -target_link_libraries(EsiCosimGRPC PUBLIC protobuf::libprotobuf gRPC::grpc++) -set(PROTO_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") -target_include_directories(EsiCosimGRPC PUBLIC "$") - -protobuf_generate( - TARGET EsiCosimGRPC - PROTOC_OUT_DIR "${PROTO_BINARY_DIR}") -protobuf_generate( - TARGET EsiCosimGRPC - LANGUAGE grpc - GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc - PLUGIN "protoc-gen-grpc=\$" - PROTOC_OUT_DIR "${PROTO_BINARY_DIR}") - -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") - -add_library(CosimRpcServer SHARED - lib/RpcServer.cpp -) -target_link_libraries(CosimRpcServer - PUBLIC - EsiCosimGRPC - ESICppRuntime -) -install(TARGETS CosimRpcServer DESTINATION lib COMPONENT ESIRuntime) - -add_subdirectory(cosim_dpi_server) -add_subdirectory(MtiPliStub) diff --git a/lib/Dialect/ESI/runtime/cosim/MtiPliStub/CMakeLists.txt b/lib/Dialect/ESI/runtime/cosim/MtiPliStub/CMakeLists.txt deleted file mode 100644 index 6fc2a9749f0a..000000000000 --- a/lib/Dialect/ESI/runtime/cosim/MtiPliStub/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(SOURCES ${CAPNP_SRCS} DummySvDpi.cpp ) -add_library(MtiPli SHARED ${SOURCES}) -target_include_directories(MtiPli PRIVATE ${CIRCT_INCLUDE_DIR}) -set_target_properties(MtiPli PROPERTIES CXX_VISIBILITY_PRESET "default") -install(TARGETS MtiPli - DESTINATION lib - COMPONENT ESIRuntime -) diff --git a/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/CMakeLists.txt b/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/CMakeLists.txt deleted file mode 100644 index cf7de4c4c477..000000000000 --- a/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -##===- CMakeLists.txt - Core cosim DPI library ----------------*- cmake -*-===// -## -## Define the cosim DPI library if it's enabled. -## -##===----------------------------------------------------------------------===// - -add_library(EsiCosimDpiServer SHARED - DpiEntryPoints.cpp -) -set_target_properties(EsiCosimDpiServer - PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib - CXX_VISIBILITY_PRESET "default" -) -add_dependencies(EsiCosimDpiServer ESICppRuntime MtiPli) -target_link_libraries(EsiCosimDpiServer - PUBLIC - ESICppRuntime - CosimRpcServer - MtiPli -) - -install(TARGETS EsiCosimDpiServer - DESTINATION lib - COMPONENT ESIRuntime -) - -set(ESI_COSIM_PATH $ - CACHE PATH "Path to Cosim DPI shared library") diff --git a/lib/Dialect/ESI/runtime/cosim_dpi_server/CMakeLists.txt b/lib/Dialect/ESI/runtime/cosim_dpi_server/CMakeLists.txt new file mode 100644 index 000000000000..154968ae5def --- /dev/null +++ b/lib/Dialect/ESI/runtime/cosim_dpi_server/CMakeLists.txt @@ -0,0 +1,75 @@ +##===- CMakeLists.txt - Core cosim DPI library ----------------*- cmake -*-===// +## +## Define the cosim DPI library if it's enabled. +## +##===----------------------------------------------------------------------===// + +# Dummy library for a library which should be included by the RTL simulator. +# Dummy is necessary for linking purposes. NOT to be distributed. +add_library(MtiPli SHARED + DummySvDpi.cpp +) +set_target_properties(MtiPli PROPERTIES CXX_VISIBILITY_PRESET "default") + +# DPI calls. +add_library(EsiCosimDpiServer SHARED + DpiEntryPoints.cpp +) +set_target_properties(EsiCosimDpiServer + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + CXX_VISIBILITY_PRESET "default" +) +add_dependencies(EsiCosimDpiServer ESICppRuntime MtiPli) +target_link_libraries(EsiCosimDpiServer + PUBLIC + ESICppRuntime + MtiPli +) + +install(TARGETS EsiCosimDpiServer + DESTINATION lib + COMPONENT ESIRuntime +) + +# RTL cosimulation collateral. +set(cosim_collateral + Cosim_DpiPkg.sv + Cosim_Endpoint.sv + Cosim_Manifest.sv + Cosim_MMIO.sv + + driver.sv + driver.cpp +) + +install(FILES + ${cosim_collateral} + DESTINATION cosim + COMPONENT ESIRuntime +) + +add_custom_target(esi-cosim + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/esi-cosim.py + ${CIRCT_TOOLS_DIR}/esi-cosim.py) +foreach (cf ${cosim_collateral}) + add_custom_command(TARGET esi-cosim POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/${cf} + ${CIRCT_TOOLS_DIR}/../cosim/${cf} + ) +endforeach() + +# ESI simple cosim runner. +install(FILES + esi-cosim.py + DESTINATION bin + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ + COMPONENT ESIRuntime +) +set(ESI_COSIM_PATH $ + CACHE PATH "Path to Cosim DPI shared library") diff --git a/lib/Dialect/ESI/runtime/cosim/Cosim_DpiPkg.sv b/lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_DpiPkg.sv similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/Cosim_DpiPkg.sv rename to lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_DpiPkg.sv diff --git a/lib/Dialect/ESI/runtime/cosim/Cosim_Endpoint.sv b/lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_Endpoint.sv similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/Cosim_Endpoint.sv rename to lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_Endpoint.sv diff --git a/lib/Dialect/ESI/runtime/cosim/Cosim_MMIO.sv b/lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_MMIO.sv similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/Cosim_MMIO.sv rename to lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_MMIO.sv diff --git a/lib/Dialect/ESI/runtime/cosim/Cosim_Manifest.sv b/lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_Manifest.sv similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/Cosim_Manifest.sv rename to lib/Dialect/ESI/runtime/cosim_dpi_server/Cosim_Manifest.sv diff --git a/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/DpiEntryPoints.cpp b/lib/Dialect/ESI/runtime/cosim_dpi_server/DpiEntryPoints.cpp similarity index 99% rename from lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/DpiEntryPoints.cpp rename to lib/Dialect/ESI/runtime/cosim_dpi_server/DpiEntryPoints.cpp index 460d2782fccc..b349e75c509b 100644 --- a/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/DpiEntryPoints.cpp +++ b/lib/Dialect/ESI/runtime/cosim_dpi_server/DpiEntryPoints.cpp @@ -18,7 +18,7 @@ #include "dpi.h" #include "esi/Ports.h" -#include "esi/cosim/RpcServer.h" +#include "esi/backends/RpcServer.h" #include #include diff --git a/lib/Dialect/ESI/runtime/cosim/MtiPliStub/DummySvDpi.cpp b/lib/Dialect/ESI/runtime/cosim_dpi_server/DummySvDpi.cpp similarity index 99% rename from lib/Dialect/ESI/runtime/cosim/MtiPliStub/DummySvDpi.cpp rename to lib/Dialect/ESI/runtime/cosim_dpi_server/DummySvDpi.cpp index bc40cbb352ab..060193e4a926 100644 --- a/lib/Dialect/ESI/runtime/cosim/MtiPliStub/DummySvDpi.cpp +++ b/lib/Dialect/ESI/runtime/cosim_dpi_server/DummySvDpi.cpp @@ -20,7 +20,7 @@ #undef EETERN #define EETERN DPI_EXTERN DPI_DLLESPEC -#include "dpi/svdpi.h" +#include "svdpi.h" #undef NDEBUG #include diff --git a/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/dpi.h b/lib/Dialect/ESI/runtime/cosim_dpi_server/dpi.h similarity index 99% rename from lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/dpi.h rename to lib/Dialect/ESI/runtime/cosim_dpi_server/dpi.h index 2713746527d6..7e353dc04d1d 100644 --- a/lib/Dialect/ESI/runtime/cosim/cosim_dpi_server/dpi.h +++ b/lib/Dialect/ESI/runtime/cosim_dpi_server/dpi.h @@ -15,7 +15,7 @@ #ifndef CIRCT_DIALECT_ESI_COSIM_DPI_H #define CIRCT_DIALECT_ESI_COSIM_DPI_H -#include "dpi/svdpi.h" +#include "svdpi.h" #ifdef WIN32 #define DPI extern "C" __declspec(dllexport) diff --git a/lib/Dialect/ESI/runtime/cosim/driver.cpp b/lib/Dialect/ESI/runtime/cosim_dpi_server/driver.cpp similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/driver.cpp rename to lib/Dialect/ESI/runtime/cosim_dpi_server/driver.cpp diff --git a/lib/Dialect/ESI/runtime/cosim/driver.sv b/lib/Dialect/ESI/runtime/cosim_dpi_server/driver.sv similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/driver.sv rename to lib/Dialect/ESI/runtime/cosim_dpi_server/driver.sv diff --git a/lib/Dialect/ESI/runtime/cosim/esi-cosim.py b/lib/Dialect/ESI/runtime/cosim_dpi_server/esi-cosim.py similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/esi-cosim.py rename to lib/Dialect/ESI/runtime/cosim_dpi_server/esi-cosim.py diff --git a/lib/Dialect/ESI/runtime/cosim/include/dpi/svdpi.h b/lib/Dialect/ESI/runtime/cosim_dpi_server/svdpi.h similarity index 100% rename from lib/Dialect/ESI/runtime/cosim/include/dpi/svdpi.h rename to lib/Dialect/ESI/runtime/cosim_dpi_server/svdpi.h diff --git a/lib/Dialect/ESI/runtime/cosim/include/esi/cosim/RpcServer.h b/lib/Dialect/ESI/runtime/cpp/include/esi/backends/RpcServer.h similarity index 96% rename from lib/Dialect/ESI/runtime/cosim/include/esi/cosim/RpcServer.h rename to lib/Dialect/ESI/runtime/cpp/include/esi/backends/RpcServer.h index bbfc694c4c20..22d4e9a9233c 100644 --- a/lib/Dialect/ESI/runtime/cosim/include/esi/cosim/RpcServer.h +++ b/lib/Dialect/ESI/runtime/cpp/include/esi/backends/RpcServer.h @@ -21,6 +21,7 @@ namespace esi { namespace cosim { +/// TODO: make this a proper backend (as much as possible). class RpcServer { public: ~RpcServer(); diff --git a/lib/Dialect/ESI/runtime/cosim/lib/RpcServer.cpp b/lib/Dialect/ESI/runtime/cpp/lib/backends/RpcServer.cpp similarity index 99% rename from lib/Dialect/ESI/runtime/cosim/lib/RpcServer.cpp rename to lib/Dialect/ESI/runtime/cpp/lib/backends/RpcServer.cpp index 1026e1bbd594..341b7b40a5b1 100644 --- a/lib/Dialect/ESI/runtime/cosim/lib/RpcServer.cpp +++ b/lib/Dialect/ESI/runtime/cpp/lib/backends/RpcServer.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "esi/cosim/RpcServer.h" +#include "esi/backends/RpcServer.h" #include "esi/Utils.h" #include "cosim.grpc.pb.h"