Modifying RTL Files Using Pyslang Not Working #1469
-
|
Now that pyslang 9.0 is out with the new SyntaxRewriter, I'm trying to write a python script to modify files based on a command file that contains a list of modifications to be processed. I'll take a simple example, delete a module port. I've found the module using by searching through the compilation.getRoot().topInstances, we'll call the result mod_obj. I then search through the Ports to find the port in question, using mod_obj.body.portList, we'll call this port_obj. Technically these can be lists as in the case of the ports, I could, for instance, perform a regex for a mass deletion of a memory bus. Having the port_obj, which I believe is a PortSymbol, I then attempt to perform a routine similar to the pyslang/test/test_syntax_rewrite for the function test_rewriter_remove. The equivalent to remove_int_var is located in a class where I set the remove_obj variable to the port_obj.syntax. I then call my remove function using the following: The remove_module_port is as follows: If I look at len(self.tree.root.members[0].header.ports.ports) and compare to len(new_tree.root.members[0].header.ports.ports) they're the same count, but I can see the logged info message on the screen as well as the remove_success being set to True so I know that we found a match and the name matches the port I'm looking for. What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Might be answering my own question a bit, but the port count went down when I modified the remove_module_port function to the following code. I did change out the remove variables to add is_ansi_port and name, so the name matching happens in the remove_module_port function. I'll need to work on a non-ansi case as well, but the count has gone down. I had noticed that when I was trying to str() that it was only printing "\n input wire" and such for the ports that were removed so that let me to I was just removing the name of the port, not the full port. |
Beta Was this translation helpful? Give feedback.
Might be answering my own question a bit, but the port count went down when I modified the remove_module_port function to the following code. I did change out the remove variables to add is_ansi_port and name, so the name matching happens in the remove_module_port function. I'll need to work on a non-ansi case as well, but the count has gone down.
I had noticed that when I…