Example #1
0
    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
Example #2
0
    def __create_intercn_channel(self, src_id: str,
                                 name_generator: NameGenerator,
                                 cn: ConstructionNode,
                                 device: MINTDevice) -> None:
        src = self._construction_nodes[src_id]
        start_point = src.output_options[0]

        if start_point.component_name is None:
            # This means a single component was mapped here
            src_component_name = self._component_refs[src_id][0]
        else:
            src_component_name = name_generator.get_cn_name(
                src_id, start_point.component_name)

        end_point = cn.input_options[0]

        if end_point.component_name is None:
            # This means a single component was mapped here
            tar_component_name = self._component_refs[cn.id][0]
        else:
            tar_component_name = name_generator.get_cn_name(
                cn.id, end_point.component_name)

        print(
            "Generating the channel - Source: {0} {2}, Target: {1} {3}".format(
                src_component_name, tar_component_name,
                start_point.component_port, end_point.component_port))

        # TODO - Change how we retrieve the technology type for the channel
        tech_string = "CHANNEL"
        # channel_name = name_generator.generate_name(tech_string)

        # TODO - Figure out how to hande a scenario where this isn't ture
        assert (len(end_point.component_port) == 1)
        if len(start_point.component_port) == 0:
            channel_name = name_generator.generate_name(tech_string)
            source = MINTTarget(src_component_name, None)
            sink = MINTTarget(tar_component_name, end_point.component_port[0])
            device.addConnection(channel_name, tech_string, dict(), source,
                                 [sink], "0")
        else:
            for component_port in start_point.component_port:
                channel_name = name_generator.generate_name(tech_string)
                source = MINTTarget(src_component_name, component_port)
                sink = MINTTarget(tar_component_name,
                                  end_point.component_port[0])
                # TODO - Figure out how to make this layer generate automatically
                device.addConnection(channel_name, tech_string, dict(), source,
                                     [sink], "0")

        # TODO - Once we are done creating a path, we need to delete the start and end point options
        # from their respective construction nodes.
        print("Updated the connectionoptions in {} - Removing {}".format(
            src, start_point))
        src.output_options.remove(start_point)

        print("Updated the connectionoptions in {} - Removing {}".format(
            cn, end_point))
        cn.input_options.remove(end_point)