mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	- Rewrite all Python features to use the pybind11 library instead of boost::python. Unlike boost::python, pybind11 is a header-only library that is just included by Pyosys code, saving a lot of compile time on wheels. - Factor out as much "translation" code from the generator into proper C++ files - Fix running the embedded interpreter not supporting "from pyosys import libyosys as ys" like wheels - Move Python-related elements to `pyosys` directory at the root of the repo - Slight shift in bridging semantics: - Containers are declared as "opaque types" and are passed by reference to Python - many methods have been implemented to make them feel right at home without the overhead/ambiguity of copying to Python and then copying back after mutation - Monitor/Pass use "trampoline" pattern to support virual methods overridable in Python: virtual methods no longer require `py_` prefix - Create really short test set for pyosys that just exercises basic functionality
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			446 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			446 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from pyosys import libyosys as ys
 | |
| from pathlib import Path
 | |
| 
 | |
| __file_dir__ = Path(__file__).absolute().parent
 | |
| 
 | |
| d = ys.Design()
 | |
| 
 | |
| class Monitor(ys.Monitor):
 | |
| 	def __init__(self):
 | |
| 		super().__init__()
 | |
| 		self.mods = []
 | |
| 
 | |
| 	def notify_module_add(self, mod):
 | |
| 		self.mods.append(mod.name.str())
 | |
| 
 | |
| m = Monitor()
 | |
| d.monitors.add(m)
 | |
| 
 | |
| ys.run_pass(f"read_verilog {__file_dir__ / 'spm.cut.v.gz'}", d)
 | |
| ys.run_pass("hierarchy -top spm", d)
 | |
| 
 | |
| assert m.mods == ["\\spm"]
 |