Beispiel #1
0
    def extract_graph(self):
        """ Get a graph of the circuit to display.
        """

        # Extract edges from circuit
        driver_dictionary = self._build_driver_dictionary()
        self.edge_list = self._get_edge_list(driver_dictionary)

        #  Now we can build the graph since we've the vetices(instantiations) and
        # the edges (circuit point-to-point connections).
        self.graph_dict = self._get_graph_dictionary(self.edge_list)

        # Determine which layer of the schematic the blocks belong on
        self.layer_dict = {}
        self.layer_dict = self._determine_layering(self.graph_dict,
                                                   col_dict=self.layer_dict)

        #  Insert dummy nodes to break up long edges - make the graph 'proper'
        self._split_long_edges()

        # DEBUG
        if DEBUG:
            libdb.show_dictionary("Graph Edges Dictionary", self.graph_dict )
            libdb.show_dictionary("Graph Layer Dictionary", self.layer_dict )
            self.show_connections()

        return self.graph_dict
Beispiel #2
0
    def _build_adjacency_dicts(self, debug=False):
        """ Build forward and backwards adjacency dictionaries.
        These are used to get at the y-positions of the adjacent
        vertices of a given node.
        """
        
        if debug:
            print "Building adjacency dicts"
            
        self.forward_adjacent_dict = {}
        self.backward_adjacent_dict = {}
        for source in self.graph_edges.keys():
            if source == '_iport':
                continue
            source_drawobj = self.drawing_object_dict[source]
            sinks = self.graph_edges[source]
            for sink in sinks:
                if debug: print "  source %s, sink %s" % (source, sink)
                self.backward_adjacent_dict.setdefault(source, []).append(source_drawobj)
                if sink != '_oport':
                    sink_drawobj = self.drawing_object_dict[sink]                
                    self.forward_adjacent_dict.setdefault(source, [] ).append(sink_drawobj)

                
        if debug:
            libdb.show_dictionary( "Forward Adjacency Dictionary",
                self.forward_adjacent_dict )
            libdb.show_dictionary( "Backward Adjacency Dictionary",
                self.backward_adjacent_dict )
Beispiel #3
0
    def _build_adjacency_dicts(self, debug=False):
        """ Build forward and backwards adjacency dictionaries.
        These are used to get at the y-positions of the adjacent
        vertices of a given node.
        """

        if debug:
            print "Building adjacency dicts"

        self.forward_adjacent_dict = {}
        self.backward_adjacent_dict = {}
        for source in self.graph_edges.keys():
            if source == '_iport':
                continue
            source_drawobj = self.drawing_object_dict[source]
            sinks = self.graph_edges[source]
            for sink in sinks:
                if debug: print "  source %s, sink %s" % (source, sink)
                self.backward_adjacent_dict.setdefault(
                    source, []).append(source_drawobj)
                if sink != '_oport':
                    sink_drawobj = self.drawing_object_dict[sink]
                    self.forward_adjacent_dict.setdefault(
                        source, []).append(sink_drawobj)

        if debug:
            libdb.show_dictionary("Forward Adjacency Dictionary",
                                  self.forward_adjacent_dict)
            libdb.show_dictionary("Backward Adjacency Dictionary",
                                  self.backward_adjacent_dict)
Beispiel #4
0
    def extract_graph(self):
        """ Get a graph of the circuit to display.
        """

        # Extract edges from circuit
        driver_dictionary = self._build_driver_dictionary()
        self.edge_list = self._get_edge_list(driver_dictionary)

        #  Now we can build the graph since we've the vetices(instantiations) and
        # the edges (circuit point-to-point connections).
        self.graph_dict = self._get_graph_dictionary(self.edge_list)

        # Determine which layer of the schematic the blocks belong on
        self.layer_dict = {}
        self.layer_dict = self._determine_layering(self.graph_dict,
                                                   col_dict=self.layer_dict)

        #  Insert dummy nodes to break up long edges - make the graph 'proper'
        self._split_long_edges()

        # DEBUG
        if DEBUG:
            libdb.show_dictionary("Graph Edges Dictionary", self.graph_dict)
            libdb.show_dictionary("Graph Layer Dictionary", self.layer_dict)
            self.show_connections()

        return self.graph_dict
