ignore # comment lines
[yosys.git] / backends / cxxrtl / cxxrtl_capi.cc
index 489d72da5c82409a3d7be92052f5c5fd5a18d31d..227173ba87f94de34b393a4eed57378c7c9ae706 100644 (file)
@@ -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;
 }
@@ -43,18 +56,37 @@ void cxxrtl_destroy(cxxrtl_handle handle) {
        delete handle;
 }
 
+void cxxrtl_reset(cxxrtl_handle handle) {
+       handle->module->reset();
+}
+
+int cxxrtl_eval(cxxrtl_handle handle) {
+       return handle->module->eval();
+}
+
+int cxxrtl_commit(cxxrtl_handle handle) {
+       return handle->module->commit();
+}
+
 size_t cxxrtl_step(cxxrtl_handle handle) {
        return handle->module->step();
 }
 
-cxxrtl_object *cxxrtl_get(cxxrtl_handle handle, const char *name) {
-       if (handle->objects.count(name) > 0)
-               return static_cast<cxxrtl_object*>(&handle->objects.at(name));
-       return nullptr;
+struct cxxrtl_object *cxxrtl_get_parts(cxxrtl_handle handle, const char *name, size_t *parts) {
+       auto it = handle->objects.table.find(name);
+       if (it == handle->objects.table.end())
+               return nullptr;
+       *parts = it->second.size();
+       return static_cast<cxxrtl_object*>(&it->second[0]);
 }
 
 void cxxrtl_enum(cxxrtl_handle handle, void *data,
-                 void (*callback)(void *data, const char *name, cxxrtl_object *object)) {
-       for (auto &it : handle->objects)
-               callback(data, it.first.c_str(), static_cast<cxxrtl_object*>(&it.second));
+                 void (*callback)(void *data, const char *name,
+                                  cxxrtl_object *object, size_t parts)) {
+       for (auto &it : handle->objects.table)
+               callback(data, it.first.c_str(), static_cast<cxxrtl_object*>(&it.second[0]), it.second.size());
+}
+
+void cxxrtl_outline_eval(cxxrtl_outline outline) {
+       outline->eval();
 }