From 72fec22691d8c3f8c29008e6f8984e563f0e3243 Mon Sep 17 00:00:00 2001 From: Ivan Kosarev Date: Wed, 29 Sep 2021 21:41:22 +0100 Subject: [PATCH] [#37] __recalc_node_list() to take nodes instead of indexes. --- tests/z80sim/z80sim.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/z80sim/z80sim.py b/tests/z80sim/z80sim.py index ef5f862..96af10f 100755 --- a/tests/z80sim/z80sim.py +++ b/tests/z80sim/z80sim.py @@ -146,7 +146,7 @@ def __load_defs(self): self.__load_transistors() def __all_nodes(self): - return [n.id for n in self.__nodes.values() + return [n for n in self.__nodes.values() if n not in (self.__gnd, self.__pwr)] def __add_node_to_group(self, n): @@ -242,31 +242,31 @@ def __recalc_node(self, n): else: self.__turn_transistor_off(t) - def __recalc_node_list(self, list): + def __recalc_node_list(self, nodes): self.__recalc_list = [] self.__recalc_hash = set() for j in range(100): # Loop limiter. - if len(list) == 0: + if len(nodes) == 0: return - for i in list: - self.__recalc_node(self.__nodes[i]) + for n in nodes: + self.__recalc_node(n) - list = self.__recalc_list + nodes = [self.__nodes[i] for i in self.__recalc_list] self.__recalc_list = [] self.__recalc_hash = set() def __set_low(self, id): - i = self.__node_ids[id] - self.__nodes[i].pullup = False - self.__nodes[i].pulldown = True - self.__recalc_node_list([i]) + n = self.__nodes[self.__node_ids[id]] + n.pullup = False + n.pulldown = True + self.__recalc_node_list([n]) def __set_high(self, id): - i = self.__node_ids[id] - self.__nodes[i].pullup = True - self.__nodes[i].pulldown = False - self.__recalc_node_list([i]) + n = self.__nodes[self.__node_ids[id]] + n.pullup = True + n.pulldown = False + self.__recalc_node_list([n]) def __is_node_high(self, nn): return self.__nodes[nn].state