-
Notifications
You must be signed in to change notification settings - Fork 13
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
Tester Refactor #22
Tester Refactor #22
Conversation
@@ -10,9 +10,9 @@ def test_tester_basic(): | |||
tester = fault.Tester(circ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the serialization tests should be disjoint from the tester tests. the tester tests should just ensure that the series of actions generated is accurate (mostly trivial).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
"d", m.In(m.Array(16, m.Array(20, m.Bit)))] | ||
|
||
|
||
def test_all(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test could be structured better, but just wanted to get in all the test functionality so we're sure nothing is broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest parametrization might be useful here (see https://docs.pytest.org/en/latest/parametrize.html)
fault/verilator_target.py
Outdated
f"{i}, \"{action.port.name}\");"] | ||
if isinstance(action, actions.Eval): | ||
return ["top->eval();"] | ||
if isinstance(action, actions.Step): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
fault/tester.py
Outdated
self.vectors[-1][index] = make_value(port, AnyValue) | ||
|
||
def process(self, action): | ||
if isinstance(action, (actions.Poke, actions.Expect)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to deal with nested arrays here (i.e. tester.poke(circ.I[2])
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this logic is what you're referring to https://github.com/leonardt/fault/pull/22/files#diff-cbd9d87f93cddae35c5f407fde349e05L63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
fault/verilator_target.py
Outdated
|
||
@staticmethod | ||
def generate_action_code(i, action): | ||
if isinstance(action, actions.Poke): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to deal with nested arrays --> flatten names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the array flattening stuff is quite annoying, I'm not sure if there's a less complex solution to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, carry on!
def __init__(self, steps, clock): | ||
super().__init__() | ||
self.steps = steps | ||
self.clock = clock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I like this abstraction of Actions. I thought about this more, and I think this is the right approach in general. It's much more conservative in space (it records the changes to the input/output state of the circuit, rather than the entire input/output state contained in a full test vector). This state is realized in the simulation state itself, so there's no reason to duplicate the state in the test vector.
We can always generate the test vector version from this sequence of actions.
fault/tester.py
Outdated
self.vectors[-1][index] = make_value(port, AnyValue) | ||
|
||
def process(self, action): | ||
if isinstance(action, (actions.Poke, actions.Expect)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this logic is what you're referring to https://github.com/leonardt/fault/pull/22/files#diff-cbd9d87f93cddae35c5f407fde349e05L63
fault/verilator_target.py
Outdated
|
||
@staticmethod | ||
def generate_action_code(i, action): | ||
if isinstance(action, actions.Poke): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the array flattening stuff is quite annoying, I'm not sure if there's a less complex solution to this.
"d", m.In(m.Array(16, m.Array(20, m.Bit)))] | ||
|
||
|
||
def test_all(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest parametrization might be useful here (see https://docs.pytest.org/en/latest/parametrize.html)
@leonardt this should be ready for final review. |
Refactoring tester to now just capture a sequence of "actions". Each target can choose to interpret these actions however. These actions tend to be more 1-to-1 with actions in the actual targets, making the translation easier. The verilator target has been mostly fully implemented. TODO: -- Verilator target nested arrays + name flattening -- Python/CoreIR simulator target
tests/test_tester.py only tests how Tester produces actions (not serialization). The serialization is tested specifically by testing TestVectorBuilder (in tests/test_test_vector_builder.py).
Added the following: -- Logic to optinally skip compilation to verilog in the target -- Nested array support (flattening). This includes a utility function "verilator_name()" in verilator_utils.py.
Updated the magma simulator targets to work with the new action interface. Note that the python simulator is not supported and not tested for now. We issue a warning if it is used.
Renamed the corresponding class and files. This is to avoid pytest warnings etc. Also makes the names cleaner.
Rather than compiling to verilator we now just check that the test vectors have the structure we expect. This isolates the behavior the test vector generation.
Pull Request Test Coverage Report for Build 166
💛 - Coveralls |
@rsetaluri looks like the most recent checks passed. Is this ready for a final review? |
@leonardt yes it is ready for final review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor change request but I'll make it and do the merge. Thanks for the great work. The verilator target code looks much cleaner, and I think working with Actions is going to lead to better internal code (rather than dealing with test vector indices and such)
tests/test_magma_simulator_target.py
Outdated
circ = common.TestNestedArraysCircuit | ||
tester = fault.Tester(circ) | ||
expected = [random.randint(0, (1 << 4) - 1) for i in range(3)] | ||
expected = [_BV(random.randint(0, (1 << 4) - 1)) for i in range(3)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use random.rand_bv
Started refactoring the tester and targets. Wanted to get some feedback on this -- still more to do if the direction is good. The commit msg should describe the new way of doing things.
@leonardt what do you think?