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

Add python simulator backend #9

Merged
merged 5 commits into from
Jul 24, 2018
Merged

Conversation

rsetaluri
Copy link
Collaborator

@leonardt I don't think this is complete yet. Just wanted to throw it out there to make sure it was on the right track. What do you think? I think solving issue #8 will make it obvious what to do here.

Adding backend for python simulator. Also adding test for python
simulator backend.

TODO(rsetaluri): Add tests for synchronous circuit (i.e. w/ clk).

@rsetaluri rsetaluri requested a review from leonardt July 20, 2018 06:35
Copy link
Owner

@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.

Minor comments, seems like it's on the right path functionality wise. I agree we should nail down the semantics of peek, poke, and expect. I'll try to write up a specification.

print("Advancing clock")
simulator.advance(2)
elif port.isoutput():
print(f"Setting {self._circuit.name}.{name} to {val}")
Copy link
Owner

Choose a reason for hiding this comment

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

We should change these to use some logging infrastructure. Can we add a fault.logging module which just uses Python's builtin logging module for now? We can use info, debug, and error levels for now. These are probably best put under info or debug. Doing this early let's us add useful logging info throughout the code base but have an easy to silence it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See PR #10. Will update this once that's merged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

sim_val = simulator.get_value(port)
assert sim_val == val
else:
raise NotImplementedError()
Copy link
Owner

Choose a reason for hiding this comment

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

Implementation seems reasonable, but can we decompose this a bit into smaller functions? It's quite large and will get larger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@leonardt
Copy link
Owner

Let me know if you want to merge this as is or wait for more functionality to be filled out. One thing to test would be nested arrays, I think this should just work since we don't have to flatten types. We may need to support that for the coreir simulator target.

We're starting to collect a bunch of these Foo style test circuits. In my nested-arrays pull, I started a common module for testing that we could use to define circuits that are common across tests. Would be nice to have a common set of circuits that each target should be able to handle. You could add to that once we get nested-arrays into master.

In theory, we should be able to run the same set of tests on each target, so it would be good to abstract some tests in this way so that we know the targets are consistent.

@coveralls
Copy link

coveralls commented Jul 20, 2018

Pull Request Test Coverage Report for Build 73

  • 65 of 67 (97.01%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.9%) to 91.071%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fault/python_simulator_target.py 63 65 96.92%
Totals Coverage Status
Change from base Build 66: 1.9%
Covered Lines: 255
Relevant Lines: 280

💛 - Coveralls

rsetaluri and others added 4 commits July 23, 2018 16:35
Adding backend for python simulator. Also adding test for python
simulator backend.

TODO(rsetaluri): Add tests for synchronous circuit (i.e. w/ clk).
This change includes the following:
-- Rewrite of the conversion from test vectors to python simulator
   inputs
-- Added fault.logging.debug
-- Added more tests for python simulator target
@rsetaluri rsetaluri force-pushed the add-python-simulator-target branch from 6b1e282 to 4bca960 Compare July 23, 2018 23:36
@rsetaluri
Copy link
Collaborator Author

Note: addresses issue #4

Copy link
Owner

@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.

Looks good, some minor changes but I'll push them myself.

@leonardt leonardt merged commit ea52b2b into master Jul 24, 2018
@leonardt leonardt deleted the add-python-simulator-target branch July 24, 2018 21:35
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