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 support for poke/expect using a list of values for nested arrays #36

Merged
merged 14 commits into from
Sep 18, 2018

Conversation

leonardt
Copy link
Owner

Support passing a list of values as an argument to poke and expect for nested arrays. This still supports passing a single value, which is convenient if you want to zero all the children of the nested arrays, so you can say something like tester.poke(circuit.nested_array, 0).

Also includes a default __repr__ method for actions that uses __str__ for now (useful for debugging when printing a list of actions, which calls repr)

@coveralls
Copy link

coveralls commented Sep 17, 2018

Pull Request Test Coverage Report for Build 290

  • 29 of 32 (90.63%) changed or added relevant lines in 3 files are covered.
  • 3 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.4%) to 81.26%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fault/magma_simulator_target.py 12 15 80.0%
Files with Coverage Reduction New Missed Lines %
fault/verilator_utils.py 1 94.74%
fault/value_utils.py 1 92.86%
fault/verilator_target.py 1 98.7%
Totals Coverage Status
Change from base Build 260: 0.4%
Covered Lines: 516
Relevant Lines: 635

💛 - Coveralls

fault/tester.py Outdated
@@ -1,4 +1,5 @@
import magma
import magma as m
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's just use one of these imports; impartial to if we use as m or not.

fault/tester.py Outdated
def poke(self, port, value):
value = make_value(port, value)
self.actions.append(actions.Poke(port, value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this logic should be delegated to the targets -- tester should ideally not be implementing logic to split a poke(array_port, [...]) into several actions. I would argue these functions should be unchanged, and in the targets we do a:

if isinstance(value, fault.Array):
   ...

Because, the magma/coreir simulator may support directly set_value(array_port, [...]) where as of course for verilator we need to blow it up.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good point, that's actually how I initially implemented it. I'll make this change.

@@ -52,6 +52,22 @@ def test_tester_nested_arrays():
check(tester.actions[i], exp)


def test_tester_nested_arrays_list_of_vals():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we copy this test for the actual targets and ensure that it works?

@leonardt
Copy link
Owner Author

Review comments addressed, ready for another pass.

The logic has been moved to the targets.

isinstance(action.port.T, (m._BitType, m._BitKind)):
got = BitVector(got).as_uint()
else if isinstance(action.port, (m.ArrayType, m.ArrayKind)):
raise NotImplementedError("Printing complex nested arrays")
Copy link
Owner Author

Choose a reason for hiding this comment

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

I think we should defer this feature for now. The user can print elements of the array fine, but there's not a simple way to map a complex nested array to a standard format string.

fault/magma_simulator_target.py Outdated Show resolved Hide resolved
fault/verilator_target.py Outdated Show resolved Hide resolved
fault/magma_simulator_target.py Outdated Show resolved Hide resolved
fault/magma_simulator_target.py Show resolved Hide resolved
fault/verilator_target.py Outdated Show resolved Hide resolved
fault/magma_simulator_target.py Show resolved Hide resolved
@rsetaluri
Copy link
Collaborator

Looks good, thanks for addressing the comments.

@leonardt leonardt merged commit ffa3d9f into master Sep 18, 2018
@leonardt leonardt deleted the nested-array-actions branch September 18, 2018 01:59
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.

3 participants