Skip to content

Commit

Permalink
[Sim][#50] Introduce identification of state nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Oct 13, 2022
1 parent 82de5da commit afcf133
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions tests/z80sim/z80sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit afcf133

Please sign in to comment.