mirror of https://github.com/llvm/circt.git
[ESI] [Cosim DPI] Cap'nProto install and schema generation (#216)
* [ESI] [Cosim DPI] Capn'Proto install and schema generation This is the second in a series to merge #213. This is the capnp schema generation component. * Added header comment.
This commit is contained in:
parent
0b0fe60877
commit
37f809c5e9
|
@ -52,6 +52,9 @@ add_custom_target(circt-headers)
|
|||
set_target_properties(circt-headers PROPERTIES FOLDER "Misc")
|
||||
add_custom_target(circt-doc)
|
||||
|
||||
set(ENV{PKG_CONFIG_PATH}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ext/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
|
||||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
|
|
|
@ -6,3 +6,5 @@ mlir_tablegen(ESIAttrs.h.inc -gen-struct-attr-decls)
|
|||
mlir_tablegen(ESIAttrs.cpp.inc -gen-struct-attr-defs)
|
||||
|
||||
add_public_tablegen_target(MLIRESIEnumsIncGen)
|
||||
|
||||
add_subdirectory(cosim)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
find_package(CapnProto CONFIG PATHS "${CMAKE_SOURCE_DIR}/ext")
|
||||
if(CapnProto_FOUND)
|
||||
option(ESI_COSIM "Enable ESI Cosimulation" ON)
|
||||
message("-- Enabling ESI cosim")
|
||||
add_definitions(${CAPNP_DEFINITIONS})
|
||||
capnp_generate_cpp(COSIM_CAPNP_SRCS COSIM_CANPN_HDRS CosimDpi.capnp)
|
||||
add_library(EsiCosimCapnp ${COSIM_CAPNP_HDRS} ${COSIM_CAPNP_SRCS})
|
||||
target_link_libraries(EsiCosimCapnp PRIVATE CapnProto::capnp)
|
||||
endif()
|
|
@ -0,0 +1,44 @@
|
|||
##===- CosimDpi.capnp - ESI cosim RPC schema ------------------*- CAPNP -*-===//
|
||||
##
|
||||
## The ESI cosimulation RPC Cap'nProto schema. Documentation is in
|
||||
## docs/ESI/cosim.md. TL;DR: Run the simulation, then connect to its RPC server
|
||||
## with a client generated by the Cap'nProto implementation for your language of
|
||||
## choice! (https://capnproto.org/otherlang.html)
|
||||
##
|
||||
##===----------------------------------------------------------------------===//
|
||||
|
||||
@0xe642127a31681ef6;
|
||||
|
||||
# The primary interface exposed by an ESI cosim simulation.
|
||||
interface CosimDpiServer {
|
||||
# List all the registered endpoints.
|
||||
list @0 () -> (ifaces :List(EsiDpiInterfaceDesc));
|
||||
# Open one of them. Specify both the send and recv data types if want type
|
||||
# safety and your language supports it.
|
||||
open @1 [S, T] (iface :EsiDpiInterfaceDesc) -> (iface :EsiDpiEndpoint(S, T));
|
||||
}
|
||||
|
||||
# Description of a registered endpoint.
|
||||
struct EsiDpiInterfaceDesc {
|
||||
# Capn'Proto ID of the struct type being sent _to_ the simulator.
|
||||
sendTypeID @0 :UInt64;
|
||||
# Capn'Proto ID of the struct type being sent _from_ the simulator.
|
||||
recvTypeID @1 :UInt64;
|
||||
# Numerical identifier of the endpoint. Defined in the design.
|
||||
endpointID @2 :Int32;
|
||||
}
|
||||
|
||||
# Interactions with an open endpoint. Optionally typed.
|
||||
interface EsiDpiEndpoint(SendMsgType, RecvMsgType) {
|
||||
# Send a message to the endpoint.
|
||||
send @0 (msg :SendMsgType);
|
||||
# Recieve a message from the endpoint. Non-blocking.
|
||||
recv @1 (block :Bool = true) -> (hasData :Bool, resp :RecvMsgType);
|
||||
# Close the connect to this endpoint.
|
||||
close @2 ();
|
||||
}
|
||||
|
||||
# A struct for untyped access to an endpoint.
|
||||
struct UntypedData @0xac6e64291027d47a {
|
||||
data @0 :Data;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# Downloads, compiles, and installs CapnProto into $/ext
|
||||
|
||||
EXT_DIR=$(cd "$(dirname "$BASH_SOURCE[0]")/../ext" && pwd)
|
||||
CAPNP_VER=0f1bf4fce79923fb4974aa55a53e26450f83f286
|
||||
|
||||
echo $EXT_DIR
|
||||
cd $EXT_DIR
|
||||
|
||||
git clone https://github.com/capnproto/capnproto.git
|
||||
cd capnproto
|
||||
git checkout $CAPNP_VER
|
||||
cd c++
|
||||
autoreconf -i
|
||||
./configure --prefix=$EXT_DIR
|
||||
make -j$(nprocs)
|
||||
make install
|
||||
cd ../../
|
Loading…
Reference in New Issue