Store complete wire information within netlist object, Begin implementing a generic record search function

master
Aaron Goldstein 2020-05-21 19:54:15 -07:00
parent 478ea80e62
commit 3c16630df4
1 changed files with 32 additions and 5 deletions

View File

@ -76,6 +76,7 @@ def determine_parts_list(schematic):
def determine_net_list(schematic): def determine_net_list(schematic):
wires = [ record for record in schematic["records"] if record["RECORD"] == "27" ] wires = [ record for record in schematic["records"] if record["RECORD"] == "27" ]
pins = [ record for record in schematic["records"] if record["RECORD"] == 2 ]
p = re.compile('^(?P<prefix>X)(?P<index>\d+)$') p = re.compile('^(?P<prefix>X)(?P<index>\d+)$')
for wire in wires: for wire in wires:
@ -88,24 +89,50 @@ def determine_net_list(schematic):
if wire["index"] not in [id for net in nets for id in net]: if wire["index"] not in [id for net in nets for id in net]:
nets.append(find_connected_wires(wire, [], schematic)) nets.append(find_connected_wires(wire, [], schematic))
visited, found = find_record(schematic, key="RECORD", value="2")
schematic["nets"] = nets schematic["nets"] = nets
return schematic return schematic
def find_record(schematic, key, value, record=None, visited=None, found=None):
print("finding records where: {0} = {1}".format(key, value))
if visited == None:
visited = []
if found == None:
found = []
if record == None:
for record in schematic['records']:
visited, found = find_record(schematic, key, value, record=record, visited=visited, found=found)
else:
if record['index'] not in [r['index'] for r in visited]:
visited.append(record)
if key in record.keys():
if record[key] == value:
found.append(record)
if "children" in record.keys():
for child_record in record["children"]:
visited, found = find_record(schematic, key, value, record=child_record, visited=visited, found=found)
return visited, found
def find_connected_wires(wire, visited, schematic): def find_connected_wires(wire, visited, schematic):
neighbors = find_neighbors(wire, schematic) neighbors = find_neighbors(wire, schematic)
print('entering: {0}'.format(wire['index'])) print('entering: {0}'.format(wire['index']))
if wire['index'] not in visited: if wire['index'] not in [w['index'] for w in visited]:
print('adding: {0} to {1}'.format(wire['index'], visited)) print('adding: {0} to {1}'.format(wire['index'], [w['index'] for w in visited]))
visited.append(wire['index']) visited.append(wire)
for neighbor in neighbors: for neighbor in neighbors:
print('trying: {0} of {1}'.format(neighbor['index'], [x['index'] for x in neighbors])) print('trying: {0} of {1}'.format(neighbor['index'], [x['index'] for x in neighbors]))
visited = find_connected_wires(neighbor, visited, schematic) visited = find_connected_wires(neighbor, visited, schematic)
print('visited = {0}'.format(visited)) print('visited = {0}'.format([w['index'] for w in visited]))
else: else:
print('skipping: {0} already in list {1}'.format(wire['index'], visited)) print('skipping: {0} already in list {1}'.format(wire['index'], [w['index'] for w in visited]))
print('returning: {0}'.format(wire['index'])) print('returning: {0}'.format(wire['index']))
return visited return visited