Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifications of which modules to parse #307

Merged
merged 5 commits into from Oct 24, 2018
Merged

Conversation

rsetaluri
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Oct 19, 2018

Pull Request Test Coverage Report for Build 1195

  • 12 of 13 (92.31%) changed or added relevant lines in 1 file are covered.
  • 23 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 71.949%

Changes Missing Coverage Covered Lines Changed/Added Lines %
magma/fromverilog.py 12 13 92.31%
Files with Coverage Reduction New Missed Lines %
magma/circuit.py 23 87.79%
Totals Coverage Status
Change from base Build 1178: 0.0%
Covered Lines: 3473
Relevant Lines: 4827

💛 - Coveralls

Copy link
Collaborator

@leonardt leonardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, from what I understand this argument was only used by https://github.com/adamdai/magmacam so this will be a breaking change for them, but we can post an issue to track it. Any other code, well we'll find out.

I setup the magma-lang pypi package a little while ago https://pypi.org/project/magma-lang/#history it's time to do a new release and start having dependent projects use the release version so they can track versions.

Some minor musings on portions of the code, but not blocking requests.

modules.append(circuit)
except Exception as e:
logger.warning(f"Could not parse module {node.name} ({e}), "
f"skipping")
if module is not None:
raise Exception(f"Could not find module {module}")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior to return an empty list if there is no module found. Seems like reasonable behavior, but before it would raise an error if it couldn't find the module.

Either behavior seems like it could work, but maybe raising an exception if target_modules is not empty but no modules were found, might be helpful for the user (forcing them to handle this case, rather than returning an empty list which might make their code advance and cause a bug later down the line that may be harder to understand).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Perhaps a warning would be best? The information is ultimately conveyed one way or another when an empty list is returned.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning sounds good, so if there is some issue caused, they can at least inspect the log and see it which might give them a clue as to where the issue is coming from

@@ -107,7 +107,7 @@ def ParseVerilogModule(node, type_map):

return node.name, args

def FromVerilog(source, func, type_map, module=None):
def FromVerilog(source, func, type_map, target_modules=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having both a single module argument and a list of modules argument? It would probably be convenient, but I'm not sure if there's an elegant way to do this without having to introduce some complexity in the code (handling the various cases). Maybe we can have a separate function that defines a single module from verilog (and then wraps the module in a list of one element and passes it to this function).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like reducing the complexity here and forcing the client to pass in a list and take the 0-th element of the list is preferable, esp. since it is likely not the most common case. This change also moves in the direction of thinking about bigger/general/more complex design scenarios where people might implement several modules in the same file etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I agree.

@leonardt leonardt merged commit c7a994b into master Oct 24, 2018
@leonardt leonardt deleted the magma-verilog-wrap branch October 24, 2018 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants