Skip to content

Commit

Permalink
Update 'test_payload_loop' unittests
Browse files Browse the repository at this point in the history
After adding checks to the timeslice field, 'test_payload_loop'
unittests started failing as they used 40 or 50, but max supported
is 31. This commit changes offending timeslices to 30, as these
unittests check executed commands and not evaluation time.

This commit also updates assertion message to print correct max values.

Signed-off-by: Maciej Dudek <[email protected]>
  • Loading branch information
mtdudek committed Nov 28, 2024
1 parent f6add2d commit 38198c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions rowhammer_tester/gateware/payload_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, op_code, **kwargs):
if op_code == OpCode.LOOP:
count = kwargs["count"]
assert count < 2**Decoder.LOOP_COUNT, \
f'LOOP count value:{count} exceeded max value:{2**Decoder.LOOP_COUNT}'
f'LOOP count value:{count} exceeded max value:{2**Decoder.LOOP_COUNT - 1}'
self._parts = [
(Decoder.OP_CODE, op_code),
(Decoder.LOOP_COUNT, count),
Expand All @@ -155,7 +155,7 @@ def __init__(self, op_code, **kwargs):
timeslice = kwargs['timeslice']
assert timeslice != 0, 'Timeslice for instructions other than NOOP should be > 0'
assert timeslice < 2**Decoder.TIMESLICE, \
f'Timeslice value:{timeslice} exceeded max value:{2**Decoder.TIMESLICE}'
f'Timeslice value:{timeslice} exceeded max value:{2**Decoder.TIMESLICE - 1}'
no_address = [OpCode.REF] # PRE requires bank address
assert 'address' in kwargs or op_code in no_address, \
'{} instruction requires `address`'.format(op_code.name)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_payload_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ def test_payload_loop(self):
encoder(OpCode.ACT, timeslice=10, address=encoder.address(bank=0, row=100)),
encoder(OpCode.READ, timeslice=30, address=encoder.address(bank=0, col=200)),
encoder(OpCode.LOOP, count=8 - 1, jump=1), # to READ col=200
encoder(OpCode.PRE, timeslice=40, address=encoder.address(bank=0)),
encoder(OpCode.REF, timeslice=50),
encoder(OpCode.REF, timeslice=50),
encoder(OpCode.PRE, timeslice=30, address=encoder.address(bank=0)),
encoder(OpCode.REF, timeslice=30),
encoder(OpCode.REF, timeslice=30),
encoder(OpCode.LOOP, count=5 - 1, jump=2), # to first REF
]

Expand Down Expand Up @@ -795,9 +795,9 @@ def test_payload_loop(self):
encoder(OpCode.ACT, timeslice=10, address=encoder.address(bank=0, row=100)),
encoder(OpCode.READ, timeslice=30, address=encoder.address(bank=0, col=200)),
encoder(OpCode.LOOP, count=8 - 1, jump=1), # to READ col=200
encoder(OpCode.PRE, timeslice=40, address=encoder.address(bank=0)),
encoder(OpCode.REF, timeslice=50),
encoder(OpCode.REF, timeslice=50),
encoder(OpCode.PRE, timeslice=30, address=encoder.address(bank=0)),
encoder(OpCode.REF, timeslice=30),
encoder(OpCode.REF, timeslice=30),
encoder(OpCode.LOOP, count=5 - 1, jump=2), # to first REF
]

Expand Down

0 comments on commit 38198c2

Please sign in to comment.