Skip to content

Commit

Permalink
[Sim][#37] Inline __get_group_state().
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Jun 13, 2022
1 parent 2ee6f52 commit 42c2c95
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions tests/z80sim/z80sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,6 @@ def __load_defs(self):
self.__t5 = self.__nodes['t5']
self.__t6 = self.__nodes['t6']

def __get_group_state(self, group):
# 1. deal with power connections first
if self.__gnd in group:
return False
if self.__pwr in group:
return True

# 2. deal with pullup/pulldowns next
for n in group:
if n.pull is not None:
return n.pull

return None

def __set_transistor(self, t, state, recalc_nodes):
if t.state == state:
return
Expand Down Expand Up @@ -370,15 +356,25 @@ def __recalc_node(self, n, recalc_nodes):
if t.state:
worklist.append(t.get_other_conn(n))

new_state = self.__get_group_state(group)

if new_state is None:
state = None
if self.__gnd in group:
state = False
elif self.__pwr in group:
state = True
else:
for n in group:
if n.pull is not None:
state = n.pull
break

if state is None:
# Floating group.
return

for n in group:
if n.state == new_state:
if n.state == state:
continue
n.state = new_state
n.state = state
for t in n.gate_of:
self.__set_transistor(t, n.state, recalc_nodes)

Expand Down

0 comments on commit 42c2c95

Please sign in to comment.