From afcf133d1a5153eea150144f306ebf5c04a11442 Mon Sep 17 00:00:00 2001 From: Ivan Kosarev Date: Thu, 13 Oct 2022 19:18:04 +0100 Subject: [PATCH] [Sim][#50] Introduce identification of state nodes. --- tests/z80sim/z80sim.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/z80sim/z80sim.py b/tests/z80sim/z80sim.py index 1b1482f..506d904 100755 --- a/tests/z80sim/z80sim.py +++ b/tests/z80sim/z80sim.py @@ -3241,8 +3241,42 @@ def add(ss): def identify_state_nodes(): - s = build_reset_state() - s.get_node_states() + base_state = build_reset_state() + + # Execute a couple nops to make sure the CPU is in its normal + # operational state. + base_state.set_db_and_wait(0x00, 4) # nop + base_state.set_db_and_wait(0x00, 4) # nop + base_state.cache() + + persistent_nodes = base_state.get_node_states() + + # Make sure there are initially no nodes with symbolic states. + assert all(s.value is not None for s in persistent_nodes.values()) + + repeat = True + while repeat: + repeat = False + s = State(base_state) + + # Symbolise non-persistent nodes. + for id in s.get_node_states(): + if id not in persistent_nodes: + s.set_node_state(id, Bool.get(id)) + + s.set_db_and_wait(0x00, 4) # nop + s.cache() + + # Exclude nodes that may end up changing their state from + # persistent nodes. + for id, state in s.get_node_states().items(): + if id in _PINS or id not in persistent_nodes: + continue + if state.is_equiv(persistent_nodes[id]): + continue + # Status.print(id) + del persistent_nodes[id] + repeat = True def build_symbolic_states():