Skip to content

Commit

Permalink
[Sim][#37] Rename the node fields storing associated transistors.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Jun 13, 2022
1 parent 403e05f commit 8ffd98d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/z80sim/z80sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ def __init__(self, index, pull):
self.custom_id = None
self.index, self.pull = index, pull
self.state = False
self.gates = []
self.c1c2s = []

# These are not sets as we want reproducible behaviour.
self.gate_of = []
self.conn_of = []

def __repr__(self):
return self.id
Expand Down Expand Up @@ -175,9 +177,9 @@ def __load_transistors(self):
assert index not in self.__trans
self.__trans[index] = t

gate.gates.append(t)
c1.c1c2s.append(t)
c2.c1c2s.append(t)
gate.gate_of.append(t)
c1.conn_of.append(t)
c2.conn_of.append(t)

def __load_defs(self):
self.__load_nodes()
Expand Down Expand Up @@ -218,7 +220,7 @@ def __add_node_to_group(self, n, group):
if n in self.__gnd_pwr:
return

for t in n.c1c2s:
for t in n.conn_of:
if t.state:
other = t.c1 if n is t.c2 else t.c2
self.__add_node_to_group(other, group)
Expand All @@ -241,7 +243,7 @@ def __get_group_state(self, group):
max_state = False
max_connections = 0
for n in group:
connections = len(n.gates) + len(n.c1c2s)
connections = len(n.gate_of) + len(n.conn_of)
if max_connections < connections:
max_connections = connections
max_state = n.state
Expand Down Expand Up @@ -279,7 +281,7 @@ def __recalc_node(self, n, recalc_nodes):
if n.state == new_state:
continue
n.state = new_state
for t in n.gates:
for t in n.gate_of:
self.__set_transistor(t, n.state, recalc_nodes)

def __recalc_node_list(self, recalc_nodes):
Expand Down

0 comments on commit 8ffd98d

Please sign in to comment.