Beispiel #5
0
    def _assign_horizontal_sections_to_tracks(self, layer, debug=False):
        """ Assign the horizontal sections to tracks.

        Greedy assign as described in [Eschbach et al].
        
        First assign each horizontal section to a unique track.  
        Then we see which net will cause the least crossovers on the top track.
        Then we see which of the other nets causes the least crossovers on the 2nd track.
        And so on until all nets are assigned to a track.
        """
    
        if debug:
            libdb.show_dictionary( "Layered Connection Dictionary",
                                    self.layered_connection_dict )
        
        self._optimize_hypernet_tracks( self.layered_connection_dict[layer], debug )
Beispiel #6
0
    def _assign_horizontal_sections_to_tracks(self, layer, debug=False):
        """ Assign the horizontal sections to tracks.

        Greedy assign as described in [Eschbach et al].
        
        First assign each horizontal section to a unique track.  
        Then we see which net will cause the least crossovers on the top track.
        Then we see which of the other nets causes the least crossovers on the 2nd track.
        And so on until all nets are assigned to a track.
        """

        if debug:
            libdb.show_dictionary("Layered Connection Dictionary",
                                  self.layered_connection_dict)

        self._optimize_hypernet_tracks(self.layered_connection_dict[layer],
                                       debug)
Beispiel #7
0
    def _determine_glue_points(self, debug=False):
        """ Find glue Points for pins on instantiations."""

        self.glue_points = {}

        for layer in self.layered_drawing_object_dict.keys():
            for drawing_obj in self.layered_drawing_object_dict[layer]:
                drawing_obj.build_glue_points_dict()

                if drawing_obj.obj_type == 'hypernet':
                    print "Woops - shouldn't have hypernets at this stage..."

                for pin, position in drawing_obj.glue_points.iteritems():
                    self.glue_points[pin] = position

        if debug:
            libdb.show_dictionary("Glue Point Dictionary", self.glue_points)
Beispiel #8
0
    def _determine_glue_points(self, debug=False):
        """ Find glue Points for pins on instantiations."""
        
        self.glue_points = {}

        for layer in self.layered_drawing_object_dict.keys():
            for drawing_obj in self.layered_drawing_object_dict[layer]:
                drawing_obj.build_glue_points_dict()
            
                if drawing_obj.obj_type == 'hypernet':
                    print "Woops - shouldn't have hypernets at this stage..."
             
                for pin,position in drawing_obj.glue_points.iteritems():
                    self.glue_points[pin] = position
                
        if debug:
            libdb.show_dictionary( "Glue Point Dictionary",
                                   self.glue_points)
Beispiel #9
0
    def _build_drawing_object_dict(self, debug=False):
        """ Build the list of objects to display on the screen.

        Add the instance modules and ports."""

        self.drawing_object_dict = {}

        # Add module instanciations to the list
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if self.module.inst_dict.values():
            for iii, inst in enumerate(self.module.inst_dict.values()):

                drawobj = Drawing_Object(
                    name=inst.module_ref.name,
                    parent=self,  #hmmm, for flightlines only! FIXME
                    label=inst.name,
                    obj_type='module',
                )

                submod = inst.module_ref
                for port_name in submod.port_name_list:
                    port = submod.port_dict[
                        port_name]  # This preserves port ordering
                    if port.direction == 'input':
                        drawobj.lhs_ports.append(port.GetLabelStr())
                    else:
                        drawobj.rhs_ports.append(port.GetLabelStr())

                # Add to drawing object dict
                self.drawing_object_dict[inst.name] = drawobj

        else:
            # a wee fake thingy for modules with no sub modules
            drawobj = Drawing_Object(
                name='_Nothing_',
                parent=self,  #hmmm, for flightlines only! FIXME
                label='_here',
                obj_type='module')

            self.drawing_object_dict['_Nothing'] = drawobj

        # Add the port instances
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if self.module.port_name_list:
            for port in self.module.port_dict.values():

                if port.direction == 'input':
                    key = '_iport'
                else:
                    key = '_oport'

                # Unitless positions for the meantime
                #x_pos += 2 # inst_col_dict[key]
                drawobj = Drawing_Object(
                    name='port',
                    parent=self,  #hmmm
                    label=port.GetLabelStr(),
                    obj_type='port')

                #print port.direction
                if port.direction == 'output':
                    drawobj.mirror = True

                drawobj._update_sizes()

                # Add to drawing object dict
                self.drawing_object_dict[port.GetLabelStr()] = drawobj

        else:
            print "Woops, modules should have ports, " + \
                  self.module.name + " doesn't seem to have ones!"

        #  Add any passthrus as they are needed.  These are vertice
        # names in the graph dictionary which are not covered by
        # inst or port names.
        passthru_id = 0
        for node in self.graph_edges.keys():
            if not self.drawing_object_dict.get(node, None):
                if node == '_iport':
                    continue

                if debug: print "Found a new thang..", node
                drawobj = Drawing_Object(
                    name=node + '_' + str(passthru_id),
                    parent=self,  #hmmm, for flightlines only! FIXME
                    label=node,
                    obj_type='passthru',
                )

                drawobj.lhs_ports.append('_in')
                drawobj.rhs_ports.append('_out')
                drawobj.startpt = wx.Point(0, 0)
                drawobj.endpt = wx.Point(20, 0)

                self.drawing_object_dict[node] = drawobj

                passthru_id += 1

        if debug:
            libdb.show_dictionary("Drawing Object Dictionary",
                                  self.drawing_object_dict)
