コード例 #1
0
ファイル: diagram.py プロジェクト: imclab/SpiNNer
 def add_wire(self, board, direction, styles=None):
     self._add_path([
         "board %d %s" % (board.id, Diagram.DIRECTION_POSTFIX[direction]),
         "board %d %s" %
         (board.follow_wire(direction).id,
          Diagram.DIRECTION_POSTFIX[topology.opposite(direction)])
     ], styles)
コード例 #2
0
def generate_wiring_instructions(boards, socket_names):
	# Instructions for wiring systems up
	
	out = ""
	
	b2c = dict(boards)
	
	wires = []
	for board, source_coord in cabinet_torus:
		for direction in [NORTH, EAST, SOUTH_WEST]:
			target_coord = b2c[board.follow_wire(direction)]
			
			source = tuple(list(source_coord) + [socket_names[direction]])
			target = tuple(list(target_coord) + [socket_names[topology.opposite(direction)]])
			
			# List wires in bottom-left to top-right order
			wires.append(tuple(sorted([source,target])))
	
	# (cabinet,rack) -> [wire,...]
	wires_between_slots = defaultdict(list)
	# (cabinet) -> [wire,...]
	wires_between_racks = defaultdict(list)
	# [wire,...]
	wires_between_cabinets = []
	
	for source, target in wires:
		if source[0:2] == target[0:2]:
			# Same cabinet and rack
			wires_between_slots[(source[0:2])].append((source,target))
		elif source[0] == target[0]:
			# Same cabinet
			wires_between_racks[source[0]].append((source,target))
		else:
			# Different cabinet
			wires_between_cabinets.append((source,target))
	
	# Within-rack wires
	out += r"\subsection{Wires Within Racks}"
	for cabinet_num in range(num_cabinets):
		for rack_num in range(num_racks_per_cabinet):
			out += r"\subsubsection{Cabinet %d, Rack %d}"%(cabinet_num, rack_num)
			out += generate_wiring_list(wires_between_slots[(cabinet_num,rack_num)])
	
	# Within-cabinet wires
	if wires_between_racks:
		out += r"\newpage\subsection{Wires Within Cabinets}"
		for cabinet_num in range(num_cabinets):
			out += r"\subsubsection{Cabinet %d}"%(cabinet_num)
			out += generate_wiring_list(wires_between_racks[(cabinet_num)])
	
	# Global wires
	if wires_between_cabinets:
		out += r"\newpage\subsection{Wires Between Cabinets}"
		out += generate_wiring_list(wires_between_cabinets)
	
	return out
コード例 #3
0
def generate_packet_loop(boards, direction, diagram, start = (0,0,0)):
	c2b = dict((c,b) for (b,c) in boards)
	start_board = c2b[start]
	loop = list(board.follow_packet_loop( start_board
	                                    , topology.opposite(direction)
	                                    , direction
	                                    ))
	style = ["thick", dict(DIRECTION_COLOURS)[direction]]
	
	for in_direction, b in loop:
		diagram.add_packet_path( b
		                       , in_direction
		                       , topology.opposite(b.follow_packet(in_direction, direction)[0])
		                       , ["dashed"] + style
		                       )
		diagram.add_wire( b
		                , in_direction
		                , style
		                )
	
	# Number of boards crossed is (threeboards_crossed*3)/2 and the number of
	# nodes crossed is 4 times this (see Simon's document).
	return ((len(loop)*3)/2) * 4
コード例 #4
0
def generate_wiring_loop(boards, direction, diagram, start = (0,0,0)):
	c2b = dict((c,b) for (b,c) in boards)
	start_board = c2b[start]
	loop = list(board.follow_wiring_loop(start_board, direction))
	
	style = ["thick", dict(DIRECTION_COLOURS)[direction]]
	
	for b in loop:
		diagram.add_wire( b
		                , direction
		                , style
		                )
		diagram.add_packet_path( b
		                       , direction
		                       , topology.opposite(direction)
		                       , ["dashed"] + style
		                       )
	
	return len(loop)
コード例 #5
0
ファイル: diagram.py プロジェクト: imclab/SpiNNer
    def add_curved_wire(self, board, direction, styles=None):
        offset = {
            topology.NORTH: (0, 1, 0),
            topology.SOUTH: (0, -1, 0),
            topology.NORTH_EAST: (0, 0, -1),
            topology.SOUTH_WEST: (0, 0, 1),
            topology.EAST: (1, 0, 0),
            topology.WEST: (-1, 0, 0),
        }[direction]
        self.path_definitions += r"""
			\draw [%s] [hexagon coords]
				(%s) ..
				  controls +(%d,%d,%d)
				       and +(%d,%d,%d)
				.. (%s)
				;
		""" % (",".join(styles), "board %d %s" %
         (board.id, Diagram.DIRECTION_POSTFIX[direction]), offset[0],
         offset[1], offset[2], -offset[0], -offset[1], -offset[2],
         "board %d %s" %
         (board.follow_wire(direction).id,
          Diagram.DIRECTION_POSTFIX[topology.opposite(direction)])) + "\n"