Skip to content

Commit

Permalink
[Sim][#50] Refine passing the instruction latch to the node-testing f…
Browse files Browse the repository at this point in the history
…unction.
  • Loading branch information
kosarev committed Oct 7, 2022
1 parent 0b56aea commit e17eb22
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/z80sim/z80sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,7 @@ class TestFailure(Exception):
pass


def test_node(instrs, n, prev_instr_latch, before, after):
def test_node(instrs, n, at_start, before, after):
def check(x):
x = is_active(n).xifelse(x, before[n])

Expand Down Expand Up @@ -2246,7 +2246,7 @@ def get_pc_plus(off):
# TODO: Does this agree with the current known
# description of the behaviour?
f = get_f()[i]
op = prev_instr_latch
op = Bits(at_start[f'instr{b}'] for b in range(8))
x = Bits(op.bits[6:8])
z = Bits(op.bits[0:3])
q = op[3]
Expand Down Expand Up @@ -2744,15 +2744,14 @@ def get_cond_as_expr(cond, before):
SAMPLED_NODES.update((f'reg_{r}{i}', f'reg_{r}{r}{i}'))
for r in ('pch', 'pcl', 'sph', 'spl', 'i', 'r'):
SAMPLED_NODES.add(f'reg_{r}{i}')
SAMPLED_NODES.add(f'instr{i}')

phase = len(instrs)
id = instrs[-1]
cycles = TestedInstrs.get_cycles(id, phase)

s = State(base_state)

instr_latch = s.get_node_states(f'instr{i}' for i in range(8))
instr_latch = Bits(instr_latch[f'instr{i}'] for i in range(8))
at_start = s.get_node_states(SAMPLED_NODES)

before = get_effective_states(s)
for cycle_no, (d, ticks, cond) in enumerate(cycles):
Expand All @@ -2775,7 +2774,7 @@ def get_cond_as_expr(cond, before):
after = get_effective_states(s)

for n in sorted(TESTED_NODES):
token = test_node(instrs, n, instr_latch, before, after)
token = test_node(instrs, n, at_start, before, after)
assert isinstance(token, CheckToken)

return after_instr_state
Expand Down

0 comments on commit e17eb22

Please sign in to comment.