Beispiel #10
0
    def _build_drawing_object_dict( self, debug=False):
        """ Build the list of objects to display on the screen.

        Add the instance modules and ports."""
        
        
        self.drawing_object_dict = {} 
   
        # Add module instanciations to the list
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if self.module.inst_dict.values() :
            for iii,inst in enumerate(self.module.inst_dict.values()):

                drawobj = Drawing_Object( name=inst.module_ref.name,
                                           parent=self,  #hmmm, for flightlines only! FIXME
                                           label=inst.name,
                                           obj_type='module',
                                        )

                submod = inst.module_ref
                for port_name in submod.port_name_list:
                    port = submod.port_dict[ port_name ] # This preserves port ordering
                    if port.direction == 'input':
                        drawobj.lhs_ports.append( port.GetLabelStr() )
                    else:
                        drawobj.rhs_ports.append( port.GetLabelStr() )

                
                # Add to drawing object dict
                self.drawing_object_dict[inst.name] = drawobj
                
        else:
            # a wee fake thingy for modules with no sub modules
            drawobj = Drawing_Object( name='_Nothing_',
                                       parent=self, #hmmm, for flightlines only! FIXME
                                       label='_here',
                                       obj_type='module')

            self.drawing_object_dict['_Nothing'] = drawobj


        # Add the port instances
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if self.module.port_name_list:
            for port in self.module.port_dict.values():
                
                if port.direction == 'input':
                    key = '_iport'
                else:
                    key = '_oport'

                # Unitless positions for the meantime
                #x_pos += 2 # inst_col_dict[key]
                drawobj = Drawing_Object( name='port',
                                           parent=self, #hmmm
                                           label=port.GetLabelStr(),
                                           obj_type='port' )

                #print port.direction
                if port.direction == 'output':
                    drawobj.mirror = True

                drawobj._update_sizes()

                # Add to drawing object dict
                self.drawing_object_dict[port.GetLabelStr()] = drawobj

        else:
            print "Woops, modules should have ports, " + \
                  self.module.name + " doesn't seem to have ones!"


        #  Add any passthrus as they are needed.  These are vertice
        # names in the graph dictionary which are not covered by
        # inst or port names.
        passthru_id = 0
        for node in self.graph_edges.keys():
            if not self.drawing_object_dict.get( node, None ):
                if node == '_iport':
                    continue

                if debug: print "Found a new thang..", node
                drawobj = Drawing_Object( name=node + '_' + str(passthru_id),
                                          parent=self,  #hmmm, for flightlines only! FIXME
                                          label=node,
                                          obj_type='passthru',
                                        )                

                drawobj.lhs_ports.append( '_in' )
                drawobj.rhs_ports.append( '_out' )
                drawobj.startpt = wx.Point(0,0)
                drawobj.endpt   = wx.Point(20,0)

                self.drawing_object_dict[node] = drawobj

                passthru_id += 1
           
        if debug:     
            libdb.show_dictionary( "Drawing Object Dictionary",
                                   self.drawing_object_dict )