From 868447a008da8bdcbe9968ef53a690e0869c9ac2 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Sun, 20 Jul 2025 19:24:58 +1000 Subject: [PATCH] In /8085 adopt new nomenclature "fets" instead of "channels", so rename /scripts/channels.py to /scripts/fets.py and have it produce the fets.txt file, but in /scripts/fets.py it still mostly refers to channels until it writes the output --- .gitignore | 2 +- 8085/Makefile | 10 +++--- scripts/blocks.py | 32 ++++++++--------- scripts/blocks.sh | 2 +- scripts/{channels.py => fets.py} | 6 +++- scripts/gates.py | 60 ++++++++++++++++---------------- 6 files changed, 58 insertions(+), 54 deletions(-) rename scripts/{channels.py => fets.py} (97%) diff --git a/.gitignore b/.gitignore index 304299f..7c911b7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,9 +11,9 @@ /8080/nets.txt /8080/sizes.txt /8085/buried.png -/8085/channels.txt /8085/diff.png /8085/dot +/8085/fets.txt /8085/gates.txt /8085/layers.png /8085/layers_rev.png diff --git a/8085/Makefile b/8085/Makefile index daf8b10..6da6902 100644 --- a/8085/Makefile +++ b/8085/Makefile @@ -25,11 +25,11 @@ layers_rev.png #poly2.png \ #vias2.png -gates.txt: channels.txt - ../scripts/gates.py channels.txt GND,VCC >$@ +gates.txt: fets.txt + ../scripts/gates.py fets.txt GND,VCC >$@ -channels.txt: nodes.txt - ../scripts/channels.py nodes.txt 1,4,5,6,7 >$@ +fets.txt: nodes.txt + ../scripts/fets.py nodes.txt 1,4,5,6,7 >$@ node_sizes.txt: nodes.txt ../scripts/node_sizes.py nodes.txt >$@ @@ -150,7 +150,7 @@ pads.png \ poly.png \ split_diff.png \ vias.png \ -channels.txt \ +fets.txt \ gates.txt \ node_sizes.txt \ nodes.txt diff --git a/scripts/blocks.py b/scripts/blocks.py index 91dcf64..39845d1 100755 --- a/scripts/blocks.py +++ b/scripts/blocks.py @@ -4,23 +4,23 @@ import re import sys if len(sys.argv) < 3: - print(f'usage: {sys.argv[0]:s} channels.txt dot_dir') + print(f'usage: {sys.argv[0]:s} fets.txt dot_dir') sys.exit(1) -channels_txt = sys.argv[1] +fets_txt = sys.argv[1] dot_dir = sys.argv[2] nets = {} blocks = {} -channels = [] -with open(channels_txt) as fin: +fets = [] +with open(fets_txt) as fin: line = fin.readline() assert len(line) fields = [int(i) for i in line.split()] assert len(fields) >= 1 - n_channels = fields[0] + n_fets = fields[0] n_gates = fields[1] if len(fields) >= 2 else 0 - for i in range(n_channels): + for i in range(n_fets): line = fin.readline() assert len(line) fields = line.split() @@ -44,13 +44,13 @@ with open(channels_txt) as fin: for net in [poly_net] + diff_nets: if net not in nets: - nets[net] = set() # blocks (of channels/gates) that the net visits + nets[net] = set() # blocks (of fets/gates) that the net visits nets[net].add(block) if block not in blocks: - blocks[block] = ([], []) # channels, gates - blocks[block][0].append(len(channels)) - channels.append( + blocks[block] = ([], []) # fets, gates + blocks[block][0].append(len(fets)) + fets.append( (block, channel, poly_net, diff_nets, x, y, mass, r_matrix) ) @@ -73,15 +73,15 @@ with open(channels_txt) as fin: for product in expr: for net in product: if net not in nets: - nets[net] = set() # blocks (of channels/gates) that the net visits + nets[net] = set() # blocks (of fets/gates) that the net visits nets[net].add(block) if block not in blocks: - blocks[block] = ([], []) # channels, gates + blocks[block] = ([], []) # fets, gates blocks[block][1].append(len(gates)) gates.append((block, output_net, expr)) -for block, (block_channels, block_gates) in sorted(blocks.items()): +for block, (block_fets, block_gates) in sorted(blocks.items()): with open(f'{dot_dir:s}/{block:s}.dot', 'w') as fout: fout.write(f'digraph "{block:s}" {{\n') @@ -104,10 +104,10 @@ for block, (block_channels, block_gates) in sorted(blocks.items()): fout.write(f' "{net_node:s}" [shape={shape:s}, label="{net:s}"]\n') return net_node - for i in block_channels: - _, channel, poly_net, diff_nets, x, y, mass, r_matrix = channels[i] + for i in block_fets: + _, channel, poly_net, diff_nets, x, y, mass, r_matrix = fets[i] - node = f'channel:{channel:s}' + node = f'fet:{channel:s}' label = channel if len(r_matrix) == 2: label += f'\nR={r_matrix[1][0]:.3f}' diff --git a/scripts/blocks.sh b/scripts/blocks.sh index 9a1ce16..170291f 100755 --- a/scripts/blocks.sh +++ b/scripts/blocks.sh @@ -8,7 +8,7 @@ fi rm -rf dot mkdir dot -`dirname $0`/blocks.py gates.txt dot && ( +`dirname $0`/blocks.py $1 dot && ( cd dot for i in *.dot do diff --git a/scripts/channels.py b/scripts/fets.py similarity index 97% rename from scripts/channels.py rename to scripts/fets.py index 314488a..1031bec 100755 --- a/scripts/channels.py +++ b/scripts/fets.py @@ -158,7 +158,7 @@ def resistor_solver(image): #print('R', 1. / sum_I2, 'squares') return 1. / sum_I2 -print(len(channels)) +fets = [] image = numpy.zeros((ys, xs), numpy.uint8) for (channel, (channel_items, channel_reports)) in sorted(channels.items()): #adjacent_nodes = set([items[item1][0] for _, item1 in channel_reports]) @@ -268,6 +268,10 @@ for (channel, (channel_items, channel_reports)) in sorted(channels.items()): r_matrix[-1].append(resistor_solver(image[min_y:max_y, min_x:max_x])) image[min_y:max_y, min_x:max_x] = 0 + fets.append((block, channel, poly_net, diff_nets, x, y, mass, r_matrix)) + +print(len(fets)) +for block, channel, poly_net, diff_nets, x, y, mass, r_matrix in fets: print(block, channel, poly_net, len(diff_nets), x, y, mass) for i in range(len(diff_nets)): print(' ' + diff_nets[i], ' '.join([str(j) for j in r_matrix[i]])) diff --git a/scripts/gates.py b/scripts/gates.py index 578b83c..bbfe6f6 100755 --- a/scripts/gates.py +++ b/scripts/gates.py @@ -4,19 +4,19 @@ import re import sys if len(sys.argv) < 3: - print(f'usage: {sys.argv[0]:s} channels.txt net_gnd,net_vcc') + print(f'usage: {sys.argv[0]:s} fets.txt net_gnd,net_vcc') sys.exit(1) -channels_txt = sys.argv[1] +fets_txt = sys.argv[1] [net_gnd, net_vcc] = sys.argv[2].split(',') nets = {} -channels = [] -with open(channels_txt) as fin: +fets = [] +with open(fets_txt) as fin: line = fin.readline() assert len(line) - [n_channels] = [int(i) for i in line.split()] + [n_fets] = [int(i) for i in line.split()] - for i in range(n_channels): + for i in range(n_fets): line = fin.readline() assert len(line) fields = line.split() @@ -43,14 +43,14 @@ with open(channels_txt) as fin: nets[net] = [False, 0, []] # visited, n_connections, switches nets[net][1] += 1 - # make an index so we can quickly follow channels wired as switches + # make an index so we can quickly follow fets wired as switches if len(diff_nets) == 2: [diff_net0, diff_net1] = diff_nets - nets[diff_net0][2].append((len(channels), diff_net1)) - nets[diff_net1][2].append((len(channels), diff_net0)) - channels.append( + nets[diff_net0][2].append((len(fets), diff_net1)) + nets[diff_net1][2].append((len(fets), diff_net0)) + fets.append( [True, block, channel, poly_net, diff_nets, x, y, mass, r_matrix] - ) # first element is valid flag, set to False to delete the channel + ) # first element is valid flag, set to False to delete the fet # raised by follow() if pulled-up net doesn't appear to be a logic gate class InvalidGate(Exception): @@ -61,7 +61,7 @@ class InvalidGate(Exception): # inner list has nets to be ANDed together, outer list has products to # be ORed together -- the OR of products, if true, pulls the output down # note: expr of [] does not pull the output down, expr of [[]] does -def follow(del_channels, net, parent_net): +def follow(del_fets, net, parent_net): if net == net_gnd: return [[]] if net == net_vcc: @@ -76,23 +76,23 @@ def follow(del_channels, net, parent_net): try: expr = [] - for channel1, net1 in nets[net][2]: + for fet1, net1 in nets[net][2]: if net1 != parent_net: - del_channels.append(channel1) - valid1, _, _, poly_net1, _, _, _, _, _ = channels[channel1] + del_fets.append(fet1) + valid1, _, _, poly_net1, _, _, _, _, _ = fets[fet1] if not valid1: raise InvalidGate() - expr1 = follow(del_channels, net1, net) + expr1 = follow(del_fets, net1, net) expr.extend([i + [poly_net1] for i in expr1]) return expr finally: nets[net][0] = False gates = [] -for i in range(len(channels)): - valid, block, channel, poly_net, diff_nets, _, _, _, _ = channels[i] +for i in range(len(fets)): + valid, block, _, poly_net, diff_nets, _, _, _, _ = fets[i] if valid: - # look for a channel wired as a pull-up to VCC (implied to be depletion) + # look for a fet wired as a pull-up to VCC (implied to be depletion) if ( poly_net != net_gnd and poly_net != net_vcc and @@ -100,16 +100,16 @@ for i in range(len(channels)): ): # the top level analysis ignores anything connected to the output that # doesn't look like a pull-down (could be driving a transmission gate) - del_channels = [i] + del_fets = [i] expr = [] nets[poly_net][0] = True # set visited flag to avoid infinite recursion - for channel1, net1 in nets[poly_net][2]: - valid1, _, _, poly_net1, _, _, _, _, _ = channels[channel1] + for fet1, net1 in nets[poly_net][2]: + valid1, _, _, poly_net1, _, _, _, _, _ = fets[fet1] if valid1: - del_channels1 = [channel1] + del_fets1 = [fet1] try: - expr1 = follow(del_channels1, net1, poly_net) - del_channels.extend(del_channels1) + expr1 = follow(del_fets1, net1, poly_net) + del_fets.extend(del_fets1) expr.extend([i + [poly_net1] for i in expr1]) except InvalidGate: pass @@ -117,12 +117,12 @@ for i in range(len(channels)): # don't allow constant expr (probably an error or analog circuit) if expr != [] and expr != [[]]: - for channel1 in del_channels: - channels[channel1][0] = False + for fet1 in del_fets: + fets[fet1][0] = False gates.append((block, poly_net, expr)) -n_channels = sum([int(valid) for valid, _, _, _, _, _, _, _, _ in channels]) -print(n_channels, len(gates)) +n_fets = sum([int(valid) for valid, _, _, _, _, _, _, _, _ in fets]) +print(n_fets, len(gates)) for [ valid, block, @@ -133,7 +133,7 @@ for [ y, mass, r_matrix -] in channels: +] in fets: if valid: print(block, channel, poly_net, len(diff_nets), x, y, mass) for i in range(len(diff_nets)): -- 2.34.1