@@ -79,7 +79,7 @@ def optimize(
7979 return block
8080
8181
82- def _get_inverter_chains (wire_creator , wire_users ):
82+ def _get_inverter_chains (wire_src_dict , wire_dst_dict ):
8383 """Returns all inverter chains in the block.
8484
8585 The function returns a list of inverter chains in the block. Each inverter chain is
@@ -98,7 +98,7 @@ def _get_inverter_chains(wire_creator, wire_users):
9898 # Build a list of inverter chains. Each inverter chain is a list of WireVectors,
9999 # from source to destination.
100100 inverter_chains = []
101- for current_dest , current_creator in wire_creator .items ():
101+ for current_dest , current_creator in wire_src_dict .items ():
102102 if current_creator .op != "~" :
103103 # Skip non-inverters.
104104 continue
@@ -107,7 +107,7 @@ def _get_inverter_chains(wire_creator, wire_users):
107107 # a WireVector).
108108 current_arg = current_creator .args [0 ]
109109 # current_users is the number of LogicNets that use current_dest.
110- current_users = len (wire_users [current_dest ])
110+ current_users = len (wire_dst_dict [current_dest ])
111111
112112 # Add the current inverter to the end of this inverter chain.
113113 append_to = None
@@ -117,7 +117,7 @@ def _get_inverter_chains(wire_creator, wire_users):
117117 for inverter_chain in inverter_chains :
118118 chain_arg = inverter_chain [0 ]
119119 chain_dest = inverter_chain [- 1 ]
120- chain_users = len (wire_users [chain_dest ])
120+ chain_users = len (wire_dst_dict [chain_dest ])
121121
122122 if chain_dest is current_arg and chain_users == 1 :
123123 # This chain's only destination is the current inverter. Append the
@@ -168,9 +168,9 @@ def _optimize_inverter_chains(block, skip_sanity_check=False):
168168 B -w-> Y
169169 """
170170
171- # wire_creator maps from WireVector to the LogicNet that defines its value.
172- # wire_users maps from WireVector to a list of LogicNets that use its value.
173- wire_creator , wire_users = block .net_connections ()
171+ # wire_src_dict maps from WireVector to the LogicNet that defines its value.
172+ # wire_dst_dict maps from WireVector to a list of LogicNets that use its value.
173+ wire_src_dict , wire_dst_dict = block .net_connections ()
174174
175175 new_logic = set ()
176176 net_removal_set = set ()
@@ -199,9 +199,9 @@ def _optimize_inverter_chains(block, skip_sanity_check=False):
199199 # will be mapped to A and E will be mapped to C. Hence, when finding the replacement
200200 # of E, we have to first query the dict to get C, and then query the dict again on C
201201 # to get A.
202- wire_src_dict = _ProducerList ()
202+ wire_producer = _ProducerList ()
203203
204- for inverter_chain in _get_inverter_chains (wire_creator , wire_users ):
204+ for inverter_chain in _get_inverter_chains (wire_src_dict , wire_dst_dict ):
205205 # If len(inverter_chain) = n, there are n-1 inverters in the chain. We only
206206 # remove inverters if there are at least two inverters in a chain.
207207 if len (inverter_chain ) > 2 :
@@ -215,10 +215,10 @@ def _optimize_inverter_chains(block, skip_sanity_check=False):
215215 wires_to_remove = inverter_chain [start_idx :]
216216 wire_removal_set .update (wires_to_remove )
217217 # Remove inverters used in the chain.
218- inverters_to_remove = {wire_creator [wire ] for wire in wires_to_remove }
218+ inverters_to_remove = {wire_src_dict [wire ] for wire in wires_to_remove }
219219 net_removal_set .update (inverters_to_remove )
220220 # Map the end wire of the inverter chain to the beginning wire.
221- wire_src_dict [inverter_chain [- 1 ]] = inverter_chain [start_idx - 1 ]
221+ wire_producer [inverter_chain [- 1 ]] = inverter_chain [start_idx - 1 ]
222222
223223 # This loop recreates the block with inverter chains removed. It adds each LogicNet
224224 # in the original block to the new block if it is not marked for removal, and
@@ -230,7 +230,7 @@ def _optimize_inverter_chains(block, skip_sanity_check=False):
230230 LogicNet (
231231 net .op ,
232232 net .op_param ,
233- args = tuple (wire_src_dict .find_producer (x ) for x in net .args ),
233+ args = tuple (wire_producer .find_producer (x ) for x in net .args ),
234234 dests = net .dests ,
235235 )
236236 )
@@ -1042,7 +1042,7 @@ def direct_connect_outputs(block=None):
10421042 # NOTE: would use transform.all_nets(), but it becomes tricky when we want to remove
10431043 # more than just the current net on a single pass
10441044 block = working_block (block )
1045- _ , dst_nets = block .net_connections ()
1045+ _wire_src_dict , wire_dst_dict = block .net_connections ()
10461046
10471047 nets_to_remove = set ()
10481048 nets_to_add = set ()
@@ -1053,10 +1053,10 @@ def direct_connect_outputs(block=None):
10531053 continue
10541054
10551055 dest_wire = net .dests [0 ]
1056- if dest_wire not in dst_nets or len (dst_nets [dest_wire ]) > 1 :
1056+ if dest_wire not in wire_dst_dict or len (wire_dst_dict [dest_wire ]) > 1 :
10571057 continue
10581058
1059- dst_net = dst_nets [dest_wire ][0 ]
1059+ dst_net = wire_dst_dict [dest_wire ][0 ]
10601060 if dst_net .op != "w" or not isinstance (dst_net .dests [0 ], Output ):
10611061 continue
10621062
@@ -1105,7 +1105,7 @@ def two_way_fanout(block=None):
11051105
11061106 block = working_block (block )
11071107
1108- _ , dst_map = block .net_connections ()
1108+ _wire_src_dict , wire_dst_dict = block .net_connections ()
11091109 # Two-pass approach: Remember which nets will need to change, in case there are
11101110 # multiple arguments which will be changing along the way.
11111111 nets_to_update = collections .defaultdict (list )
@@ -1114,7 +1114,7 @@ def two_way_fanout(block=None):
11141114 if curr_fanout > 1 :
11151115 s = _make_tree (wire , block , curr_fanout )
11161116 curr_ix = 0
1117- for dst_net in dst_map [wire ]:
1117+ for dst_net in wire_dst_dict [wire ]:
11181118 for i , arg in enumerate (dst_net .args ):
11191119 if arg is wire :
11201120 nets_to_update [dst_net ].append ((wire , i , s [curr_ix ]))
0 commit comments