mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 19:52:31 +00:00 
			
		
		
		
	cellhelp: Add default format parse for simcells
Since `simcells.v` uses consistent formatting we can handle it specifically to help tidy up sphinx warnings about the truth tables, and instead chuck them in a code block which when printing to rst. Also has the side effect that rst code blocks can be added manually with `//- ::` followed by a blank line.
This commit is contained in:
		
							parent
							
								
									a2b2904ed8
								
							
						
					
					
						commit
						57cd8d29db
					
				
					 2 changed files with 31 additions and 4 deletions
				
			
		|  | @ -988,10 +988,14 @@ struct HelpPass : public Pass { | ||||||
| 			} | 			} | ||||||
| 			else if (cell_help_messages.cell_help.count(args[1])) { | 			else if (cell_help_messages.cell_help.count(args[1])) { | ||||||
| 				SimHelper help_cell = cell_help_messages.cell_help.at(args[1]); | 				SimHelper help_cell = cell_help_messages.cell_help.at(args[1]); | ||||||
| 				if (help_cell.ver == "2") { | 				if (help_cell.ver == "2" || help_cell.ver == "2a") { | ||||||
| 					log("\n    %s %s\n", help_cell.name.c_str(), help_cell.ports.c_str()); | 					log("\n    %s %s\n\n", help_cell.name.c_str(), help_cell.ports.c_str()); | ||||||
| 					log("\n%s\n", help_cell.title.c_str()); | 					if (help_cell.title != "") log("%s\n", help_cell.title.c_str()); | ||||||
| 					log("%s\n", help_cell.desc.c_str()); | 					std::stringstream ss; | ||||||
|  | 					ss << help_cell.desc; | ||||||
|  | 					for (std::string line; std::getline(ss, line, '\n');) { | ||||||
|  | 						if (line != "::") log("%s\n", line.c_str()); | ||||||
|  | 					} | ||||||
| 					log("Run 'help %s+' to display the Verilog model for this cell type.\n", args[1].c_str()); | 					log("Run 'help %s+' to display the Verilog model for this cell type.\n", args[1].c_str()); | ||||||
| 					log("\n"); | 					log("\n"); | ||||||
| 				} else { | 				} else { | ||||||
|  |  | ||||||
|  | @ -36,6 +36,24 @@ class SimHelper: | ||||||
|         val += f'cell_code[{json.dumps(self.name + "+")}] = tempCell;' |         val += f'cell_code[{json.dumps(self.name + "+")}] = tempCell;' | ||||||
|         return val |         return val | ||||||
| 
 | 
 | ||||||
|  | def simcells_reparse(cell: SimHelper): | ||||||
|  |     # cut manual signature | ||||||
|  |     cell.desc = cell.desc[3:] | ||||||
|  | 
 | ||||||
|  |     # code-block truth table | ||||||
|  |     new_desc = [] | ||||||
|  |     indent = "" | ||||||
|  |     for line in cell.desc: | ||||||
|  |         if line.startswith("Truth table:"): | ||||||
|  |             indent = "   " | ||||||
|  |             new_desc.pop() | ||||||
|  |             new_desc.extend(["::", ""]) | ||||||
|  |         new_desc.append(indent + line) | ||||||
|  |     cell.desc = new_desc | ||||||
|  | 
 | ||||||
|  |     # set version | ||||||
|  |     cell.ver = "2a" | ||||||
|  | 
 | ||||||
| simHelper = SimHelper() | simHelper = SimHelper() | ||||||
| 
 | 
 | ||||||
| for line in fileinput.input(): | for line in fileinput.input(): | ||||||
|  | @ -62,7 +80,12 @@ for line in fileinput.input(): | ||||||
|         # no module definition, ignore line |         # no module definition, ignore line | ||||||
|         pass |         pass | ||||||
|     if line.startswith("endmodule"): |     if line.startswith("endmodule"): | ||||||
|  |         short_filename = Path(fileinput.filename()).name | ||||||
|  |         if simHelper.ver == "1" and short_filename == "simcells.v": | ||||||
|  |             # default simcells parsing | ||||||
|  |             simcells_reparse(simHelper) | ||||||
|         if not simHelper.desc: |         if not simHelper.desc: | ||||||
|  |             # no help | ||||||
|             simHelper.desc.append("No help message for this cell type found.\n") |             simHelper.desc.append("No help message for this cell type found.\n") | ||||||
|         print(simHelper) |         print(simHelper) | ||||||
|         simHelper = SimHelper() |         simHelper = SimHelper() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue