aboutsummaryrefslogtreecommitdiffstats
path: root/backends/cxxrtl/cxxrtl_capi.cc
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-12-03 02:35:23 +0000
committerGitHub <noreply@github.com>2020-12-03 02:35:23 +0000
commit13a270555be2965b7204872ca60e030b6573accc (patch)
tree631f2c895b03129347de7591ec0b3a0ce96fca78 /backends/cxxrtl/cxxrtl_capi.cc
parent5a15307926a5984737615a9767c55a11dfb53562 (diff)
parente89f6ae819e31103f9cd03163cd52672ec0ac472 (diff)
downloadyosys-13a270555be2965b7204872ca60e030b6573accc.tar.gz
yosys-13a270555be2965b7204872ca60e030b6573accc.tar.bz2
yosys-13a270555be2965b7204872ca60e030b6573accc.zip
Merge pull request #2470 from whitequark/cxxrtl-create_at
cxxrtl: allow customizing the root module path in the C API
Diffstat (limited to 'backends/cxxrtl/cxxrtl_capi.cc')
-rw-r--r--backends/cxxrtl/cxxrtl_capi.cc15
1 files changed, 14 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;
}