mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-23 06:13:41 +00:00
cxxrtl: expose scope information in the C++ API.
This commit adds a `debug_scopes` container, which can collect metadata about scopes in a design. Currently the only scope is that of a module. A module scope can be represented either by a module and cell pair, or a `$scopeinfo` cell in a flattened netlist. The metadata produced by the C++ API is identical between these two cases, so flattening remains transparent to a netlist with CXXRTL. The existing `debug_items` method is deprecated. This isn't strictly necessary, but the user experience is better if the path is provided as e.g. `"top "` (as some VCD viewers make it awkward to select topmost anonymous scope), and the upgrade flow encourages that, which should reduce frustration later. While the new `debug_items` method could still be broken in the future as the C++ API permits, this seems unlikely since the debug information can now capture all common netlist aspects and includes several extension points (via `debug_item`, `debug_scope` types). Also, naming of scope paths was normalized to `path` or `top_path`, as applicable.
This commit is contained in:
parent
d903f47d41
commit
1a44645aef
5 changed files with 247 additions and 162 deletions
|
@ -35,19 +35,19 @@ 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()) {
|
||||
cxxrtl_handle cxxrtl_create_at(cxxrtl_toplevel design, const char *top_path_) {
|
||||
std::string top_path = top_path_;
|
||||
if (!top_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 += ' ';
|
||||
assert(top_path.back() != ' ');
|
||||
top_path += ' ';
|
||||
}
|
||||
|
||||
cxxrtl_handle handle = new _cxxrtl_handle;
|
||||
handle->module = std::move(design->module);
|
||||
handle->module->debug_info(handle->objects, path);
|
||||
handle->module->debug_info(handle->objects, top_path);
|
||||
delete design;
|
||||
return handle;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ 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);
|
||||
// is prepended with `top_path`.
|
||||
cxxrtl_handle cxxrtl_create_at(cxxrtl_toplevel design, const char *top_path);
|
||||
|
||||
// Release all resources used by a design and its handle.
|
||||
void cxxrtl_destroy(cxxrtl_handle handle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue