Skip to content

Commit

Permalink
Add assertions Payload Executor command encoder
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Dudek <[email protected]>
  • Loading branch information
mtdudek committed Nov 28, 2024
1 parent 71fa86b commit b6cc204
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rowhammer_tester/gateware/payload_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ def __init__(self, op_code, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
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}'
self._parts = [
(Decoder.OP_CODE, op_code),
(Decoder.LOOP_COUNT, kwargs['count']),
(Decoder.LOOP_COUNT, count),
(Decoder.LOOP_JUMP, kwargs['jump']),
]
elif op_code == OpCode.NOOP:
Expand All @@ -149,13 +152,16 @@ def __init__(self, op_code, **kwargs):
(Decoder.TIMESLICE_NOOP, kwargs['timeslice']),
]
else:
assert kwargs['timeslice'] != 0, 'Timeslice for instructions other than NOOP should be > 0'
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}'
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)
self._parts = [
(Decoder.OP_CODE, op_code),
(Decoder.TIMESLICE, kwargs['timeslice']),
(Decoder.TIMESLICE, timeslice),
(Decoder.ADDRESS, kwargs.get('address', 0)),
]

Expand Down

0 comments on commit b6cc204

Please sign in to comment.