def generate_flow_network(self, fig_subgraph_view) -> MINTDevice: # TODO - For now just assume that the networks basically are a bunch # of nodes with nets/channels connecting them ret = MINTDevice("flow_network_temp") for node in fig_subgraph_view.nodes: n = MINTNode("node_{}".format(node)) ret.add_component(n) self._store_fig_netlist_name(node, n.ID) i = 1 for node in fig_subgraph_view.nodes: # Create the channel between these nodes channel_name = "c_{}".format(i) i += 1 params = dict() params["channelWidth"] = 400 source = MINTTarget("node_{}".format(node)) sinks = [] # Add all the outgoing edges for edge in fig_subgraph_view.out_edges(node): tar = edge[1] if tar not in fig_subgraph_view.nodes: # We skip because this might be a weird edge that we were not supposed # to have in this network continue sinks.append(MINTTarget("node_{}".format(tar))) ret.addConnection(channel_name, "CHANNEL", params, source, sinks, '0') return ret
def construct_components(self, name_generator: NameGenerator, device: MINTDevice) -> None: for cn in self.construction_nodes: if len(cn.mapping_options) > 1: # TODO - update for combinatorial design space exploration raise Exception( "Does not support Combinatorial design exploration") elif len(cn.mapping_options) == 1: mapping_option = cn.mapping_options[0] # TODO - Make sure we skip the mapping option if pass through is enabled if isinstance(mapping_option, NetworkMappingOption): if mapping_option.mapping_type is NetworkMappingOptionType.PASS_THROUGH: continue if mapping_option.primitive.type is PrimitiveType.COMPONENT: # Create a new component here based on the primitive technology # and the name generator # Then merge with the larger device # Save the copy of subgraph view of the netlist in the construction node component_to_add = mapping_option.primitive.get_default_component( name_generator) device.add_component(component_to_add) self._component_refs[cn.id] = [component_to_add.ID] # for connecting_option in cn # TODO - save the subgraph view reference elif mapping_option.primitive.type is PrimitiveType.NETLIST: netlist = mapping_option.primitive.get_default_netlist( cn.id, name_generator) self._component_refs[cn.id] = [ component.ID for component in netlist.components ] device.merge_netlist(netlist) # TODO - Save the subgraph view reference elif mapping_option.primitive.type is PrimitiveType.PROCEDURAL: netlist = mapping_option.primitive.get_default_netlist( cn.id, name_generator) self._component_refs[cn.id] = [ component.ID for component in netlist.components ] device.merge_netlist(netlist) else: raise Exception( "Does not work with any known option for primitive type" ) cn.load_connection_options() else: print("No mappings found to the current construction node {0}". format(cn))