Skip to content

Commit

Permalink
[ESI] Rip out Cap'nProto schema generation (#6349)
Browse files Browse the repository at this point in the history
This turned out to be a bad idea. We're still using Cap'nProto for Cosim, just with the message being a blob which is already encoded by the client. This is nearly identical to what happens in hardware, just Cap'nProto/DPI as the transport layer.

Goodbye old frenemy.
  • Loading branch information
teqdruid authored Oct 27, 2023
1 parent 583b36b commit 03e1d94
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 1,944 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ else()
message(STATUS "Found Cap'nProto at ${CapnProto_DIR}.")
set(CMAKE_INSTALL_RPATH ${capnp_LIBDIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

option(ESI_COSIM "Enable ESI Cosimulation" ON)
endif()
endif()

Expand Down
4 changes: 0 additions & 4 deletions include/circt-c/Dialect/ESI.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ extern "C" {

MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(ESI, esi);
MLIR_CAPI_EXPORTED void registerESIPasses(void);
MLIR_CAPI_EXPORTED void registerESITranslations(void);

MLIR_CAPI_EXPORTED MlirLogicalResult
circtESIExportCosimSchema(MlirModule, MlirStringCallback, void *userData);

MLIR_CAPI_EXPORTED bool circtESITypeIsAChannelType(MlirType type);
MLIR_CAPI_EXPORTED MlirType circtESIChannelTypeGet(MlirType inner,
Expand Down
2 changes: 2 additions & 0 deletions include/circt/Dialect/ESI/APIUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ESIAPIType {
// API-safe name for this type which should work with most languages.
StringRef name() const;

uint64_t size() const;

// Capnproto-safe type id for this type.
uint64_t typeID() const;

Expand Down
24 changes: 0 additions & 24 deletions include/circt/Dialect/ESI/ESIChannels.td
Original file line number Diff line number Diff line change
Expand Up @@ -497,30 +497,6 @@ def RtlBitArrayType : Type<CPred<"$_self.isa<::circt::hw::ArrayType>()"
" && $_self.cast<::circt::hw::ArrayType>().getElementType() =="
" ::mlir::IntegerType::get($_self.getContext(), 1)">, "an HW bit array">;

def CapnpDecodeOp : ESI_Physical_Op<"decode.capnp", [Pure]> {
let summary = "Translate bits in Cap'nProto messages to HW typed data";

let arguments = (ins ClockType:$clk, I1:$valid, RtlBitArrayType:$capnpBits);
let results = (outs AnyType:$decodedData);

let assemblyFormat = [{
$clk $valid $capnpBits attr-dict `:` qualified(type($capnpBits)) `->`
qualified(type($decodedData))
}];
}

def CapnpEncodeOp : ESI_Physical_Op<"encode.capnp", [Pure]> {
let summary = "Translate HW typed data to Cap'nProto";

let arguments = (ins ClockType:$clk, I1:$valid, AnyType:$dataToEncode);
let results = (outs RtlBitArrayType:$capnpBits);

let assemblyFormat = [{
$clk $valid $dataToEncode attr-dict `:` qualified(type($dataToEncode))
`->` qualified(type($capnpBits))
}];
}

def NullSourceOp : ESI_Physical_Op<"null", [Pure]> {
let summary = "An op which never produces messages.";

Expand Down
2 changes: 0 additions & 2 deletions include/circt/Dialect/ESI/ESIDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace circt {
namespace esi {

void registerESIPasses();
void registerESITranslations();
LogicalResult exportCosimSchema(ModuleOp module, llvm::raw_ostream &os);

/// Name of dialect attribute which governs whether or not to bundle (i.e. use
/// SystemVerilog interfaces) channel signal wires on external modules.
Expand Down
2 changes: 0 additions & 2 deletions include/circt/Dialect/ESI/ESIPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
namespace circt {
namespace esi {

std::unique_ptr<OperationPass<ModuleOp>> createESIEmitCollateralPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIPhysicalLoweringPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIBundleLoweringPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIPortLoweringPass();
std::unique_ptr<OperationPass<ModuleOp>> createESITypeLoweringPass();
std::unique_ptr<OperationPass<ModuleOp>> createESItoHWPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIConnectServicesPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIAddCPPAPIPass();
std::unique_ptr<OperationPass<ModuleOp>> createESICleanMetadataPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIBuildManifestPass();
std::unique_ptr<OperationPass<ModuleOp>> createESIAppIDHierPass();
Expand Down
14 changes: 0 additions & 14 deletions include/circt/Dialect/ESI/ESIPasses.td
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@ def ESIConnectServices : Pass<"esi-connect-services", "mlir::ModuleOp"> {
"circt::comb::CombDialect"];
}


def ESIEmitCollateral: Pass<"esi-emit-collateral", "mlir::ModuleOp"> {
let summary = "Emit all the neccessary collateral";
let constructor = "circt::esi::createESIEmitCollateralPass()";
let dependentDialects = ["circt::sv::SVDialect"];
let options = [
Option<"schemaFile", "schema-file", "std::string",
"", "File to output capnp schema into">,
ListOption<"tops", "tops", "std::string",
"List of top modules to export Tcl for",
"llvm::cl::ZeroOrMore,">
];
}

def ESIAppIDHier : Pass<"esi-appid-hier", "mlir::ModuleOp"> {
let summary = "Build an AppID based hierarchy rooted at top module 'top'";
let constructor = "circt::esi::createESIAppIDHierPass()";
Expand Down
9 changes: 2 additions & 7 deletions include/circt/Dialect/ESI/cosim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
##
##===----------------------------------------------------------------------===//

if(CapnProto_FOUND)
option(ESI_COSIM "Enable ESI Cosimulation" ON)
message("-- Enabling ESI cosim")

file(READ CosimDpi.capnp EsiCosimSchema)
set(COSIM_SCHEMA_HDR ${CIRCT_BINARY_DIR}/include/circt/Dialect/ESI/CosimSchema.h)
configure_file(CosimSchema.h.in ${COSIM_SCHEMA_HDR})
if (ESI_COSIM)
message("-- ESI cosim enabled")

if (MSVC)
string(REPLACE "/EHs-c-" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
Expand Down
28 changes: 0 additions & 28 deletions include/circt/Dialect/ESI/cosim/CosimSchema.h.in

This file was deleted.

1 change: 0 additions & 1 deletion include/circt/InitAllTranslations.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace circt {
// automatically.
inline void registerAllTranslations() {
static bool initOnce = []() {
esi::registerESITranslations();
calyx::registerToCalyxTranslation();
firrtl::registerFromFIRFileTranslation();
firrtl::registerToFIRFileTranslation();
Expand Down
48 changes: 0 additions & 48 deletions integration_test/Dialect/ESI/cosim/basic.mlir

This file was deleted.

72 changes: 0 additions & 72 deletions integration_test/Dialect/ESI/cosim/basic.py

This file was deleted.

7 changes: 0 additions & 7 deletions lib/CAPI/Dialect/ESI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(ESI, esi, circt::esi::ESIDialect)

void registerESIPasses() { circt::esi::registerESIPasses(); }

MlirLogicalResult circtESIExportCosimSchema(MlirModule module,
MlirStringCallback callback,
void *userData) {
mlir::detail::CallbackOstream stream(callback, userData);
return wrap(circt::esi::exportCosimSchema(unwrap(module), stream));
}

bool circtESITypeIsAChannelType(MlirType type) {
return unwrap(type).isa<ChannelType>();
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Dialect/ESI/APIUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ bool ESIAPIType::isSupported() const {
return circt::esi::isSupported(type, true);
}

uint64_t ESIAPIType::size() const {
if (auto chan = dyn_cast<ChannelType>(type))
return hw::getBitWidth(chan.getInner());
return hw::getBitWidth(type);
}

ESIAPIType::ESIAPIType(Type typeArg) : type(innerType(typeArg)) {
TypeSwitch<Type>(type)
.Case([this](IntegerType t) {
Expand Down
13 changes: 1 addition & 12 deletions lib/Dialect/ESI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ set(srcs
ESIPasses.cpp
ESIServices.cpp
ESIStdServices.cpp
ESITranslations.cpp
ESITypes.cpp
Passes/ESIEmitCollateral.cpp
Passes/ESILowerPhysical.cpp
Passes/ESILowerBundles.cpp
Passes/ESILowerPorts.cpp
Expand Down Expand Up @@ -50,12 +48,6 @@ set(ESI_Deps
MLIRESIInterfacesIncGen
)

if(CapnProto_FOUND)
option(ESI_CAPNP "Enable ESI Capnp features" ON)
list(APPEND srcs capnp/Schema.cpp)
list(APPEND ESI_LinkLibs CapnProto::capnp CapnProto::capnpc)
endif()

add_circt_dialect_library(CIRCTESI
${srcs}

Expand Down Expand Up @@ -110,7 +102,7 @@ foreach(SRC ${ESI_RUNTIME_SRCS})
copy_esi_runtime(${SRC})
endforeach()

if (ESI_CAPNP)
if (ESI_COSIM)
add_dependencies(esi-collateral EsiCosimCapnp)
get_target_property(EsiCosimCapnp_bindir EsiCosimCapnp SOURCE_DIR)
set(ESI_COSIM_SCHEMA "${EsiCosimCapnp_bindir}/CosimDpi.capnp")
Expand All @@ -119,9 +111,6 @@ if (ESI_CAPNP)
COMMAND ${CMAKE_COMMAND} -E
copy "${ESI_COSIM_SCHEMA}"
"${CMAKE_CURRENT_BINARY_DIR}/runtime/CosimDpi.capnp")

target_compile_definitions(obj.CIRCTESI PRIVATE CAPNP)
target_link_libraries(obj.CIRCTESI CapnProto::capnp CapnProto::capnpc)
endif()

add_subdirectory(cosim)
Expand Down
Loading

0 comments on commit 03e1d94

Please sign in to comment.