diff options
author | whitequark <whitequark@whitequark.org> | 2020-12-03 01:58:02 +0000 |
---|---|---|
committer | whitequark <whitequark@whitequark.org> | 2020-12-03 01:58:02 +0000 |
commit | e89f6ae819e31103f9cd03163cd52672ec0ac472 (patch) | |
tree | 631f2c895b03129347de7591ec0b3a0ce96fca78 | |
parent | 5a15307926a5984737615a9767c55a11dfb53562 (diff) | |
download | yosys-e89f6ae819e31103f9cd03163cd52672ec0ac472.tar.gz yosys-e89f6ae819e31103f9cd03163cd52672ec0ac472.tar.bz2 yosys-e89f6ae819e31103f9cd03163cd52672ec0ac472.zip |
cxxrtl: allow customizing the root module path in the C API.
-rw-r--r-- | backends/cxxrtl/cxxrtl_capi.cc | 15 | ||||
-rw-r--r-- | backends/cxxrtl/cxxrtl_capi.h | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/backends/cxxrtl/cxxrtl_capi.cc b/backends/cxxrtl/cxxrtl_capi.cc index 1c3c63e3e..f92709b46 100644 --- a/backends/cxxrtl/cxxrtl_capi.cc +++ b/backends/cxxrtl/cxxrtl_capi.cc @@ -32,9 +32,22 @@ const cxxrtl::debug_items &cxxrtl_debug_items_from_handle(cxxrtl_handle handle) } cxxrtl_handle cxxrtl_create(cxxrtl_toplevel design) { + return cxxrtl_create_at(design, ""); +} + +cxxrtl_handle cxxrtl_create_at(cxxrtl_toplevel design, const char *root) { + std::string path = root; + if (!path.empty()) { + // module::debug_info() accepts either an empty path, or a path ending in space to simplify + // the logic in generated code. While this is sketchy at best to expose in the C++ API, this + // would be a lot worse in the C API, so don't expose it here. + assert(path.back() != ' '); + path += ' '; + } + cxxrtl_handle handle = new _cxxrtl_handle; handle->module = std::move(design->module); - handle->module->debug_info(handle->objects); + handle->module->debug_info(handle->objects, path); delete design; return handle; } diff --git a/backends/cxxrtl/cxxrtl_capi.h b/backends/cxxrtl/cxxrtl_capi.h index 662bf2c20..d67c58f94 100644 --- a/backends/cxxrtl/cxxrtl_capi.h +++ b/backends/cxxrtl/cxxrtl_capi.h @@ -52,6 +52,12 @@ typedef struct _cxxrtl_handle *cxxrtl_handle; // The `design` is consumed by this operation and cannot be used afterwards. cxxrtl_handle cxxrtl_create(cxxrtl_toplevel design); +// Create a design handle at a given hierarchy position from a design toplevel. +// +// This operation is similar to `cxxrtl_create`, except the full hierarchical name of every object +// is prepended with `root`. +cxxrtl_handle cxxrtl_create_at(cxxrtl_toplevel design, const char *root); + // Release all resources used by a design and its handle. void cxxrtl_destroy(cxxrtl_handle handle); |