Skip to content

Commit

Permalink
[Sim][#51] Ground and power nodes not to have groups.
Browse files Browse the repository at this point in the history
This prevents unnecessary updates of nodes that were previously
members of these groups.
  • Loading branch information
kosarev committed Jun 12, 2023
1 parent b597f35 commit 5d23047
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/z80sim/z80sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,14 +1298,13 @@ def __identify_group_of(self, n):
worklist = [n]
while worklist:
n = worklist.pop()
if n in group:
if n.is_gnd_or_pwr or n in group:
continue

group.append(n)

if not n.is_gnd_or_pwr:
for t in n.conn_of:
worklist.append(t.get_other_conn(n))
for t in n.conn_of:
worklist.append(t.get_other_conn(n))

return sorted(group)

Expand All @@ -1319,6 +1318,9 @@ def __identify_groups(self):
for m in group:
self.__groups[m] = group

assert self.__gnd not in self.__groups
assert self.__pwr not in self.__groups

def __get_node_preds(self, n):
def get_group_pred(n, get_node_pred, stack, preds):
cyclic = False
Expand Down Expand Up @@ -1395,6 +1397,7 @@ def __update_group_of(self, n, next_round_nodes, updated):
# Update node and transistor states.
for i, n in enumerate(group):
with Status.do(f'update {i}/{len(group)} {n}', '--show-nodes'):
assert not n.is_gnd_or_pwr
gnd, pwr, pullup, pulldown = self.__get_node_preds(n)

floating = n.state
Expand All @@ -1412,7 +1415,8 @@ def __update_group_of(self, n, next_round_nodes, updated):
n.state = state
for t in n.gate_of:
for c in t.conns:
if c not in next_round_nodes:
if (not c.is_gnd_or_pwr and
c not in next_round_nodes):
next_round_nodes.append(c)

updated.add(n)
Expand Down Expand Up @@ -1533,12 +1537,12 @@ def __init__(self, *, memory=None, skip_reset=None, image=None):
self.__restore_nodes_from_image(node_names, nodes, node_storage)
self.__restore_transistors_from_image(trans)

self.__identify_groups()

self.__gnd = self.__nodes_by_name[_GND_ID]
self.__pwr = self.__nodes_by_name[_PWR_ID]
self.__gnd_pwr = self.__gnd, self.__pwr

self.__identify_groups()

self.__nclk = self.__nodes_by_name['~clk']

self.__nbusrq = self.__nodes_by_name['~busrq']
Expand Down

0 comments on commit 5d23047

Please sign in to comment.