mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	cxxrtl: allow customizing the root module path in the C API.
This commit is contained in:
		
							parent
							
								
									5a15307926
								
							
						
					
					
						commit
						e89f6ae819
					
				
					 2 changed files with 20 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue