OpenCores
URL https://opencores.org/ocsvn/nocmodel/nocmodel/trunk

Subversion Repositories nocmodel

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /nocmodel
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

/trunk/nocmodel/noc_base.py
0,0 → 1,888
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoC Base Objects
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
================
NoCmodel Base Objects
================
This module declares classes used on a Network-on-chip representation:
* NoC container class
* Router base class
* Channel base class
* IPCore base class
* Protocol base class
* Packet class
"""
 
import networkx as nx
 
class noc(nx.Graph):
"""
Base class for NoC modeling.
Based on a Graph object that hold the NoC structure
Arguments
* kwargs: optional parameters to put as object attributes
"""
def __init__(self, **kwargs):
"""
NoCmodel constructor
"""
nx.Graph.__init__(self, **kwargs)
 
# objects management functions
def add_router(self, name="", with_ipcore=False, **kwargs):
"""
Create a base router object and add it to NoC model.
 
Arguments
* name: optional name for this router. By default has the form of
"R_<index>"
* with_ipcore: If True, add an ipcore to the created router.
* kwargs: optional parameters to put as object attributes
 
Return: reference to the created router object
"""
#nodeidx = self._get_next_nodeidx()
routernode = router(index=None, name=name, graph_ref=self, **kwargs)
retval = self.add_router_from_object(routernode)
if name == "":
retval.name = "R_%d" % retval.index
if with_ipcore:
# kwargs are reserved for router creation, not for ipcore.
self.add_ipcore(retval)
return retval
def add_router_from_object(self, router_ref):
"""
Add an existing router object to NoC model.
Use this function to add an object based on a derived class of
base router defined in this module.
 
Arguments
* router_ref: reference to the router object
 
Return: the same reference passed in router_ref
Notes:
* This function will change router_ref.index and router_ref.graph_ref
attributes when inserted in the NoC model.
"""
if not isinstance(router_ref, router):
raise ValueError("Argument 'router_ref' is not a router object.")
 
router_ref.index = self._get_next_nodeidx()
router_ref.graph_ref = self
# don't forget that index is used for address
router_ref.address = router_ref.index
self.add_node(router_ref.index, router_ref=router_ref)
return router_ref
 
def add_channel(self, router1, router2, name="", **kwargs):
"""
Create a base channel object to link two objects and add it
to NoC model.
 
Arguments:
* router1: reference to a router, router index or ipcore
* router2: -idem-
* name: optional argument for channel name
* kwargs: optional parameters to put as object attributes
 
Notes:
* If router1 or router2 is an ipcore reference, this method creates
the special channel object and update ipcore references. Additionally,
if both arguments are ipcores, throw an error exception
"""
if isinstance(router1, ipcore) and isinstance(router2, ipcore):
raise ValueError("Both object references cannot be ipcore objects.")
 
rhash = [None, None]
rrefs = [None, None]
for targetid, routertarget in enumerate((router1, router2)):
if isinstance(routertarget, router):
if routertarget.index in self.node:
rhash[targetid] = routertarget.index
rrefs[targetid] = self.node[routertarget.index]["router_ref"]
elif isinstance(routertarget, ipcore):
# special channel
rhash[targetid] = None
rrefs[targetid] = routertarget
elif isinstance(routertarget, int):
if routertarget in self.node:
rhash[targetid] = routertarget
rrefs[targetid] = self.node[routertarget]["router_ref"]
 
if rrefs[0] is None:
raise ValueError("Object not found for argument 'router1'")
if rrefs[1] is None:
raise ValueError("Object not found for argument 'router2'")
 
if None in rhash:
ipcore_idx = rhash.index(None)
# ipcore channel
if name == "":
# channel default name format
name = "CH_IP_%s" % rrefs[ipcore_idx].name
channelnode = channel(index=None, name=name, graph_ref=self, **kwargs)
else:
# inter-routers channel
if name == "":
# channel default name format
name = "CH_%s:%s" % (rrefs[0].name, rrefs[1].name)
channelnode = channel(index=self._get_next_edgeidx(), name=name, graph_ref=self, **kwargs)
self.add_edge(rhash[0], rhash[1], channel_ref = channelnode)
channelnode.endpoints = rrefs
return channelnode
def add_from_channel(self, channel_ref, router1=None, router2=None):
"""
Add a channel object to NoC model.
Use this function to add an object based on a derived class of
base channel defined in this module.
 
Arguments
* channel_ref: reference to the channel object
* router1: optional reference to a router, router index or ipcore
* router2: -idem-
Return: the same reference passed in channel_ref
Notes:
* If router1 or router2 are not used as arguments, will assume that
channel object has defined its attribute "endpoints" with the
objects to connect. If the objects don't exist in the NoC model,
throw an error exception.
 
* If router1 or router2 is an ipcore reference, this method creates
the special channel object and update ipcore references. Additionally,
if both arguments are ipcores, throw an error exception.
* This function will change channel_ref.index and channel_ref.graph_ref
attributes when inserted in the NoC model. Also it may change
channel_ref.endpoints with router1 and router2 references.
"""
if not isinstance(channel_ref, channel):
raise ValueError("Argument 'channel_ref' is not a channel object.")
 
if isinstance(router1, ipcore) and isinstance(router2, ipcore):
raise ValueError("Both object references cannot be ipcore objects.")
 
rhash = [None, None]
rrefs = [None, None]
for targetid, routertarget in enumerate((router1, router2)):
if isinstance(routertarget, router):
if routertarget.index in self.node:
rhash[targetid] = routertarget.index
rrefs[targetid] = self.node[routertarget.index]["router_ref"]
elif isinstance(routertarget, ipcore):
# special channel
rhash[targetid] = None
rrefs[targetid] = routertarget
elif isinstance(routertarget, int):
if routertarget in self.node:
rhash[targetid] = routertarget
rrefs[targetid] = self.node[routertarget]["router_ref"]
 
if (router1 is None) and (router2 is None):
# extract from endpoints attribute
if not hasattr(channel_ref, "endpoints"):
raise ValueError("Channel object has not attribute 'endpoints'")
for i in range(2):
if not isinstance(channel_ref.endpoints[i], [router, ipcore]):
raise ValueError("Channel object: attribute 'endpoints'[%d] is not a router or an ipcore" % i)
if isinstance(channel_ref.endpoints[i], router):
if channel_ref.endpoints[i].index in self.node:
rhash[i] = channel_ref.endpoints[i].index
rrefs[i] = channel_ref.endpoints[i]
if isinstance(channel_ref.endpoints[i], ipcore):
rhash[i] = None
rrefs[i] = channel_ref.endpoints[i]
 
if rrefs[0] is None:
raise ValueError("Object not found for argument 'router1'")
if rrefs[1] is None:
raise ValueError("Object not found for argument 'router2'")
 
if None in rhash:
ipcore_idx = rhash.index(None)
channel_ref.index = None
# ipcore channel: adjust the references
rrefs[ipcore_idx].channel_ref = channel_ref
# the other reference must be a router object
rrefs[ipcore_idx - 1].ipcore_ref = rrefs[ipcore_idx]
else:
# inter-routers channel
channel_ref.index = self._get_next_edgeidx()
self.add_edge(rhash[0], rhash[1], channel_ref=channel_ref)
# update common references
channel_ref.graph_ref = self
channel_ref.endpoints = rrefs
return channel_ref
 
def add_ipcore(self, router_ref, name="", **kwargs):
"""
Create an ipcore object and connect it to the router reference argument
 
Arguments
* router_ref: reference to an existing router
* name: optional name for this router. By default has the form of
"IP_<router_index>"
* kwargs: optional parameters to put as object attributes
 
Return: reference to the created ipcore object
 
Notes:
* This function automatically adds a special channel object
(router-to-ipcore) and adjust its relations in all involved objects.
"""
if router_ref not in self.router_list():
raise ValueError("Argument 'router_ref' must be an existing router.")
if name == "":
# channel default name format
name = "IP_%d" % router_ref.index
# fix channel name, based on ipcore name
chname = "CH_%s" % name
newip = ipcore(name=name, router_ref=router_ref, graph_ref=self, **kwargs)
channelnode = channel(index=None, name=chname, graph_ref=self, endpoints=[router_ref, newip])
# fix references
newip.channel_ref = channelnode
router_ref.ipcore_ref = newip
return newip
def add_from_ipcore(self, ipcore_ref, router_ref, channel_ref=None):
"""
Add a ipcore object to NoC model.
 
Arguments
* ipcore_ref: reference to ipcore object
* router_ref: reference to an existing router to connect
* channel_ref: optional channel object that connect the router and
the ipcore. If not used, this function will create a new channel object.
 
Return: the same reference passed in ipcore_ref
 
Notes:
* This function automatically adds a special channel object
(router-to-ipcore) and adjust its relations in all involved objects.
"""
if not isinstance(ipcore_ref, ipcore):
raise ValueError("Argument 'ipcore_ref' is not an ipcore object.")
if router_ref not in self.router_list():
raise ValueError("Argument 'router_ref' must be an existing router.")
 
if channel_ref != None:
if not isinstance(channel_ref, channel):
raise ValueError("Argument 'channel_ref' is not a channel object.")
else:
channel_ref.index = None
channel_ref.graph_ref = self
channel_ref.endpoints = [router_ref, ipcore_ref]
else:
# channel default name format
chname = "CH_IP_%d" % router_ref.index
channel_ref = channel(index=None, name=chname, graph_ref=self, endpoints=[router_ref, ipcore_ref])
# fix references
ipcore_ref.router_ref = router_ref
ipcore_ref.channel_ref = channel_ref
ipcore_ref.graph_ref = self
router_ref.ipcore_ref = ipcore_ref
return ipcore_ref
 
def del_router(self, router_ref):
"""
Remove router_ref from the NoC model
TODO: not implemented
"""
pass
 
def del_channel(self, channel_ref):
"""
Remove channel_ref from the NoC model
TODO: not implemented
"""
pass
def del_ipcore(self, ipcore_ref):
"""
Remove ipcore_ref from the NoC model
TODO: not implemented
"""
pass
 
# list generation functions
def router_list(self):
l = []
for i in self.nodes_iter(data=True):
l.append(i[1]["router_ref"])
return l
 
def ipcore_list(self):
l = []
for i in self.nodes_iter(data=True):
if i[1]["router_ref"].ipcore_ref != None:
l.append(i[1]["router_ref"].ipcore_ref)
return l
 
def channel_list(self):
# this function does not list ipcore channels
l = []
for i in self.edges_iter(data=True):
l.append(i[2]["channel_ref"])
return l
def all_list(self):
l = self.router_list()
l.extend(self.ipcore_list())
l.extend(self.channel_list())
return l
 
# query functions
def get_router_by_address(self, address):
for r in self.router_list():
if r.address == address:
return r
return False
 
# hidden functions
def _add_router_from_node(self, node, name="", router_ref=None, **kwargs):
"""
Create a router object (or use an existing router reference) based on
an existing empty node on graph object.
"""
if router_ref is None:
# index comes from node
if name == "":
name = "R_%d" % node
routernode = router(index=node, name=name, graph_ref=self, **kwargs)
else:
if not isinstance(router_ref, router):
raise ValueError("Argument 'router_ref' is not a router object.")
routernode = router_ref
routernode.index = node
routernode.graph_ref = self
self.node[node]["router_ref"] = routernode
return routernode
 
def _add_channel_from_edge(self, edge, name="", channel_ref=None, **kwargs):
"""
Create a channel object (or use an existing channel reference) based
on an existing edge on graph object.
"""
# inter-routers channels only
rrefs = [self.node[edge[0]]["router_ref"], self.node[edge[1]]["router_ref"]]
chindex = self.edges().index(edge)
if channel_ref is None:
if name == "":
# channel default name format
name = "CH_%s:%s" % (rrefs[0].name, rrefs[1].name)
channelnode = channel(index=chindex, name=name, graph_ref=self, **kwargs)
else:
if not isinstance(channel_ref, channel):
raise ValueError("Argument 'channel_ref' is not a channel object.")
channelnode = channel_ref
channelnode.index = chindex
channelnode.graph_ref = self
channelnode.endpoints = rrefs
self.get_edge_data(edge[0], edge[1])["channel_ref"] = channelnode
 
return channelnode
 
def _get_next_nodeidx(self):
# get the next node index number
# don't use intermediate available indexes
return len(self.nodes())
 
def _get_next_edgeidx(self):
# get the next edge index number
# don't use intermediate available indexes
return len(self.edges())
 
# *******************************
# Generic models for NoC elements
# *******************************
 
class nocobject():
"""
NoC base object
This base class is used to implement common methods for NoC objects.
Don't use directly.
"""
def get_protocol_ref(self):
"""
Get protocol object for this instance
"""
if hasattr(self, "protocol_ref"):
if isinstance(self.protocol_ref, protocol):
return self.protocol_ref
if isinstance(self.graph_ref.protocol_ref, protocol):
return self.graph_ref.protocol_ref
# nothing?
return None
 
class ipcore(nocobject):
"""
IP core base object
This object represents a IP Core object and its properties. This base class
is meant to either be inherited or extended by adding other attributes.
 
Relations with other objects:
* It should be related to one NoC model object (self.graph_ref)
* It should have one reference to a router object (self.router_ref), even if
the ipcore has a direct connection to the NoC.
* It should have one reference to a channel object (self.channel_ref). This
channel exclusively link this ipcore and its router.
 
Attributes:
* name
* router_ref: optional reference to its related router.
* channel_ref: optional reference to its related channel
* graph_ref: optional reference to its graph model
"""
def __init__(self, name, **kwargs):
# Basic properties
self.name = name
# default values
self.router_ref = None
self.channel_ref = None
self.graph_ref = None
for key in kwargs.keys():
setattr(self, key, kwargs[key])
 
class router(nocobject):
"""
Router base object
 
This object represents a router object and its properties. This base class
is meant to either be inherited or extended by adding other attributes.
 
Relations with other objects:
* It should be related to one NoC model object (self.graph_ref)
* It should be one of the node attributes in the graph model
(node["router_ref"])
* It may have one reference to an ipcore object (self.ipcore_ref)
* It has a port list with relations to other routers through channel objects,
and only one relation to its ipcore object through one channel.
(self.ports). Note that this attribute must be updated after changing
the NoC model.
 
Attributes:
* index: index on a noc object. Essential to search for a router object
* name
* ipcore_ref: optional reference to its related ipcore
* graph_ref: optional reference to its graph model
"""
def __init__(self, index, name, **kwargs):
# Basic properties
self.index = index
self.name = name
# default values
self.ipcore_ref = None
self.graph_ref = None
# address can be anything, but let use index by default
# note that address can be overriden with optional arguments in kwargs
self.address = index
for key in kwargs.keys():
setattr(self, key, kwargs[key])
# ports structure
self.ports = {}
# available routes info
self.routes_info = {}
 
# update functions: call them when the underlying NoC structure
# has changed
def update_ports_info(self):
"""
Update the dictionary "ports": information about router neighbors,
the channels that connect them and its references.
Ports dictionary has the following structure:
* key: address of the neighbor router that this port connects.
* value: dictionary with the following keys:
* "peer" (required): reference to the neighbor router
* "channel" (required): reference to the channel that connects this
router and its neighbor router.
* Optional keys can be added to this dictionary.
* Also, the special key "local address" holds the port to
router's ipcore. Its values are:
* "peer" (required): reference to its ipcore
* "channel" (required): reference to the channel that connects this
router and its ipcore.
* Optional keys can be added to this dictionary with the same
meaning as other ports.
"""
# port definitions
localhash = self.address
updated_addr = [self.address]
for neighborhash in self.graph_ref.neighbors(localhash):
neighbor = self.graph_ref.node[neighborhash]["router_ref"]
#check if already defined in ports dictionary
if neighbor.address not in self.ports:
self.ports[neighbor.address] = {}
# update relevant data
self.ports[neighbor.address]["peer"] = neighbor
ch_ref = self.graph_ref.edge[localhash][neighborhash]["channel_ref"]
self.ports[neighbor.address]["channel"] = ch_ref
updated_addr.append(neighbor.address)
 
# special port: ipcore
if self.address not in self.ports:
self.ports[self.address] = {}
self.ports[self.address]["peer"] = self.ipcore_ref
# take channel reference from ipcore. Other channels are related to
# an edge on the graph model. Channels in an ipcore are special because
# they don't have a related edge, just link an ipcore and this router
self.ports[self.address]["channel"] = self.ipcore_ref.channel_ref
 
# clean 'deleted' ports
keys = self.ports.iterkeys()
for deleted in keys:
if deleted not in updated_addr:
del self.ports[deleted]
 
def update_routes_info(self):
"""
Update the dictionary "routes_info": it is a table with information
about how a package, starting from this router, can reach another one.
routes_info dictionary has the following structure:
* keys : the address of all the routers in NoC
* values : an ordered list of dictionaries with
* "next" : address of the next router
* "paths" : list of possible paths for key destination
"""
# this function will calculate a new table!
self.routes_info.clear()
#mynodehash = (self.coord_x, self.coord_y)
mynodehash = self.index
for destrouter in self.graph_ref.router_list():
# discard route to myself
if destrouter == self:
continue
#desthash = (destrouter.coord_x, destrouter.coord_y)
desthash = destrouter.index
 
# entry for destrouter
self.routes_info[destrouter.index] = []
 
# first: take all shortest paths (function not available on NetworkX)
shortest_routes = all_shortest_paths(self.graph_ref, mynodehash, desthash)
# convert nodehashes to router addresses
shortest_r_addr = [map(lambda x : self.graph_ref.node[x]["router_ref"].address, i) for i in shortest_routes]
 
# NOTE about routing tables: need to think about which routes based on
# shortest paths are better in general with other routers, so the links
# are well balanced. A possible problem could be that some links will carry
# more data flow than others.
# A possible workaround lies in the generation of routing tables at
# NoC level, taking account of neighbors tables and others parameters.
 
# extract the next neighbor in each path
for route in shortest_r_addr:
# first element is myself, last element is its destination.
# for this routing table, we only need the next router to
# send the package.
newroute = True
for route_entry in self.routes_info[destrouter.index]:
if route[1] == route_entry["next"]:
# another route which next element was taken account
route_entry["paths"].append(route)
newroute = False
if newroute:
self.routes_info[destrouter.index].append({"next": route[1], "paths": [route]})
# last option: send through another node not in the shortest paths
# NOTE: decide if this is needed or make sense
 
class channel(nocobject):
"""
Channel base object
 
This object represents a channel object and its properties. This base class
is meant to either be inherited or extended by adding other attributes.
 
Relations with other objects:
* It should be related to one NoC model object (self.graph_ref)
* It may be one of the edge attributes in the graph model
(edge["channel_ref"]). In this case, this channel connects two routers
in the NoC model.
* It should have two references to NoC objects (self.endpoints). Two options
exists: two routers references (channel has an edge object) or, one
router and one ipcore (channel don't have any edge object).
 
Attributes:
* name
* index: optional index on a noc object. Must have an index when it has
a related edge in the graph model (and allowing it to be able to do
channel searching). None means it is an ipcore related channel
* graph_ref optional reference to its graph model
* endpoints optional two-item list with references to the connected objects
"""
def __init__(self, name, index=None, **kwargs):
# Basic properties
self.index = index
self.name = name
# Default values
self.graph_ref = None
self.endpoints = [None, None]
for key in kwargs.keys():
setattr(self, key, kwargs[key])
 
def is_ipcore_link(self):
"""
Checks if this channel is a special link for an ipcore.
Return: True if the channel is related to an ipcore
"""
# Search for ipcore in endpoints. Don't check None on self.index.
for ref in self.endpoints:
if isinstance(ref, ipcore):
return True
return False
class protocol(nocobject):
"""
Protocol base object
 
This object represents the protocol that the NoC objects use. This
object has attributes that define the protocol used, mainly it can be
used to generate, encode, decode or interpret packets on the NoC.
This base class can be either be inherited or extended by adding
other attributes.
 
Relations with other objects:
* Each object on the NoC (routers, channels and ipcores) may have
one reference to a protocol object (object.protocol_ref)
* A NoC model may have a protocol object: in this case, all objects in
the model will use this protocol (nocmodel.protocol_ref)
* A protocol object is a generator of packet objects
 
Attributes:
* name
Notes:
* Optional arguments "packet_format" and "packet_order" can be
added at object construction, but will not check its data consistency.
At the moment, we recommend using update_packet_field() method to
fill this data structures.
"""
def __init__(self, name="", **kwargs):
"""
Constructor
Notes:
* Optional arguments will be added as object attributes.
"""
# NOTE: to avoid python version requirements (2.7), implement ordered
# dict with an additional list. When we are sure of using
# Python > 2.7 , change to collections.OrderedDict
self.name = name
self.packet_format = {}
self.packet_order = []
self.packet_class = packet
for key in kwargs.keys():
setattr(self, key, kwargs[key])
def get_protocol_ref(self):
# override to use myself
return self
def update_packet_field(self, name, type, bitlen, description=""):
"""
Add or update a packet field.
Arguments
* name
* type: string that can be "int", "fixed" or "float"
* bitlen: bit length of this field
* description: optional description of this field
Notes:
* Each new field will be added at the end.
"""
if (type != "int") and (type != "fixed") and (type != "float"):
raise ValueError("Argument 'type' must be 'int', 'fixed' or 'float'.")
if name in self.packet_format:
# update field
previdx = self.packet_order.index(name) - 1
if previdx < 0:
# first field
lastbitpos = 0
else:
lastbitpos = self.packet_format[self.packet_order[previdx]][lsb]
nextbitpos = lastbitpos + bitlen
self.packet_format[name]["type"] = type
self.packet_format[name]["position"] = previdx + 1
# check if the packet format needs to adjust the bit positions
if self.packet_format[name]["bitlen"] != bitlen:
self.packet_format[name]["bitlen"] = bitlen
self.packet_format[name]["lsb"] = nextbitpos
self.packet_format[name]["msb"] = lastbitpos
# iterate through the rest of the fields adjusting lsb and msb
for idx in range(previdx+2, len(self.packet_order)):
curname = self.packet_order[idx]
curbitlen = self.packet_format[curname]["bitlen"]
self.packet_format[curname]["lsb"] = nextbitpos + curbitlen
self.packet_format[curname]["msb"] = nextbitpos
nextbitpos += curbitlen
else:
# append
if len(self.packet_format) == 0:
lastbitpos = 0
else:
lastbitpos = self.packet_format[self.packet_order[-1]]["lsb"]
nextbitpos = lastbitpos + bitlen
fieldpos = len(self.packet_order)
self.packet_format[name] = {"type": type, "position": fieldpos, "bitlen": bitlen, "lsb": nextbitpos, "msb": lastbitpos}
self.packet_order.append(name)
def newpacket(self, zerodefault=True, *args, **kwargs):
"""
Return a new packet with all required fields.
Arguments:
* zerodefault: If True, all missing fields will be zeroed by default.
If False, a missing value in arguments will throw an exception.
* args: Nameless arguments will add field values based on packet field
order.
* kwargs: Key-based arguments will add specified field values based in
its keys
Notes:
* kwargs takes precedence over args: i.e. named arguments can overwrite
nameless arguments.
"""
retpacket = self.packet_class(protocol_ref=self)
fieldlist = self.packet_order[:]
# first named arguments
for fkey, fvalue in kwargs.iteritems():
if fkey in fieldlist:
retpacket[fkey] = fvalue
fieldlist.remove(fkey)
# then nameless
for fidx, fvalue in enumerate(args):
fkey = self.packet_order[fidx]
if fkey in fieldlist:
retpacket[fkey] = fvalue
fieldlist.remove(fkey)
# check for empty fields
if len(fieldlist) > 0:
if zerodefault:
for fkey in fieldlist:
retpacket[fkey] = 0
else:
raise ValueError("Missing fields in argument list: %s" % repr(fieldlist))
return retpacket
def register_packet_generator(self, packet_class):
"""
Register a special packet generator class.
Must be a derived class of packet
"""
if not issubclass(packet_class, packet):
raise TypeError("Argument 'packet_class' must derive from 'packet' class.")
self.packet_class = packet_class
 
class packet(dict):
"""
Packet base object
 
This object represents a packet data, related to a protocol object. It
behaves exactly like a Python dictionary, but adds methods to simplify
packet transformations.
 
Relations with other objects:
* It should be generated by a protocol object (and will have a reference
in self.protocol_ref)
 
Attributes:
* protocol_ref: protocol object that created this object.
"""
# the constructor
def __init__(self, *args, **kwargs):
# look for a protocol_ref key
self.protocol_ref = kwargs.pop("protocol_ref", None)
dict.__init__(self, *args, **kwargs)
# *******************************
# Additional functions
# *******************************
 
# Missing function in NetworkX
def all_shortest_paths(G,a,b):
"""
Return a list of all shortest paths in graph G between nodes a and b
This is a function not available in NetworkX (checked at 22-02-2011)
 
Taken from:
http://groups.google.com/group/networkx-discuss/browse_thread/thread/55465e6bb9bae12e
"""
ret = []
pred = nx.predecessor(G,b)
if not pred.has_key(a): # b is not reachable from a
return []
pth = [[a,0]]
pthlength = 1 # instead of array shortening and appending, which are relatively
ind = 0 # slow operations, we will just overwrite array elements at position ind
while ind >= 0:
n,i = pth[ind]
if n == b:
ret.append(map(lambda x:x[0],pth[:ind+1]))
if len(pred[n]) > i:
ind += 1
if ind == pthlength:
pth.append([pred[n][i],0])
pthlength += 1
else:
pth[ind] = [pred[n][i],0]
else:
ind -= 1
if ind >= 0:
pth[ind][1] += 1
return ret
/trunk/nocmodel/noc_guilib.py
0,0 → 1,109
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# Support for graphical representation of NoC objects
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
================
NoCmodel Graphic utilities
================
This module declares functions to draw graphical representations of
NoCmodel objects.
 
"""
 
import matplotlib.pyplot as plt
import networkx as nx
 
from noc_base import *
 
def draw_noc(noc, rectangular=True, nodepos=None):
"""
Draw a representation of a NoC
Arguments:
* noc: Model to draw
* rectangular: If True assumes rectangular layout, with routers
having coord_x and coord_y attributes. If false, expect router's
positions in nodepos argument
* nodepos: Optional dictionary where keys are router's indexes and values
are tuples with x and y positions.
"""
# node positions
if rectangular:
if nodepos == None:
nodepos = {}
for i in noc.router_list():
nodepos[i.index] = (i.coord_x, i.coord_y)
else:
if nodepos == None:
raise ValueError("For non-rectangular layouts this function needs argument 'nodepos'")
 
# some parameters
ip_relpos = (-0.3, 0.3) # relative to router
# node labels
nodelabels = {}
for i in nodepos.iterkeys():
nodelabels[i] = noc.node[i]["router_ref"].name
 
# channel positions
chpos = {}
for i in noc.channel_list():
ep = i.endpoints
ep_1x = nodepos[ep[0].index][0]
ep_1y = nodepos[ep[0].index][1]
ep_2x = nodepos[ep[1].index][0]
ep_2y = nodepos[ep[1].index][1]
thepos = (ep_2x + ((ep_1x - ep_2x)/2.0), ep_2y + ((ep_1y - ep_2y)/2.0))
chpos[i.index] = {"pos": thepos, "text": i.name}
 
# start drawing
nx.draw_networkx_nodes(noc, pos=nodepos, node_size=1000, node_color="blue", alpha=0.5)
nx.draw_networkx_edges(noc, pos=nodepos, edge_color="black", alpha=1.0, width=3.0)
nx.draw_networkx_labels(noc, pos=nodepos, labels=nodelabels, font_color="red")
 
ax=plt.gca()
# channel labels
for i in chpos.itervalues():
ax.text(i["pos"][0], i["pos"][1], i["text"], horizontalalignment="center", verticalalignment="top", bbox=dict(facecolor='red', alpha=0.2))
 
# ipcore with channels and labels
for i in noc.ipcore_list():
thepos = nodepos[i.router_ref.index]
# channel
ax.arrow(thepos[0], thepos[1], ip_relpos[0], ip_relpos[1])
# ip channel label
ax.text(thepos[0]+(ip_relpos[0]/2), thepos[1]+(ip_relpos[1]/2), i.channel_ref.name, horizontalalignment="center", bbox=dict(facecolor='red', alpha=0.2))
# box with ipcore labels
ax.text(thepos[0]+ip_relpos[0], thepos[1]+ip_relpos[1], i.name, horizontalalignment="center", bbox=dict(facecolor='green', alpha=0.2))
 
plt.show()
/trunk/nocmodel/noc_tlm_utils.py
0,0 → 1,61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoC TLM simulation support - Utilities
# This module declares additional helper functions
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
from noc_tlm_base import *
from nocmodel.basicmodels import *
 
# helper functions
def add_tlm_basic_support(instance, **kwargs):
"""
This function will add for every object in noc_instance a noc_tlm object
"""
if isinstance(instance, noc):
# add simulation object
instance.tlmsim = noc_tlm_simulation(instance, **kwargs)
# and add tlm objects recursively
for obj in instance.all_list():
altkwargs = kwargs
altkwargs.pop("log_file", None)
altkwargs.pop("log_level", None)
add_tlm_basic_support(obj, **kwargs)
elif isinstance(instance, ipcore):
instance.tlm = basic_ipcore_tlm(instance, **kwargs)
# don't forget internal channel
instance.channel_ref.tlm = basic_channel_tlm(instance.channel_ref, **kwargs)
elif isinstance(instance, router):
instance.tlm = basic_router_tlm(instance, **kwargs)
elif isinstance(instance, channel):
instance.tlm = basic_channel_tlm(instance, **kwargs)
else:
print "Unsupported object: type %s" % type(instance)
/trunk/nocmodel/basicmodels/basic_channel.py
0,0 → 1,184
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# Basic Channel model
# * TLM model
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
Basic channel TLM model
"""
 
from nocmodel.noc_tlm_base import *
 
# ---------------------------
# Channel TLM model
 
class basic_channel_tlm(noc_tlm_base):
"""
TLM model of a NoC channel. It models a simple FIFO channel with
adjustable delay. This channel will move any kind of data as a whole, but
ideally will move packet objects.
Attributes:
* Channel delay: delay in clock ticks.
Notes:
*This model is completely behavioral
"""
def __init__(self, channel_ref, channel_delay=1):
noc_tlm_base.__init__(self)
if isinstance(channel_ref, channel):
self.channel_ref = channel_ref
self.graph_ref = channel_ref.graph_ref
self.logname = "Channel '%s'" % channel_ref.name
else:
raise TypeError("This class needs a channel object as constructor argument.")
 
self.debug("constructor")
 
# channel parameters
self.channel_delay = channel_delay
 
# list of router endpoints
self.endpoints = self.channel_ref.endpoints
 
# generators
self.generators = []
 
self.has_delay = False
if self.channel_delay > 0:
self.has_delay = True
self.delay_fifo = []
self.delay_fifo_max = 10 # error-catch parameter, avoid fifo excessive growing
self.delay_event = myhdl.Signal(False)
# implement delay generator
@myhdl.instance
def delay_generator():
while True:
while len(self.delay_fifo) > 0:
# extract packet and recorded time
timed_packet = self.delay_fifo.pop(0)
# calculate the exact delay value
next_delay = self.channel_delay - (myhdl.now() - timed_packet[0])
if next_delay <= 0:
self.debug("delay_generator CATCH next_delay is '%d'" % next_delay)
else:
yield myhdl.delay(next_delay)
self.debug("delay_generator sending delayed packet (by %d), timed_packet format %s" % (next_delay, repr(timed_packet)) )
# use send()
retval = self.send(*timed_packet[1:])
# what to do in error case? report and continue
if retval != noc_tlm_errcodes.no_error:
self.error("delay_generator send returns code '%d'?" % retval )
self.delay_event.next = False
yield self.delay_event
self.generators.append(delay_generator)
 
self.debugstate()
 
# channel only relays transactions
# Transaction - related methods
def send(self, src, dest, packet, addattrs=None):
"""
This method will be called by recv (no delay) or by delay_generator
src always is self
"""
# dest MUST be one of the channel endpoints
self.debug("-> send( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
if isinstance(dest, int):
# assume router direction
thedest = self.graph_ref.get_router_by_address(dest)
if thedest == False:
self.error("-> send: dest %s not found" % repr(dest) )
return noc_tlm_errcodes.tlm_badcall_send
elif isinstance(dest, (router, ipcore)):
thedest = dest
else:
self.error("-> send: what is dest '%s'?" % repr(dest) )
return noc_tlm_errcodes.tlm_badcall_send
 
# check dest as one of the channel endpoints
if thedest not in self.endpoints:
self.error("-> send: object %s is NOT one of the channel endpoints [%s,%s]" % (repr(thedest), repr(self.endpoints[0]), repr(self.endpoints[1])) )
return noc_tlm_errcodes.tlm_badcall_send
 
# call recv on the dest object
retval = thedest.tlm.recv(self.channel_ref, dest, packet, addattrs)
 
# Something to do with the retval? Only report it.
self.debug("-> send returns code '%s'" % repr(retval))
return retval
 
def recv(self, src, dest, packet, addattrs=None):
"""
receive a packet from an object. src is the object source and
it MUST be one of the objects in channel endpoints
"""
 
self.debug("-> recv( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
# src can be an address or a noc object.
if isinstance(src, int):
# assume router direction
thesrc = self.graph_ref.get_router_by_address(src)
if thesrc == False:
self.error("-> recv: src %s not found" % repr(src) )
return noc_tlm_errcodes.tlm_badcall_recv
elif isinstance(src, (router, ipcore)):
thesrc = src
else:
self.error("-> recv: what is src '%s'?" % repr(src) )
return noc_tlm_errcodes.tlm_badcall_recv
 
# check src as one of the channel endpoints
if thesrc not in self.endpoints:
self.error("-> recv: object %s is NOT one of the channel endpoints [%s,%s]" % (repr(thesrc), repr(self.endpoints[0]), repr(self.endpoints[1])) )
return noc_tlm_errcodes.tlm_badcall_recv
 
# calculate the other endpoint
end_index = self.endpoints.index(thesrc) - 1
 
if self.has_delay:
# put in delay fifo: store time and call attributes
self.delay_fifo.append([myhdl.now(), self.channel_ref, self.endpoints[end_index], packet, addattrs])
self.debug("-> recv put in delay_fifo (delay %d)" % self.channel_delay)
# catch growing fifo
if len(self.delay_fifo) > self.delay_fifo_max:
self.warning("-> recv: delay_fifo is getting bigger! current size is %d" % len(self.delay_fifo) )
# trigger event
self.delay_event.next = True
retval = noc_tlm_errcodes.no_error
else:
# use send() call directly
router_dest = self.endpoints[end_index]
retval = self.send(self.channel_ref, router_dest, packet, addattrs)
 
self.debug("-> recv returns code '%d'", retval)
return retval
/trunk/nocmodel/basicmodels/__init__.py
0,0 → 1,53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoCmodel basic models for testing
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
================
NoCmodel basic models for testing
================
This package includes:
* Module basic_channel
* Module basic_ipcore
* Module basic_protocol
* Module basic_router
"""
 
# provided modules
from basic_channel import *
from basic_ipcore import *
from basic_protocol import *
from basic_router import *
 
__version__ = "0.1"
/trunk/nocmodel/basicmodels/basic_router.py
0,0 → 1,264
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# Basic Router model
# * TLM model
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
Basic router TLM model
"""
 
from nocmodel.noc_tlm_base import *
 
# ---------------------------
# Router TLM model
 
class basic_router_tlm(noc_tlm_base):
"""
TLM model of a NoC router. This router uses store-and-forward technique,
using the routing information from the router object. This model just
forward the packet, and if the packet is in its router destination, send it
to its ipcore. Each package that the ipcore generates is delivered
automátically.
Attributes:
* router_ref : base reference
* fifo_len: max number of packets to hold in each port
Notes:
* This model is completely behavioral.
* See code comments to better understanding.
"""
def __init__(self, router_ref, fifo_len=4):
noc_tlm_base.__init__(self)
if isinstance(router_ref, router):
self.router_ref = router_ref
self.graph_ref = router_ref.graph_ref
self.logname = "Router '%s'" % router_ref.name
if router_ref.name == "":
self.logname = "Router addr '%s'" % router_ref.address
else:
raise TypeError("This class needs a router object as constructor argument.")
self.debug("constructor")
# generic parameters
self.fifo_len = fifo_len
 
# delay parameters
self.delay_route = 5 # delay for each routing decisition
self.delay_outfromfifo = 2 # delay for extract packet from fifo to output port
self.delay_ipcorebus = 1 # delay for ipcore local bus operations
# router parameters (Assume rectangular coords)
self.myaddress = router_ref.address
self.mynodecoord = (router_ref.coord_x, router_ref.coord_y)
 
# port additions: use a copy of the ports list, and add
# fifo storage and signal events
router_ref.update_ports_info()
self.ports_info = router_ref.ports.copy()
for p in self.ports_info.itervalues():
p["fifo_in"] = []
p["fifo_out"] = []
p["fifo_in_event"] = myhdl.Signal(False)
p["fifo_out_event"] = myhdl.Signal(False)
 
# extract a list of all fifo event signals
self.list_fifo_in_events = [i["fifo_in_event"] for i in self.ports_info.itervalues()]
self.list_fifo_out_events = [i["fifo_out_event"] for i in self.ports_info.itervalues()]
 
# the routing table is generated from the routes_info dict
# key: its destination address
# values: a list of ports where the package should send it. First element
# is the default option, next elements are alternate routes
router_ref.update_routes_info()
self.detailed_routingtable = self.router_ref.routes_info.copy()
self.routingtable = {}
for dest, data in self.detailed_routingtable.iteritems():
self.routingtable[dest] = [x["next"] for x in data]
# add route to myself
self.routingtable[self.myaddress] = [self.myaddress]
# log interesting info
self.info(" router params: fifo_len=%d" % self.fifo_len)
self.info(" router info: addr=%d coord=%s" % (self.myaddress, repr(self.mynodecoord)))
self.info(" router ports: %s" % repr(self.ports_info))
self.info(" router routing table: %s" % repr(self.routingtable))
 
# myhdl generators (concurrent processes)
self.generators = []
# fifo out process
@myhdl.instance
def flush_fifo_out():
while True:
for port, data in self.ports_info.iteritems():
if len(data["fifo_out"]) > 0:
if not data["fifo_out_event"].val:
self.debug("flush_fifo_out CATCH fifo not empty and NO trigger! fifo has %s" % repr(data["fifo_out"]))
self.info("flush_fifo_out event in port %d" % port)
packet = data["fifo_out"].pop(0)
self.debug("flush_fifo_out port %d packet is %s (delay %d)" % (port, repr(packet), self.delay_outfromfifo))
# DELAY model: time to move from fifo to external port in destination object
yield myhdl.delay(self.delay_outfromfifo)
# try to send it
retval = self.send(self.router_ref, data["channel"], packet)
if retval == noc_tlm_errcodes.no_error:
# clean trigger
data["fifo_out_event"].next = False
#continue
else:
self.error("flush_fifo_out FAILED in port %d (code %d)" % (port, retval))
# error management:
#TODO: temporally put back to fifo
self.info("flush_fifo_out packet went back to fifo.")
data["fifo_out"].append(packet)
yield self.list_fifo_out_events
self.debug("flush_fifo_out event hit. list %s" % repr(self.list_fifo_out_events))
 
# routing loop
@myhdl.instance
def routing_loop():
while True:
# routing update: check all fifos
for port, data in self.ports_info.iteritems():
while len(data["fifo_in"]) > 0:
if not data["fifo_in_event"].val:
self.debug("routing_loop CATCH fifo not empty and NO trigger! fifo has %s" % repr(data["fifo_in"]))
self.info("routing_loop fifo_in event in port %d" % port)
# data in fifo
packet = data["fifo_in"].pop(0)
data["fifo_in_event"].next = False
self.debug("routing_loop port %d packet %s to ipcore (delay %d)" % (port, repr(packet), self.delay_route))
# destination needed. extract from routing table
destaddr = packet["dst"]
self.debug("routing_loop port %d routingtable %s (dest %d)" % (port, repr(self.routingtable), destaddr))
nextaddr = self.routingtable[destaddr][0]
self.debug("routing_loop port %d to port %s (dest %d)" % (port, nextaddr, destaddr))
# DELAY model: time spent to make a route decisition
yield myhdl.delay(self.delay_route)
self.ports_info[nextaddr]["fifo_out"].append(packet)
# fifo trigger
if self.ports_info[nextaddr]["fifo_out_event"]:
self.debug("routing_loop CATCH possible miss event because port %d fifo_out_event=True", self.myaddress)
self.ports_info[nextaddr]["fifo_out_event"].next = True
 
yield self.list_fifo_in_events
self.debug("routing_loop event hit. list %s" % repr(self.list_fifo_in_events))
 
# list of all generators
self.generators.extend([flush_fifo_out, routing_loop])
self.debugstate()
 
# Transaction - related methods
def send(self, src, dest, packet, addattrs=None):
"""
This method will be called on a fifo available data event
Notes:
* Ignore src object.
* dest should be a channel object, but also can be a router address or
a router object.
"""
self.debug("-> send( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
if isinstance(dest, int):
# it means dest is a router address
therouter = self.graph_ref.get_router_by_address(dest)
if therouter == False:
self.error("-> send: dest %s not found" % repr(dest) )
return noc_tlm_errcodes.tlm_badcall_send
# extract channel ref from ports_info
thedest = self.ports_info[therouter.address]["channel"]
elif isinstance(dest, router):
# extract channel ref from ports_info
thedest = self.ports_info[dest.address]["channel"]
elif isinstance(dest, channel):
# use it directly
thedest = dest
else:
self.error("-> send: what is dest '%s'?" % repr(dest) )
return noc_tlm_errcodes.tlm_badcall_send
 
# call recv on the dest channel object
retval = thedest.tlm.recv(self.router_ref, thedest, packet, addattrs)
 
# TODO: something to do with the retval?
self.debug("-> send returns code '%s'" % repr(retval))
return retval
def recv(self, src, dest, packet, addattrs=None):
"""
This method will be called by channel objects connected to this router.
Notes:
* The recv method only affect the receiver FIFO sets
* Ignore dest object.
"""
self.debug("-> recv( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
# src can be an address or a noc object.
# convert to addresses
if isinstance(src, int):
thesrc = src
elif isinstance(src, router):
thesrc = src.address
elif isinstance(src, channel):
# get address from the other end. Use the endpoints to calculate
# source router
src_index = src.endpoints.index(self.router_ref) - 1
theend = src.endpoints[src_index]
if isinstance(theend, router):
thesrc = theend.address
elif isinstance(theend, ipcore):
thesrc = theend.router_ref.address
else:
self.error("-> recv: what is endpoint '%s' in channel '%s'?" % (repr(theend), repr(src)) )
return noc_tlm_errcodes.tlm_badcall_recv
else:
self.error("-> recv: what is src '%s'?" % repr(src) )
return noc_tlm_errcodes.tlm_badcall_recv
 
# thesrc becomes the port number
# check if there is enough space on the FIFO
if len(self.ports_info[thesrc]["fifo_in"]) == self.fifo_len:
# full FIFO
self.error("-> recv: full fifo. Try later.")
return noc_tlm_errcodes.full_fifo
# get into fifo
self.ports_info[thesrc]["fifo_in"].append(packet)
# trigger a new routing event
if self.ports_info[thesrc]["fifo_in_event"].val:
self.debug("-> recv: CATCH possible miss event because in port %d fifo_in_event=True", thesrc)
self.ports_info[thesrc]["fifo_in_event"].next = True
 
self.debug("-> recv returns 'noc_tlm_errcodes.no_error'")
return noc_tlm_errcodes.no_error
/trunk/nocmodel/basicmodels/basic_ipcore.py
0,0 → 1,154
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# Basic IPcore model
# * TLM model
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
Basic ipcore TLM model
"""
 
from nocmodel.noc_tlm_base import *
 
# ---------------------------
# Basic IPCore TLM model
 
class basic_ipcore_tlm(noc_tlm_base):
"""
TLM model of a NoC ipcore. Its based on sending and receiving packets
to a custom-based MyHDL generators. This class does not define any
functionality.
Attributes:
* ipcore_ref: reference to ipcore base object
Notes:
* This model is completely behavioral.
* See code comments to better understanding.
"""
def __init__(self, ipcore_ref):
noc_tlm_base.__init__(self)
if isinstance(ipcore_ref, ipcore):
self.ipcore_ref = ipcore_ref
self.graph_ref = ipcore_ref.graph_ref
self.logname = "IPCore '%s'" % ipcore_ref.name
if ipcore_ref.name == "":
self.logname = "IPCore '%s'" % ipcore_ref.router_ref.name
else:
raise TypeError("This class needs a ipcore object as constructor argument.")
self.debug("constructor")
# generic parameters
 
# one-port support: get a reference to the related channel
self.localch = self.ipcore_ref.channel_ref
 
# get protocol reference
self.protocol_ref = self.ipcore_ref.get_protocol_ref()
# bidirectional port: the sender part will write data to the signal
# outgoing_packet. This class provides a generator thar call send()
# method when there is new data.
# for receiving data, recv() method will write
# to the signal incoming_packet, and the ipcore must provide a generator
# sensible to that signal. Use the method register_generator()
self.incoming_packet = myhdl.Signal(packet())
self.outgoing_packet = myhdl.Signal(packet())
@myhdl.instance
def outgoing_process():
while True:
yield self.outgoing_packet
retval = self.send(self.ipcore_ref, self.localch, self.outgoing_packet.val)
self.generators = [outgoing_process]
self.debugstate()
 
def register_generator(self, genfunction, **kwargs):
"""
Register a new generator for this ipcore.
Arguments:
* genfunction: function that returns a MyHDL generator
* kwargs: optional keyed arguments to pass to genfunction call
Notes:
* This method requires that genfunction has the following prototype:
* my_function(din, dout, tlm_ref, <other_arguments>)
* din is a MyHDL Signal of type packet, and is the input signal
to the ipcore. Use this signal to react to input events and
receive input packets.
* dout is a MyHDL Signal of type packet, and is the output
signal to the ipcore. Use this signal to send out packets to
local channel (and then insert into the NoC).
* tlm_ref is a reference to this object. Normal use is to access
logging methods (e.g. tlm_ref.info("message") ).
* <other_arguments> may be defined, this method use kwargs
argument to pass them.
"""
makegen = genfunction(din=self.incoming_packet, dout=self.outgoing_packet, tlm_ref=self, **kwargs)
self.debug("register_generator( %s ) generator is %s args %s" % (repr(genfunction), repr(makegen), repr(kwargs)))
self.generators.append(makegen)
 
# Transaction - related methods
def send(self, src, dest, packet, addattrs=None):
"""
Assumptions:
* Safely ignore src and dest arguments, because this method
is called only by this object generators, therefore it always send
packets to the ipcore related channel.
* In theory src should be self.ipcore_ref, and dest should be
self.localch . This may be checked for errors.
"""
self.debug("-> send( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
 
# call recv on the local channel object
retval = self.localch.tlm.recv(self.ipcore_ref, self.localch, packet, addattrs)
# something to do with the retval? Only report it.
self.debug("-> send returns code '%s'" % repr(retval))
return retval
def recv(self, src, dest, packet, addattrs=None):
"""
Assumptions:
* Safely ignore src and dest arguments, because this method
is called only by local channel object.
* In theory src should be self.localch, and dest should be
self.ipcore_ref . This may be checked for errors.
"""
self.debug("-> recv( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
 
# update signal
self.incoming_packet.next = packet
 
self.debug("-> recv returns 'noc_tlm_errcodes.no_error'")
return noc_tlm_errcodes.no_error
/trunk/nocmodel/basicmodels/basic_protocol.py
0,0 → 1,54
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# Basic Protocol model
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
Basic protocol helper
"""
 
from nocmodel.noc_base import *
 
class basic_protocol(protocol):
"""
Basic protocol class
This class simplify protocol object creation. It defines a simple packet
with the following fields:
|0 7|8 15|16 31|
| src | dst | data |
"""
def __init__(self):
protocol.__init__(self, name="Basic protocol")
self.update_packet_field("src", "int", 8, "Source address")
self.update_packet_field("dst", "int", 8, "Destination address")
self.update_packet_field("data", "int", 16, "Data payload")
/trunk/nocmodel/__init__.py
0,0 → 1,57
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoCmodel package
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
"""
================
NoCmodel package
================
This package includes:
* Module noc_base: NoCmodel Base Objects
* Module noc_guilib: NoCmodel Graphic utilities
* Module noc_tlm_base: NoCmodel TLM simulation support
* Module noc_tlm_utils: helper functions for TLM simulation
* Package basicmodels: basic examples of NoC objects (not imported by default)
"""
 
# required modules
import networkx as nx
 
# provided modules
from noc_base import *
from noc_guilib import *
from noc_tlm_base import *
from noc_tlm_utils import *
 
__version__ = "0.1"
/trunk/nocmodel/noc_tlm_base.py
0,0 → 1,255
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoC TLM simulation support
# This module declares classes for Transaction Level Model simulation
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
# Transaction model:
#
# Objects in a noc model have a "tlm" member
# This "tlm" implements function send() and recv()
 
import networkx as nx
import myhdl
import logging
 
from noc_base import *
 
class noc_tlm_base():
"""
Base class for NoC TLM simulator.
This class add methods to a NoC object, required for the TLM model. Each
derived class must override the methods:
* __init__() : its constructor contains the object TLM model (data
structures, generators, etc).
* send()
* recv()
Other methods are related to simulation configuration and logging support.
"""
def __init__(self):
self.log = logging.getLogger()
self.logname = "BASECLASS"
self.generators = []
 
def get_generators(self):
return self.generators
# TLM main: every object must define this functions
def send(self, src, dest, data, addattrs=None):
"""
SEND method: this method MUST be called only by the local
object who wants to start a transaction.
This function will call the recv method in the right object.
 
Arguments:
* src: source object (or router address) that call this method, i.e. the
object that starts the transaction.
* dest: destination object (or router address) that receive the data in
the transaction. This method will call dest' recv method.
* data: data to be sent. Can be anything, but normally is an object of
type packet.
* addattrs: optional dictionary with additional arguments
Return: Must return a number: 0 for everything OK, != 0 to show an error
relevant to the caller, an exception in case of attribute error
"""
self.debug("-> send( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
return noc_tlm_errcodes.not_implemented
 
def recv(self, src, dest, data, addattrs=None):
"""
RECV method: this method MUST be called only by the send
method of the object who started the transaction.
Arguments:
* src: source object (or router address) that call this method, i.e. the
object that starts the transaction.
* dest: destination object (or router address) that receive the data in
the transaction. This method will call dest' recv method.
* data: data to be sent. Can be anything, but normally is an object of
type packet.
* addattrs: optional dictionary with additional arguments
@return Must return a number: 0 for everything OK, != 0 to show an error
relevant to the caller, an exception in case of attribute error
"""
self.debug("-> recv( %s , %s , %s , %s )" % (repr(src), repr(dest), repr(packet), repr(addattrs)))
return noc_tlm_errcodes.not_implemented
# logging methods (only use 4 levels)
def debug(self, msg, *args, **kwargs):
self.log.debug(msg, extra={"objname": self.logname}, *args, **kwargs)
def info(self, msg, *args, **kwargs):
self.log.info(msg, extra={"objname": self.logname}, *args, **kwargs)
def warning(self, msg, *args, **kwargs):
self.log.warning(msg, extra={"objname": self.logname}, *args, **kwargs)
def error(self, msg, *args, **kwargs):
self.log.error(msg, extra={"objname": self.logname}, *args, **kwargs)
 
# special log
def debugstate(self):
self.debug(" '%s' object state: " % repr(self))
for i in dir(self):
# exclude hidden attributes
if i[0] == "_":
continue
self.debug(" ['%s'] = %s " % (i, repr(getattr(self, i))))
 
class noc_tlm_simulation():
"""
NoC TLM simulator object
This class manages the MyHDL simulation on a NoC object and its logging
support.
Attributes:
* noc_ref: reference to NoC model to simulate
* log_file: optional file to save the simulation log
* log_level: optional logging level for the previous file
* kwargs: optional attributes to add to this object
"""
def __init__(self, noc_ref, log_file=None, log_level=logging.INFO, **kwargs):
if isinstance(noc_ref, noc):
self.noc_ref = noc_ref
else:
raise TypeError("This class needs a noc object as constructor argument.")
# configure logging system
# log errors to console, custom log to log_file if specified
addmsg = ""
self.log = logging.getLogger()
self.log.setLevel(log_level)
console_hdl = logging.StreamHandler()
console_hdl.setLevel(logging.WARNING)
class SimTimeFilter(logging.Filter):
def filter(self, record):
record.myhdltime = myhdl.now()
return True
self.log.addFilter(SimTimeFilter())
self.noc_formatter = logging.Formatter("%(myhdltime)4d:%(levelname)-5s:%(objname)-16s - %(message)s")
console_hdl.setFormatter(self.noc_formatter)
self.log.addHandler(console_hdl)
if log_file != None:
file_hdl = logging.FileHandler(log_file, 'w')
file_hdl.setLevel(log_level)
file_hdl.setFormatter(self.noc_formatter)
self.log.addHandler(file_hdl)
addmsg = "and on file (%s) level %s" % (log_file, logging._levelNames[log_level])
# ready to roll
self.debug("Logging enabled! Running log on console level WARNING %s" % addmsg)
 
def configure_simulation(self, max_time=None, add_generators=[]):
"""
Configure MyHDL simulation.
Arguments:
* max_time: optional max time to simulate. None means simulation
without time limit.
* add_generators: external MyHDL generators to add to the simulation
"""
# myhdl simulation: extract all generators and prepare
# arguments
for obj in self.noc_ref.all_list():
add_generators.extend(obj.tlm.get_generators())
if isinstance(obj, ipcore):
add_generators.extend(obj.channel_ref.tlm.get_generators())
# debug info
#self.debug("configure_simulation: list of generators:")
#for gen in add_generators:
#self.debug("configure_simulation: generator '%s'" % repr(gen))
self.sim_object = myhdl.Simulation(*add_generators)
self.sim_duration = max_time
self.debug("configure_simulation: will run until simulation time '%d'" % max_time)
 
def run(self):
"""
Run MyHDL simulation
"""
self.debug("Start simulation")
self.sim_object.run(self.sim_duration)
self.debug("End simulation")
 
# custom logging methods (only use 4 levels)
def debug(self, msg, *args, **kwargs):
self.log.debug(msg, extra={"objname": "TopNoC"}, *args, **kwargs)
def info(self, msg, *args, **kwargs):
self.log.info(msg, extra={"objname": "TopNoC"}, *args, **kwargs)
def warning(self, msg, *args, **kwargs):
self.log.warning(msg, extra={"objname": "TopNoC"}, *args, **kwargs)
def error(self, msg, *args, **kwargs):
self.log.error(msg, extra={"objname": "TopNoC"}, *args, **kwargs)
 
# special log filter: log individually by object name
def configure_byobject_logging(self, basefilename="", log_level=logging.INFO):
"""
Special log filter: log individually by object name
Arguments:
* basefilename: generated filenames will start with this string
* log_level: optional logging level for previous files
"""
# base filter
class ObjFilter(logging.Filter):
def __init__(self, basename):
self.basename = basename
def filter(self, record):
if record.objname == self.basename:
return True
return False
# need a handler for each object
for obj in self.noc_ref.all_list():
newfilter = ObjFilter(obj.tlm.logname)
newhandler = logging.FileHandler("%s_%s.log" % (basefilename, obj.tlm.logname), "w")
newhandler.setLevel(log_level)
newhandler.addFilter(newfilter)
newhandler.setFormatter(self.noc_formatter)
self.log.addHandler(newhandler)
# Transactions logger
class TransFilter(logging.Filter):
def filter(self, record):
if record.message.find("->") == 0:
return True
return False
newhandler = logging.FileHandler("%s_transactions.log" % basefilename, "w")
newhandler.setLevel(log_level)
newhandler.addFilter(TransFilter())
newhandler.setFormatter(self.noc_formatter)
self.log.addHandler(newhandler)
# TopNoC will not be added to this set
self.debug("Special logging enabled. basefilename=%s level %s" % (basefilename, logging._levelNames[log_level]))
 
class noc_tlm_errcodes():
"""
Common error codes definition
"""
no_error = 0
full_fifo = -1
packet_bad_data = -2
tlm_badcall_recv = -3
tlm_badcall_send = -4
not_implemented = -5
/trunk/LICENSE.txt
0,0 → 1,504
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
 
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
 
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
 
Preamble
 
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
 
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
 
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
 
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
 
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
 
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
 
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
 
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
 
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
 
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
 
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
 
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
 
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
 
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
 
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
 
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
 
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
 
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
 
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
 
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
 
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
 
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
 
a) The modified work must itself be a software library.
 
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
 
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
 
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
 
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
 
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
 
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
 
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
 
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
 
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
 
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
 
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
 
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
 
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
 
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
 
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
 
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
 
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
 
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
 
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
 
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
 
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
 
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
 
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
 
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
 
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
 
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
 
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
 
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
 
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
 
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
 
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
 
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
 
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
 
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
 
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
 
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
 
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
 
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
 
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
 
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
 
NO WARRANTY
 
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
 
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
 
END OF TERMS AND CONDITIONS
 
How to Apply These Terms to Your New Libraries
 
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
 
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
 
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
 
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
Also add information on how to contact you by electronic and paper mail.
 
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
 
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
 
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
 
That's all there is to it!
 
 
/trunk/TODO.txt
0,0 → 1,10
Plan for future releases:
 
nocmodel (0.1)
 
* Write a set of examples using unittest.
* Add more NoC object models
* Start with code generation mechanism
* Add more detailed documentation
-- Oscar Diaz <dargor@opencores.org> Thr, 03 Mar 2011 23:10:25 +0100
/trunk/doc/nocmodel.basicmodels.basic_channel.html
0,0 → 1,79
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nocmodel.basicmodels.basic_channel</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.<a href="nocmodel.basicmodels.html"><font color="#ffffff">basicmodels</font></a>.basic_channel</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/basic_channel.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/basic_channel.py</a></font></td></tr></table>
<p><tt>Basic&nbsp;channel&nbsp;TLM&nbsp;model</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="logging.html">logging</a><br>
</td><td width="25%" valign=top><a href="myhdl.html">myhdl</a><br>
</td><td width="25%" valign=top><a href="networkx.html">networkx</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nocmodel.basicmodels.basic_channel.html#basic_channel_tlm">basic_channel_tlm</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="basic_channel_tlm">class <strong>basic_channel_tlm</strong></a>(<a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>TLM&nbsp;model&nbsp;of&nbsp;a&nbsp;NoC&nbsp;channel.&nbsp;It&nbsp;models&nbsp;a&nbsp;simple&nbsp;FIFO&nbsp;channel&nbsp;with<br>
adjustable&nbsp;delay.&nbsp;This&nbsp;channel&nbsp;will&nbsp;move&nbsp;any&nbsp;kind&nbsp;of&nbsp;data&nbsp;as&nbsp;a&nbsp;whole,&nbsp;but<br>
ideally&nbsp;will&nbsp;move&nbsp;packet&nbsp;objects.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Attributes:<br>
*&nbsp;Channel&nbsp;delay:&nbsp;delay&nbsp;in&nbsp;clock&nbsp;ticks.<br>
&nbsp;<br>
Notes:<br>
*This&nbsp;model&nbsp;is&nbsp;completely&nbsp;behavioral<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="basic_channel_tlm-__init__"><strong>__init__</strong></a>(self, channel_ref, channel_delay<font color="#909090">=1</font>)</dt></dl>
 
<dl><dt><a name="basic_channel_tlm-recv"><strong>recv</strong></a>(self, src, dest, packet, addattrs<font color="#909090">=None</font>)</dt><dd><tt>receive&nbsp;a&nbsp;packet&nbsp;from&nbsp;an&nbsp;object.&nbsp;src&nbsp;is&nbsp;the&nbsp;object&nbsp;source&nbsp;and<br>
it&nbsp;MUST&nbsp;be&nbsp;one&nbsp;of&nbsp;the&nbsp;objects&nbsp;in&nbsp;channel&nbsp;endpoints</tt></dd></dl>
 
<dl><dt><a name="basic_channel_tlm-send"><strong>send</strong></a>(self, src, dest, packet, addattrs<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;method&nbsp;will&nbsp;be&nbsp;called&nbsp;by&nbsp;recv&nbsp;(no&nbsp;delay)&nbsp;or&nbsp;by&nbsp;delay_generator<br>
src&nbsp;always&nbsp;is&nbsp;self</tt></dd></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>:<br>
<dl><dt><a name="basic_channel_tlm-debug"><strong>debug</strong></a>(self, msg, *args, **kwargs)</dt><dd><tt>#&nbsp;logging&nbsp;methods&nbsp;(only&nbsp;use&nbsp;4&nbsp;levels)</tt></dd></dl>
 
<dl><dt><a name="basic_channel_tlm-debugstate"><strong>debugstate</strong></a>(self)</dt><dd><tt>#&nbsp;special&nbsp;log</tt></dd></dl>
 
<dl><dt><a name="basic_channel_tlm-error"><strong>error</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="basic_channel_tlm-get_generators"><strong>get_generators</strong></a>(self)</dt></dl>
 
<dl><dt><a name="basic_channel_tlm-info"><strong>info</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="basic_channel_tlm-warning"><strong>warning</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
</td></tr></table></td></tr></table>
</body></html>
/trunk/doc/nocmodel.html
0,0 → 1,43
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package nocmodel</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>nocmodel</strong></big></big> (version 0.1)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/__init__.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/__init__.py</a></font></td></tr></table>
<p><tt>================<br>
NoCmodel&nbsp;package<br>
================<br>
&nbsp;&nbsp;<br>
This&nbsp;package&nbsp;includes:<br>
&nbsp;&nbsp;<br>
*&nbsp;Module&nbsp;noc_base:&nbsp;NoCmodel&nbsp;Base&nbsp;Objects<br>
*&nbsp;Module&nbsp;noc_guilib:&nbsp;NoCmodel&nbsp;Graphic&nbsp;utilities<br>
*&nbsp;Module&nbsp;noc_tlm_base:&nbsp;NoCmodel&nbsp;TLM&nbsp;simulation&nbsp;support<br>
*&nbsp;Module&nbsp;noc_tlm_utils:&nbsp;helper&nbsp;functions&nbsp;for&nbsp;TLM&nbsp;simulation<br>
*&nbsp;Package&nbsp;basicmodels:&nbsp;basic&nbsp;examples&nbsp;of&nbsp;NoC&nbsp;objects&nbsp;(not&nbsp;imported&nbsp;by&nbsp;default)</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="nocmodel.basicmodels.html"><strong>basicmodels</strong>&nbsp;(package)</a><br>
<a href="nocmodel.noc_base.html">noc_base</a><br>
</td><td width="25%" valign=top><a href="nocmodel.noc_guilib.html">noc_guilib</a><br>
<a href="nocmodel.noc_tlm_base.html">noc_tlm_base</a><br>
</td><td width="25%" valign=top><a href="nocmodel.noc_tlm_utils.html">noc_tlm_utils</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__version__</strong> = '0.1'</td></tr></table>
</body></html>
/trunk/doc/nocmodel.noc_tlm_base.html
0,0 → 1,72
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: class noc_tlm_base</title>
</head><body bgcolor="#f0f0f8">
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><strong>nocmodel.noc_tlm_base</strong> = <a name="nocmodel.noc_tlm_base">class noc_tlm_base</a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Base&nbsp;class&nbsp;for&nbsp;NoC&nbsp;TLM&nbsp;simulator.<br>
&nbsp;<br>
This&nbsp;class&nbsp;add&nbsp;methods&nbsp;to&nbsp;a&nbsp;NoC&nbsp;object,&nbsp;required&nbsp;for&nbsp;the&nbsp;TLM&nbsp;model.&nbsp;Each&nbsp;<br>
derived&nbsp;class&nbsp;must&nbsp;override&nbsp;the&nbsp;methods:<br>
&nbsp;<br>
*&nbsp;<a href="#nocmodel.noc_tlm_base-__init__">__init__</a>()&nbsp;:&nbsp;its&nbsp;constructor&nbsp;contains&nbsp;the&nbsp;object&nbsp;TLM&nbsp;model&nbsp;(data&nbsp;<br>
&nbsp;&nbsp;structures,&nbsp;generators,&nbsp;etc).<br>
*&nbsp;<a href="#nocmodel.noc_tlm_base-send">send</a>()&nbsp;<br>
*&nbsp;<a href="#nocmodel.noc_tlm_base-recv">recv</a>()<br>
&nbsp;<br>
Other&nbsp;methods&nbsp;are&nbsp;related&nbsp;to&nbsp;simulation&nbsp;configuration&nbsp;and&nbsp;logging&nbsp;support.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="noc_tlm_base-__init__"><strong>__init__</strong></a>(self)</dt></dl>
 
<dl><dt><a name="noc_tlm_base-debug"><strong>debug</strong></a>(self, msg, *args, **kwargs)</dt><dd><tt>#&nbsp;logging&nbsp;methods&nbsp;(only&nbsp;use&nbsp;4&nbsp;levels)</tt></dd></dl>
 
<dl><dt><a name="noc_tlm_base-debugstate"><strong>debugstate</strong></a>(self)</dt><dd><tt>#&nbsp;special&nbsp;log</tt></dd></dl>
 
<dl><dt><a name="noc_tlm_base-error"><strong>error</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="noc_tlm_base-get_generators"><strong>get_generators</strong></a>(self)</dt></dl>
 
<dl><dt><a name="noc_tlm_base-info"><strong>info</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="noc_tlm_base-recv"><strong>recv</strong></a>(self, src, dest, data, addattrs<font color="#909090">=None</font>)</dt><dd><tt>RECV&nbsp;method:&nbsp;this&nbsp;method&nbsp;MUST&nbsp;be&nbsp;called&nbsp;only&nbsp;by&nbsp;the&nbsp;send<br>
method&nbsp;of&nbsp;the&nbsp;object&nbsp;who&nbsp;started&nbsp;the&nbsp;transaction.<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;src:&nbsp;source&nbsp;object&nbsp;(or&nbsp;router&nbsp;address)&nbsp;that&nbsp;call&nbsp;this&nbsp;method,&nbsp;i.e.&nbsp;the<br>
&nbsp;&nbsp;object&nbsp;that&nbsp;starts&nbsp;the&nbsp;transaction.<br>
*&nbsp;dest:&nbsp;destination&nbsp;object&nbsp;(or&nbsp;router&nbsp;address)&nbsp;that&nbsp;receive&nbsp;the&nbsp;data&nbsp;in<br>
&nbsp;&nbsp;the&nbsp;transaction.&nbsp;This&nbsp;method&nbsp;will&nbsp;call&nbsp;dest'&nbsp;recv&nbsp;method.<br>
*&nbsp;data:&nbsp;data&nbsp;to&nbsp;be&nbsp;sent.&nbsp;Can&nbsp;be&nbsp;anything,&nbsp;but&nbsp;normally&nbsp;is&nbsp;an&nbsp;object&nbsp;of<br>
&nbsp;&nbsp;type&nbsp;packet.<br>
*&nbsp;addattrs:&nbsp;optional&nbsp;dictionary&nbsp;with&nbsp;additional&nbsp;arguments<br>
&nbsp;<br>
@return&nbsp;Must&nbsp;return&nbsp;a&nbsp;number:&nbsp;0&nbsp;for&nbsp;everything&nbsp;OK,&nbsp;!=&nbsp;0&nbsp;to&nbsp;show&nbsp;an&nbsp;error<br>
&nbsp;&nbsp;&nbsp;&nbsp;relevant&nbsp;to&nbsp;the&nbsp;caller,&nbsp;an&nbsp;exception&nbsp;in&nbsp;case&nbsp;of&nbsp;attribute&nbsp;error</tt></dd></dl>
 
<dl><dt><a name="noc_tlm_base-send"><strong>send</strong></a>(self, src, dest, data, addattrs<font color="#909090">=None</font>)</dt><dd><tt>SEND&nbsp;method:&nbsp;this&nbsp;method&nbsp;MUST&nbsp;be&nbsp;called&nbsp;only&nbsp;by&nbsp;the&nbsp;local<br>
object&nbsp;who&nbsp;wants&nbsp;to&nbsp;start&nbsp;a&nbsp;transaction.<br>
&nbsp;<br>
This&nbsp;function&nbsp;will&nbsp;call&nbsp;the&nbsp;recv&nbsp;method&nbsp;in&nbsp;the&nbsp;right&nbsp;object.<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;src:&nbsp;source&nbsp;object&nbsp;(or&nbsp;router&nbsp;address)&nbsp;that&nbsp;call&nbsp;this&nbsp;method,&nbsp;i.e.&nbsp;the<br>
&nbsp;&nbsp;object&nbsp;that&nbsp;starts&nbsp;the&nbsp;transaction.<br>
*&nbsp;dest:&nbsp;destination&nbsp;object&nbsp;(or&nbsp;router&nbsp;address)&nbsp;that&nbsp;receive&nbsp;the&nbsp;data&nbsp;in<br>
&nbsp;&nbsp;the&nbsp;transaction.&nbsp;This&nbsp;method&nbsp;will&nbsp;call&nbsp;dest'&nbsp;recv&nbsp;method.<br>
*&nbsp;data:&nbsp;data&nbsp;to&nbsp;be&nbsp;sent.&nbsp;Can&nbsp;be&nbsp;anything,&nbsp;but&nbsp;normally&nbsp;is&nbsp;an&nbsp;object&nbsp;of<br>
&nbsp;&nbsp;type&nbsp;packet.<br>
*&nbsp;addattrs:&nbsp;optional&nbsp;dictionary&nbsp;with&nbsp;additional&nbsp;arguments<br>
&nbsp;<br>
Return:&nbsp;Must&nbsp;return&nbsp;a&nbsp;number:&nbsp;0&nbsp;for&nbsp;everything&nbsp;OK,&nbsp;!=&nbsp;0&nbsp;to&nbsp;show&nbsp;an&nbsp;error<br>
&nbsp;&nbsp;&nbsp;&nbsp;relevant&nbsp;to&nbsp;the&nbsp;caller,&nbsp;an&nbsp;exception&nbsp;in&nbsp;case&nbsp;of&nbsp;attribute&nbsp;error</tt></dd></dl>
 
<dl><dt><a name="noc_tlm_base-warning"><strong>warning</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
</td></tr></table>
</body></html>
/trunk/doc/nocmodel.basicmodels.html
0,0 → 1,41
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package nocmodel.basicmodels</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.basicmodels</strong></big></big> (version 0.1)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/__init__.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/__init__.py</a></font></td></tr></table>
<p><tt>================<br>
NoCmodel&nbsp;basic&nbsp;models&nbsp;for&nbsp;testing<br>
================<br>
&nbsp;&nbsp;<br>
This&nbsp;package&nbsp;includes:<br>
&nbsp;&nbsp;<br>
*&nbsp;Module&nbsp;basic_channel<br>
*&nbsp;Module&nbsp;basic_ipcore<br>
*&nbsp;Module&nbsp;basic_protocol<br>
*&nbsp;Module&nbsp;basic_router</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="nocmodel.basicmodels.basic_channel.html">basic_channel</a><br>
</td><td width="25%" valign=top><a href="nocmodel.basicmodels.basic_ipcore.html">basic_ipcore</a><br>
</td><td width="25%" valign=top><a href="nocmodel.basicmodels.basic_protocol.html">basic_protocol</a><br>
</td><td width="25%" valign=top><a href="nocmodel.basicmodels.basic_router.html">basic_router</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__version__</strong> = '0.1'</td></tr></table>
</body></html>
/trunk/doc/nocmodel.basicmodels.basic_router.html
0,0 → 1,90
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nocmodel.basicmodels.basic_router</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.<a href="nocmodel.basicmodels.html"><font color="#ffffff">basicmodels</font></a>.basic_router</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/basic_router.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/basic_router.py</a></font></td></tr></table>
<p><tt>Basic&nbsp;router&nbsp;TLM&nbsp;model</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="logging.html">logging</a><br>
</td><td width="25%" valign=top><a href="myhdl.html">myhdl</a><br>
</td><td width="25%" valign=top><a href="networkx.html">networkx</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nocmodel.basicmodels.basic_router.html#basic_router_tlm">basic_router_tlm</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="basic_router_tlm">class <strong>basic_router_tlm</strong></a>(<a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>TLM&nbsp;model&nbsp;of&nbsp;a&nbsp;NoC&nbsp;router.&nbsp;This&nbsp;router&nbsp;uses&nbsp;store-and-forward&nbsp;technique,&nbsp;<br>
using&nbsp;the&nbsp;routing&nbsp;information&nbsp;from&nbsp;the&nbsp;router&nbsp;object.&nbsp;This&nbsp;model&nbsp;just<br>
forward&nbsp;the&nbsp;packet,&nbsp;and&nbsp;if&nbsp;the&nbsp;packet&nbsp;is&nbsp;in&nbsp;its&nbsp;router&nbsp;destination,&nbsp;send&nbsp;it<br>
to&nbsp;its&nbsp;ipcore.&nbsp;Each&nbsp;package&nbsp;that&nbsp;the&nbsp;ipcore&nbsp;generates&nbsp;is&nbsp;delivered&nbsp;<br>
automátically.<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;router_ref&nbsp;:&nbsp;base&nbsp;reference<br>
*&nbsp;fifo_len:&nbsp;max&nbsp;number&nbsp;of&nbsp;packets&nbsp;to&nbsp;hold&nbsp;in&nbsp;each&nbsp;port<br>
&nbsp;<br>
Notes:<br>
*&nbsp;This&nbsp;model&nbsp;is&nbsp;completely&nbsp;behavioral.<br>
*&nbsp;See&nbsp;code&nbsp;comments&nbsp;to&nbsp;better&nbsp;understanding.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="basic_router_tlm-__init__"><strong>__init__</strong></a>(self, router_ref, fifo_len<font color="#909090">=4</font>)</dt></dl>
 
<dl><dt><a name="basic_router_tlm-recv"><strong>recv</strong></a>(self, src, dest, packet, addattrs<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;method&nbsp;will&nbsp;be&nbsp;called&nbsp;by&nbsp;channel&nbsp;objects&nbsp;connected&nbsp;to&nbsp;this&nbsp;router.<br>
&nbsp;<br>
Notes:<br>
*&nbsp;The&nbsp;recv&nbsp;method&nbsp;only&nbsp;affect&nbsp;the&nbsp;receiver&nbsp;FIFO&nbsp;sets<br>
*&nbsp;Ignore&nbsp;dest&nbsp;object.</tt></dd></dl>
 
<dl><dt><a name="basic_router_tlm-send"><strong>send</strong></a>(self, src, dest, packet, addattrs<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;method&nbsp;will&nbsp;be&nbsp;called&nbsp;on&nbsp;a&nbsp;fifo&nbsp;available&nbsp;data&nbsp;event<br>
&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;Ignore&nbsp;src&nbsp;object.<br>
*&nbsp;dest&nbsp;should&nbsp;be&nbsp;a&nbsp;channel&nbsp;object,&nbsp;but&nbsp;also&nbsp;can&nbsp;be&nbsp;a&nbsp;router&nbsp;address&nbsp;or<br>
&nbsp;&nbsp;a&nbsp;router&nbsp;object.</tt></dd></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>:<br>
<dl><dt><a name="basic_router_tlm-debug"><strong>debug</strong></a>(self, msg, *args, **kwargs)</dt><dd><tt>#&nbsp;logging&nbsp;methods&nbsp;(only&nbsp;use&nbsp;4&nbsp;levels)</tt></dd></dl>
 
<dl><dt><a name="basic_router_tlm-debugstate"><strong>debugstate</strong></a>(self)</dt><dd><tt>#&nbsp;special&nbsp;log</tt></dd></dl>
 
<dl><dt><a name="basic_router_tlm-error"><strong>error</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="basic_router_tlm-get_generators"><strong>get_generators</strong></a>(self)</dt></dl>
 
<dl><dt><a name="basic_router_tlm-info"><strong>info</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="basic_router_tlm-warning"><strong>warning</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
</td></tr></table></td></tr></table>
</body></html>
/trunk/doc/nocmodel.basicmodels.basic_protocol.html
0,0 → 1,63
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: class basic_protocol</title>
</head><body bgcolor="#f0f0f8">
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><strong>nocmodel.basicmodels.basic_protocol</strong> = <a name="nocmodel.basicmodels.basic_protocol">class basic_protocol</a>(<a href="nocmodel.noc_base.html#protocol">nocmodel.noc_base.protocol</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Basic&nbsp;protocol&nbsp;class<br>
&nbsp;<br>
This&nbsp;class&nbsp;simplify&nbsp;protocol&nbsp;object&nbsp;creation.&nbsp;It&nbsp;defines&nbsp;a&nbsp;simple&nbsp;packet<br>
with&nbsp;the&nbsp;following&nbsp;fields:<br>
&nbsp;<br>
|0&nbsp;&nbsp;&nbsp;7|8&nbsp;&nbsp;15|16&nbsp;&nbsp;31|<br>
|&nbsp;src&nbsp;|&nbsp;dst&nbsp;|&nbsp;data&nbsp;|<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nocmodel.basicmodels.basic_protocol.html#basic_protocol">basic_protocol</a></dd>
<dd><a href="nocmodel.noc_base.html#protocol">nocmodel.noc_base.protocol</a></dd>
<dd><a href="nocmodel.noc_base.html#nocobject">nocmodel.noc_base.nocobject</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="basic_protocol-__init__"><strong>__init__</strong></a>(self)</dt></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_base.html#protocol">nocmodel.noc_base.protocol</a>:<br>
<dl><dt><a name="basic_protocol-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt></dl>
 
<dl><dt><a name="basic_protocol-newpacket"><strong>newpacket</strong></a>(self, zerodefault<font color="#909090">=True</font>, *args, **kwargs)</dt><dd><tt>Return&nbsp;a&nbsp;new&nbsp;packet&nbsp;with&nbsp;all&nbsp;required&nbsp;fields.<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;zerodefault:&nbsp;If&nbsp;True,&nbsp;all&nbsp;missing&nbsp;fields&nbsp;will&nbsp;be&nbsp;zeroed&nbsp;by&nbsp;default.<br>
&nbsp;&nbsp;If&nbsp;False,&nbsp;a&nbsp;missing&nbsp;value&nbsp;in&nbsp;arguments&nbsp;will&nbsp;throw&nbsp;an&nbsp;exception.<br>
*&nbsp;args:&nbsp;Nameless&nbsp;arguments&nbsp;will&nbsp;add&nbsp;field&nbsp;values&nbsp;based&nbsp;on&nbsp;packet&nbsp;field<br>
&nbsp;&nbsp;order.<br>
*&nbsp;kwargs:&nbsp;Key-based&nbsp;arguments&nbsp;will&nbsp;add&nbsp;specified&nbsp;field&nbsp;values&nbsp;based&nbsp;in&nbsp;<br>
&nbsp;&nbsp;its&nbsp;keys<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;kwargs&nbsp;takes&nbsp;precedence&nbsp;over&nbsp;args:&nbsp;i.e.&nbsp;named&nbsp;arguments&nbsp;can&nbsp;overwrite<br>
&nbsp;&nbsp;nameless&nbsp;arguments.</tt></dd></dl>
 
<dl><dt><a name="basic_protocol-register_packet_generator"><strong>register_packet_generator</strong></a>(self, packet_class)</dt><dd><tt>Register&nbsp;a&nbsp;special&nbsp;packet&nbsp;generator&nbsp;class.<br>
&nbsp;<br>
Must&nbsp;be&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;packet</tt></dd></dl>
 
<dl><dt><a name="basic_protocol-update_packet_field"><strong>update_packet_field</strong></a>(self, name, type, bitlen, description<font color="#909090">=''</font>)</dt><dd><tt>Add&nbsp;or&nbsp;update&nbsp;a&nbsp;packet&nbsp;field.<br>
&nbsp;<br>
Arguments<br>
*&nbsp;name<br>
*&nbsp;type:&nbsp;string&nbsp;that&nbsp;can&nbsp;be&nbsp;"int",&nbsp;"fixed"&nbsp;or&nbsp;"float"<br>
*&nbsp;bitlen:&nbsp;bit&nbsp;length&nbsp;of&nbsp;this&nbsp;field<br>
*&nbsp;description:&nbsp;optional&nbsp;description&nbsp;of&nbsp;this&nbsp;field<br>
&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;Each&nbsp;new&nbsp;field&nbsp;will&nbsp;be&nbsp;added&nbsp;at&nbsp;the&nbsp;end.</tt></dd></dl>
 
</td></tr></table>
</body></html>
/trunk/doc/nocmodel.basicmodels.basic_ipcore.html
0,0 → 1,107
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nocmodel.basicmodels.basic_ipcore</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.<a href="nocmodel.basicmodels.html"><font color="#ffffff">basicmodels</font></a>.basic_ipcore</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/basic_ipcore.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/basicmodels/basic_ipcore.py</a></font></td></tr></table>
<p><tt>Basic&nbsp;ipcore&nbsp;TLM&nbsp;model</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="logging.html">logging</a><br>
</td><td width="25%" valign=top><a href="myhdl.html">myhdl</a><br>
</td><td width="25%" valign=top><a href="networkx.html">networkx</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nocmodel.basicmodels.basic_ipcore.html#basic_ipcore_tlm">basic_ipcore_tlm</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="basic_ipcore_tlm">class <strong>basic_ipcore_tlm</strong></a>(<a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>TLM&nbsp;model&nbsp;of&nbsp;a&nbsp;NoC&nbsp;ipcore.&nbsp;Its&nbsp;based&nbsp;on&nbsp;sending&nbsp;and&nbsp;receiving&nbsp;packets<br>
to&nbsp;a&nbsp;custom-based&nbsp;MyHDL&nbsp;generators.&nbsp;This&nbsp;class&nbsp;does&nbsp;not&nbsp;define&nbsp;any<br>
functionality.<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;ipcore_ref:&nbsp;reference&nbsp;to&nbsp;ipcore&nbsp;base&nbsp;object<br>
&nbsp;<br>
Notes:<br>
*&nbsp;This&nbsp;model&nbsp;is&nbsp;completely&nbsp;behavioral.<br>
*&nbsp;See&nbsp;code&nbsp;comments&nbsp;to&nbsp;better&nbsp;understanding.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="basic_ipcore_tlm-__init__"><strong>__init__</strong></a>(self, ipcore_ref)</dt></dl>
 
<dl><dt><a name="basic_ipcore_tlm-recv"><strong>recv</strong></a>(self, src, dest, packet, addattrs<font color="#909090">=None</font>)</dt><dd><tt>Assumptions:&nbsp;<br>
*&nbsp;Safely&nbsp;ignore&nbsp;src&nbsp;and&nbsp;dest&nbsp;arguments,&nbsp;because&nbsp;this&nbsp;method&nbsp;<br>
&nbsp;&nbsp;is&nbsp;called&nbsp;only&nbsp;by&nbsp;local&nbsp;channel&nbsp;object.<br>
*&nbsp;In&nbsp;theory&nbsp;src&nbsp;should&nbsp;be&nbsp;self.<strong>localch</strong>,&nbsp;and&nbsp;dest&nbsp;should&nbsp;be&nbsp;<br>
&nbsp;&nbsp;self.<strong>ipcore_ref</strong>&nbsp;.&nbsp;This&nbsp;may&nbsp;be&nbsp;checked&nbsp;for&nbsp;errors.</tt></dd></dl>
 
<dl><dt><a name="basic_ipcore_tlm-register_generator"><strong>register_generator</strong></a>(self, genfunction, **kwargs)</dt><dd><tt>Register&nbsp;a&nbsp;new&nbsp;generator&nbsp;for&nbsp;this&nbsp;ipcore.&nbsp;<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;genfunction:&nbsp;function&nbsp;that&nbsp;returns&nbsp;a&nbsp;MyHDL&nbsp;generator<br>
*&nbsp;kwargs:&nbsp;optional&nbsp;keyed&nbsp;arguments&nbsp;to&nbsp;pass&nbsp;to&nbsp;genfunction&nbsp;call<br>
&nbsp;<br>
Notes:<br>
*&nbsp;This&nbsp;method&nbsp;requires&nbsp;that&nbsp;genfunction&nbsp;has&nbsp;the&nbsp;following&nbsp;prototype:<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;my_function(din,&nbsp;dout,&nbsp;tlm_ref,&nbsp;&lt;other_arguments&gt;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;din&nbsp;is&nbsp;a&nbsp;MyHDL&nbsp;Signal&nbsp;of&nbsp;type&nbsp;packet,&nbsp;and&nbsp;is&nbsp;the&nbsp;input&nbsp;signal&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;the&nbsp;ipcore.&nbsp;Use&nbsp;this&nbsp;signal&nbsp;to&nbsp;react&nbsp;to&nbsp;input&nbsp;events&nbsp;and&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;receive&nbsp;input&nbsp;packets.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;dout&nbsp;is&nbsp;a&nbsp;MyHDL&nbsp;Signal&nbsp;of&nbsp;type&nbsp;packet,&nbsp;and&nbsp;is&nbsp;the&nbsp;output&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signal&nbsp;to&nbsp;the&nbsp;ipcore.&nbsp;Use&nbsp;this&nbsp;signal&nbsp;to&nbsp;send&nbsp;out&nbsp;packets&nbsp;to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local&nbsp;channel&nbsp;(and&nbsp;then&nbsp;insert&nbsp;into&nbsp;the&nbsp;NoC).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;tlm_ref&nbsp;is&nbsp;a&nbsp;reference&nbsp;to&nbsp;this&nbsp;object.&nbsp;Normal&nbsp;use&nbsp;is&nbsp;to&nbsp;access<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logging&nbsp;methods&nbsp;(e.g.&nbsp;tlm_ref.<a href="#basic_ipcore_tlm-info">info</a>("message")&nbsp;).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&lt;other_arguments&gt;&nbsp;may&nbsp;be&nbsp;defined,&nbsp;this&nbsp;method&nbsp;use&nbsp;kwargs&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argument&nbsp;to&nbsp;pass&nbsp;them.</tt></dd></dl>
 
<dl><dt><a name="basic_ipcore_tlm-send"><strong>send</strong></a>(self, src, dest, packet, addattrs<font color="#909090">=None</font>)</dt><dd><tt>Assumptions:&nbsp;<br>
*&nbsp;Safely&nbsp;ignore&nbsp;src&nbsp;and&nbsp;dest&nbsp;arguments,&nbsp;because&nbsp;this&nbsp;method&nbsp;<br>
&nbsp;&nbsp;is&nbsp;called&nbsp;only&nbsp;by&nbsp;this&nbsp;object&nbsp;generators,&nbsp;therefore&nbsp;it&nbsp;always&nbsp;send&nbsp;<br>
&nbsp;&nbsp;packets&nbsp;to&nbsp;the&nbsp;ipcore&nbsp;related&nbsp;channel.<br>
*&nbsp;In&nbsp;theory&nbsp;src&nbsp;should&nbsp;be&nbsp;self.<strong>ipcore_ref</strong>,&nbsp;and&nbsp;dest&nbsp;should&nbsp;be&nbsp;<br>
&nbsp;&nbsp;self.<strong>localch</strong>&nbsp;.&nbsp;This&nbsp;may&nbsp;be&nbsp;checked&nbsp;for&nbsp;errors.</tt></dd></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_tlm_base.html#noc_tlm_base">nocmodel.noc_tlm_base.noc_tlm_base</a>:<br>
<dl><dt><a name="basic_ipcore_tlm-debug"><strong>debug</strong></a>(self, msg, *args, **kwargs)</dt><dd><tt>#&nbsp;logging&nbsp;methods&nbsp;(only&nbsp;use&nbsp;4&nbsp;levels)</tt></dd></dl>
 
<dl><dt><a name="basic_ipcore_tlm-debugstate"><strong>debugstate</strong></a>(self)</dt><dd><tt>#&nbsp;special&nbsp;log</tt></dd></dl>
 
<dl><dt><a name="basic_ipcore_tlm-error"><strong>error</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="basic_ipcore_tlm-get_generators"><strong>get_generators</strong></a>(self)</dt></dl>
 
<dl><dt><a name="basic_ipcore_tlm-info"><strong>info</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
<dl><dt><a name="basic_ipcore_tlm-warning"><strong>warning</strong></a>(self, msg, *args, **kwargs)</dt></dl>
 
</td></tr></table></td></tr></table>
</body></html>
/trunk/doc/nocmodel.noc_base.html
0,0 → 1,1733
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nocmodel.noc_base</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.noc_base</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_base.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_base.py</a></font></td></tr></table>
<p><tt>================<br>
NoCmodel&nbsp;Base&nbsp;Objects<br>
================<br>
&nbsp;&nbsp;<br>
This&nbsp;module&nbsp;declares&nbsp;classes&nbsp;used&nbsp;on&nbsp;a&nbsp;Network-on-chip&nbsp;representation:<br>
&nbsp;&nbsp;<br>
*&nbsp;NoC&nbsp;container&nbsp;class<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Router&nbsp;base&nbsp;class<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Channel&nbsp;base&nbsp;class<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;IPCore&nbsp;base&nbsp;class<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Protocol&nbsp;base&nbsp;class<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Packet&nbsp;class</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="networkx.html">networkx</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#dict">__builtin__.dict</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#packet">packet</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#noc">noc</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#nocobject">nocobject</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#channel">channel</a>
</font></dt><dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#ipcore">ipcore</a>
</font></dt><dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#protocol">protocol</a>
</font></dt><dt><font face="helvetica, arial"><a href="nocmodel.noc_base.html#router">router</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="channel">class <strong>channel</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Channel&nbsp;base&nbsp;object<br>
&nbsp;<br>
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;and&nbsp;its&nbsp;properties.&nbsp;This&nbsp;base&nbsp;class<br>
is&nbsp;meant&nbsp;to&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;other&nbsp;attributes.<br>
&nbsp;<br>
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
*&nbsp;It&nbsp;should&nbsp;be&nbsp;related&nbsp;to&nbsp;one&nbsp;NoC&nbsp;model&nbsp;object&nbsp;(self.<strong>graph_ref</strong>)<br>
*&nbsp;It&nbsp;may&nbsp;be&nbsp;one&nbsp;of&nbsp;the&nbsp;edge&nbsp;attributes&nbsp;in&nbsp;the&nbsp;graph&nbsp;model&nbsp;<br>
&nbsp;&nbsp;(edge["channel_ref"]).&nbsp;In&nbsp;this&nbsp;case,&nbsp;this&nbsp;<a href="#channel">channel</a>&nbsp;connects&nbsp;two&nbsp;routers<br>
&nbsp;&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model.<br>
*&nbsp;It&nbsp;should&nbsp;have&nbsp;two&nbsp;references&nbsp;to&nbsp;NoC&nbsp;objects&nbsp;(self.<strong>endpoints</strong>).&nbsp;Two&nbsp;options<br>
&nbsp;&nbsp;exists:&nbsp;two&nbsp;routers&nbsp;references&nbsp;(<a href="#channel">channel</a>&nbsp;has&nbsp;an&nbsp;edge&nbsp;object)&nbsp;or,&nbsp;one<br>
&nbsp;&nbsp;<a href="#router">router</a>&nbsp;and&nbsp;one&nbsp;<a href="#ipcore">ipcore</a>&nbsp;(<a href="#channel">channel</a>&nbsp;don't&nbsp;have&nbsp;any&nbsp;edge&nbsp;object).<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;name<br>
*&nbsp;index:&nbsp;optional&nbsp;index&nbsp;on&nbsp;a&nbsp;<a href="#noc">noc</a>&nbsp;object.&nbsp;Must&nbsp;have&nbsp;an&nbsp;index&nbsp;when&nbsp;it&nbsp;has<br>
&nbsp;&nbsp;a&nbsp;related&nbsp;edge&nbsp;in&nbsp;the&nbsp;graph&nbsp;model&nbsp;(and&nbsp;allowing&nbsp;it&nbsp;to&nbsp;be&nbsp;able&nbsp;to&nbsp;do<br>
&nbsp;&nbsp;<a href="#channel">channel</a>&nbsp;searching).&nbsp;None&nbsp;means&nbsp;it&nbsp;is&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;related&nbsp;<a href="#channel">channel</a><br>
*&nbsp;graph_ref&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;graph&nbsp;model<br>
*&nbsp;endpoints&nbsp;optional&nbsp;two-item&nbsp;list&nbsp;with&nbsp;references&nbsp;to&nbsp;the&nbsp;connected&nbsp;objects<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="channel-__init__"><strong>__init__</strong></a>(self, name, index<font color="#909090">=None</font>, **kwargs)</dt></dl>
 
<dl><dt><a name="channel-is_ipcore_link"><strong>is_ipcore_link</strong></a>(self)</dt><dd><tt>Checks&nbsp;if&nbsp;this&nbsp;<a href="#channel">channel</a>&nbsp;is&nbsp;a&nbsp;special&nbsp;link&nbsp;for&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>.<br>
&nbsp;<br>
Return:&nbsp;True&nbsp;if&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;is&nbsp;related&nbsp;to&nbsp;an&nbsp;<a href="#ipcore">ipcore</a></tt></dd></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_base.html#nocobject">nocobject</a>:<br>
<dl><dt><a name="channel-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
 
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="ipcore">class <strong>ipcore</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>IP&nbsp;core&nbsp;base&nbsp;object<br>
&nbsp;<br>
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;IP&nbsp;Core&nbsp;object&nbsp;and&nbsp;its&nbsp;properties.&nbsp;This&nbsp;base&nbsp;class<br>
is&nbsp;meant&nbsp;to&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;other&nbsp;attributes.<br>
&nbsp;<br>
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
*&nbsp;It&nbsp;should&nbsp;be&nbsp;related&nbsp;to&nbsp;one&nbsp;NoC&nbsp;model&nbsp;object&nbsp;(self.<strong>graph_ref</strong>)<br>
*&nbsp;It&nbsp;should&nbsp;have&nbsp;one&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;(self.<strong>router_ref</strong>),&nbsp;even&nbsp;if<br>
&nbsp;&nbsp;the&nbsp;<a href="#ipcore">ipcore</a>&nbsp;has&nbsp;a&nbsp;direct&nbsp;connection&nbsp;to&nbsp;the&nbsp;NoC.<br>
*&nbsp;It&nbsp;should&nbsp;have&nbsp;one&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;(self.<strong>channel_ref</strong>).&nbsp;This<br>
&nbsp;&nbsp;<a href="#channel">channel</a>&nbsp;exclusively&nbsp;link&nbsp;this&nbsp;<a href="#ipcore">ipcore</a>&nbsp;and&nbsp;its&nbsp;<a href="#router">router</a>.<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;name<br>
*&nbsp;router_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;related&nbsp;<a href="#router">router</a>.<br>
*&nbsp;channel_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;related&nbsp;<a href="#channel">channel</a><br>
*&nbsp;graph_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;graph&nbsp;model<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="ipcore-__init__"><strong>__init__</strong></a>(self, name, **kwargs)</dt></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_base.html#nocobject">nocobject</a>:<br>
<dl><dt><a name="ipcore-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
 
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="noc">class <strong>noc</strong></a>(<a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Base&nbsp;class&nbsp;for&nbsp;NoC&nbsp;modeling.<br>
Based&nbsp;on&nbsp;a&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a>&nbsp;object&nbsp;that&nbsp;hold&nbsp;the&nbsp;NoC&nbsp;structure<br>
&nbsp;<br>
Arguments<br>
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nocmodel.noc_base.html#noc">noc</a></dd>
<dd><a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="noc-__init__"><strong>__init__</strong></a>(self, **kwargs)</dt><dd><tt>NoCmodel&nbsp;constructor</tt></dd></dl>
 
<dl><dt><a name="noc-add_channel"><strong>add_channel</strong></a>(self, router1, router2, name<font color="#909090">=''</font>, **kwargs)</dt><dd><tt>Create&nbsp;a&nbsp;base&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;to&nbsp;link&nbsp;two&nbsp;objects&nbsp;and&nbsp;add&nbsp;it&nbsp;<br>
to&nbsp;NoC&nbsp;model.<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;router1:&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#router">router</a>,&nbsp;<a href="#router">router</a>&nbsp;index&nbsp;or&nbsp;<a href="#ipcore">ipcore</a><br>
*&nbsp;router2:&nbsp;-idem-<br>
*&nbsp;name:&nbsp;optional&nbsp;argument&nbsp;for&nbsp;<a href="#channel">channel</a>&nbsp;name<br>
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>
&nbsp;<br>
Notes:<br>
*&nbsp;If&nbsp;router1&nbsp;or&nbsp;router2&nbsp;is&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;reference,&nbsp;this&nbsp;method&nbsp;creates<br>
&nbsp;&nbsp;the&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;and&nbsp;update&nbsp;<a href="#ipcore">ipcore</a>&nbsp;references.&nbsp;Additionally,<br>
&nbsp;&nbsp;if&nbsp;both&nbsp;arguments&nbsp;are&nbsp;ipcores,&nbsp;throw&nbsp;an&nbsp;error&nbsp;exception</tt></dd></dl>
 
<dl><dt><a name="noc-add_from_channel"><strong>add_from_channel</strong></a>(self, channel_ref, router1<font color="#909090">=None</font>, router2<font color="#909090">=None</font>)</dt><dd><tt>Add&nbsp;a&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;to&nbsp;NoC&nbsp;model.<br>
&nbsp;<br>
Use&nbsp;this&nbsp;function&nbsp;to&nbsp;add&nbsp;an&nbsp;object&nbsp;based&nbsp;on&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;<br>
base&nbsp;<a href="#channel">channel</a>&nbsp;defined&nbsp;in&nbsp;this&nbsp;module.<br>
&nbsp;<br>
Arguments<br>
*&nbsp;channel_ref:&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;object<br>
*&nbsp;router1:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#router">router</a>,&nbsp;<a href="#router">router</a>&nbsp;index&nbsp;or&nbsp;<a href="#ipcore">ipcore</a><br>
*&nbsp;router2:&nbsp;-idem-<br>
&nbsp;<br>
Return:&nbsp;the&nbsp;same&nbsp;reference&nbsp;passed&nbsp;in&nbsp;channel_ref<br>
&nbsp;<br>
Notes:<br>
*&nbsp;If&nbsp;router1&nbsp;or&nbsp;router2&nbsp;are&nbsp;not&nbsp;used&nbsp;as&nbsp;arguments,&nbsp;will&nbsp;assume&nbsp;that<br>
&nbsp;&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;has&nbsp;defined&nbsp;its&nbsp;attribute&nbsp;"endpoints"&nbsp;with&nbsp;the&nbsp;<br>
&nbsp;&nbsp;objects&nbsp;to&nbsp;connect.&nbsp;If&nbsp;the&nbsp;objects&nbsp;don't&nbsp;exist&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model,<br>
&nbsp;&nbsp;throw&nbsp;an&nbsp;error&nbsp;exception.<br>
&nbsp;<br>
*&nbsp;If&nbsp;router1&nbsp;or&nbsp;router2&nbsp;is&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;reference,&nbsp;this&nbsp;method&nbsp;creates<br>
&nbsp;&nbsp;the&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;and&nbsp;update&nbsp;<a href="#ipcore">ipcore</a>&nbsp;references.&nbsp;Additionally,<br>
&nbsp;&nbsp;if&nbsp;both&nbsp;arguments&nbsp;are&nbsp;ipcores,&nbsp;throw&nbsp;an&nbsp;error&nbsp;exception.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
*&nbsp;This&nbsp;function&nbsp;will&nbsp;change&nbsp;channel_ref.index&nbsp;and&nbsp;channel_ref.graph_ref&nbsp;<br>
&nbsp;&nbsp;attributes&nbsp;when&nbsp;inserted&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model.&nbsp;Also&nbsp;it&nbsp;may&nbsp;change&nbsp;<br>
&nbsp;&nbsp;channel_ref.endpoints&nbsp;with&nbsp;router1&nbsp;and&nbsp;router2&nbsp;references.</tt></dd></dl>
 
<dl><dt><a name="noc-add_from_ipcore"><strong>add_from_ipcore</strong></a>(self, ipcore_ref, router_ref, channel_ref<font color="#909090">=None</font>)</dt><dd><tt>Add&nbsp;a&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;to&nbsp;NoC&nbsp;model.<br>
&nbsp;<br>
Arguments<br>
*&nbsp;ipcore_ref:&nbsp;reference&nbsp;to&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object<br>
*&nbsp;router_ref:&nbsp;reference&nbsp;to&nbsp;an&nbsp;existing&nbsp;<a href="#router">router</a>&nbsp;to&nbsp;connect<br>
*&nbsp;channel_ref:&nbsp;optional&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;that&nbsp;connect&nbsp;the&nbsp;<a href="#router">router</a>&nbsp;and<br>
&nbsp;&nbsp;the&nbsp;<a href="#ipcore">ipcore</a>.&nbsp;If&nbsp;not&nbsp;used,&nbsp;this&nbsp;function&nbsp;will&nbsp;create&nbsp;a&nbsp;new&nbsp;<a href="#channel">channel</a>&nbsp;object.<br>
&nbsp;<br>
Return:&nbsp;the&nbsp;same&nbsp;reference&nbsp;passed&nbsp;in&nbsp;ipcore_ref<br>
&nbsp;<br>
Notes:<br>
*&nbsp;This&nbsp;function&nbsp;automatically&nbsp;adds&nbsp;a&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;<br>
&nbsp;&nbsp;(<a href="#router">router</a>-to-<a href="#ipcore">ipcore</a>)&nbsp;and&nbsp;adjust&nbsp;its&nbsp;relations&nbsp;in&nbsp;all&nbsp;involved&nbsp;objects.</tt></dd></dl>
 
<dl><dt><a name="noc-add_ipcore"><strong>add_ipcore</strong></a>(self, router_ref, name<font color="#909090">=''</font>, **kwargs)</dt><dd><tt>Create&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;and&nbsp;connect&nbsp;it&nbsp;to&nbsp;the&nbsp;<a href="#router">router</a>&nbsp;reference&nbsp;argument<br>
&nbsp;<br>
Arguments<br>
*&nbsp;router_ref:&nbsp;reference&nbsp;to&nbsp;an&nbsp;existing&nbsp;<a href="#router">router</a><br>
*&nbsp;name:&nbsp;optional&nbsp;name&nbsp;for&nbsp;this&nbsp;<a href="#router">router</a>.&nbsp;By&nbsp;default&nbsp;has&nbsp;the&nbsp;form&nbsp;of&nbsp;<br>
&nbsp;&nbsp;"IP_&lt;router_index&gt;"<br>
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>
&nbsp;<br>
Return:&nbsp;reference&nbsp;to&nbsp;the&nbsp;created&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object<br>
&nbsp;<br>
Notes:<br>
*&nbsp;This&nbsp;function&nbsp;automatically&nbsp;adds&nbsp;a&nbsp;special&nbsp;<a href="#channel">channel</a>&nbsp;object&nbsp;<br>
&nbsp;&nbsp;(<a href="#router">router</a>-to-<a href="#ipcore">ipcore</a>)&nbsp;and&nbsp;adjust&nbsp;its&nbsp;relations&nbsp;in&nbsp;all&nbsp;involved&nbsp;objects.</tt></dd></dl>
 
<dl><dt><a name="noc-add_router"><strong>add_router</strong></a>(self, name<font color="#909090">=''</font>, with_ipcore<font color="#909090">=False</font>, **kwargs)</dt><dd><tt>Create&nbsp;a&nbsp;base&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;and&nbsp;add&nbsp;it&nbsp;to&nbsp;NoC&nbsp;model.<br>
&nbsp;<br>
Arguments<br>
*&nbsp;name:&nbsp;optional&nbsp;name&nbsp;for&nbsp;this&nbsp;<a href="#router">router</a>.&nbsp;By&nbsp;default&nbsp;has&nbsp;the&nbsp;form&nbsp;of&nbsp;<br>
&nbsp;&nbsp;"R_&lt;index&gt;"<br>
*&nbsp;with_ipcore:&nbsp;If&nbsp;True,&nbsp;add&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;to&nbsp;the&nbsp;created&nbsp;<a href="#router">router</a>.<br>
*&nbsp;kwargs:&nbsp;optional&nbsp;parameters&nbsp;to&nbsp;put&nbsp;as&nbsp;object&nbsp;attributes<br>
&nbsp;<br>
Return:&nbsp;reference&nbsp;to&nbsp;the&nbsp;created&nbsp;<a href="#router">router</a>&nbsp;object</tt></dd></dl>
 
<dl><dt><a name="noc-add_router_from_object"><strong>add_router_from_object</strong></a>(self, router_ref)</dt><dd><tt>Add&nbsp;an&nbsp;existing&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;to&nbsp;NoC&nbsp;model.<br>
&nbsp;<br>
Use&nbsp;this&nbsp;function&nbsp;to&nbsp;add&nbsp;an&nbsp;object&nbsp;based&nbsp;on&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;<br>
base&nbsp;<a href="#router">router</a>&nbsp;defined&nbsp;in&nbsp;this&nbsp;module.<br>
&nbsp;<br>
Arguments<br>
*&nbsp;router_ref:&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#router">router</a>&nbsp;object<br>
&nbsp;<br>
Return:&nbsp;the&nbsp;same&nbsp;reference&nbsp;passed&nbsp;in&nbsp;router_ref<br>
&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;This&nbsp;function&nbsp;will&nbsp;change&nbsp;router_ref.index&nbsp;and&nbsp;router_ref.graph_ref&nbsp;<br>
&nbsp;&nbsp;attributes&nbsp;when&nbsp;inserted&nbsp;in&nbsp;the&nbsp;NoC&nbsp;model.</tt></dd></dl>
 
<dl><dt><a name="noc-all_list"><strong>all_list</strong></a>(self)</dt></dl>
 
<dl><dt><a name="noc-channel_list"><strong>channel_list</strong></a>(self)</dt></dl>
 
<dl><dt><a name="noc-del_channel"><strong>del_channel</strong></a>(self, channel_ref)</dt><dd><tt>Remove&nbsp;channel_ref&nbsp;from&nbsp;the&nbsp;NoC&nbsp;model<br>
&nbsp;<br>
TODO:&nbsp;not&nbsp;implemented</tt></dd></dl>
 
<dl><dt><a name="noc-del_ipcore"><strong>del_ipcore</strong></a>(self, ipcore_ref)</dt><dd><tt>Remove&nbsp;ipcore_ref&nbsp;from&nbsp;the&nbsp;NoC&nbsp;model<br>
&nbsp;<br>
TODO:&nbsp;not&nbsp;implemented</tt></dd></dl>
 
<dl><dt><a name="noc-del_router"><strong>del_router</strong></a>(self, router_ref)</dt><dd><tt>Remove&nbsp;router_ref&nbsp;from&nbsp;the&nbsp;NoC&nbsp;model<br>
&nbsp;<br>
TODO:&nbsp;not&nbsp;implemented</tt></dd></dl>
 
<dl><dt><a name="noc-get_router_by_address"><strong>get_router_by_address</strong></a>(self, address)</dt><dd><tt>#&nbsp;query&nbsp;functions</tt></dd></dl>
 
<dl><dt><a name="noc-ipcore_list"><strong>ipcore_list</strong></a>(self)</dt></dl>
 
<dl><dt><a name="noc-router_list"><strong>router_list</strong></a>(self)</dt><dd><tt>#&nbsp;list&nbsp;generation&nbsp;functions</tt></dd></dl>
 
<hr>
Methods inherited from <a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>:<br>
<dl><dt><a name="noc-__contains__"><strong>__contains__</strong></a>(self, n)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;n&nbsp;is&nbsp;a&nbsp;node,&nbsp;False&nbsp;otherwise.&nbsp;Use&nbsp;the&nbsp;expression<br>
'n&nbsp;in&nbsp;G'.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;1&nbsp;in&nbsp;G<br>
True</tt></dd></dl>
 
<dl><dt><a name="noc-__getitem__"><strong>__getitem__</strong></a>(self, n)</dt><dd><tt>Return&nbsp;a&nbsp;<a href="__builtin__.html#dict">dict</a>&nbsp;of&nbsp;neighbors&nbsp;of&nbsp;node&nbsp;n.&nbsp;&nbsp;Use&nbsp;the&nbsp;expression&nbsp;'G[n]'.<br>
&nbsp;<br>
Parameters<br>
----------<br>
n&nbsp;:&nbsp;node<br>
&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Returns<br>
-------<br>
adj_dict&nbsp;:&nbsp;dictionary<br>
&nbsp;&nbsp;&nbsp;The&nbsp;adjacency&nbsp;dictionary&nbsp;for&nbsp;nodes&nbsp;connected&nbsp;to&nbsp;n.<br>
&nbsp;<br>
Notes<br>
-----<br>
G[n]&nbsp;is&nbsp;similar&nbsp;to&nbsp;G.<a href="#noc-neighbors">neighbors</a>(n)&nbsp;but&nbsp;the&nbsp;internal&nbsp;data&nbsp;dictionary<br>
is&nbsp;returned&nbsp;instead&nbsp;of&nbsp;a&nbsp;list.<br>
&nbsp;<br>
Assigning&nbsp;G[n]&nbsp;will&nbsp;corrupt&nbsp;the&nbsp;internal&nbsp;graph&nbsp;data&nbsp;structure.<br>
Use&nbsp;G[n]&nbsp;for&nbsp;reading&nbsp;data&nbsp;only.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;G[0]<br>
{1:&nbsp;{}}</tt></dd></dl>
 
<dl><dt><a name="noc-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>Iterate&nbsp;over&nbsp;the&nbsp;nodes.&nbsp;Use&nbsp;the&nbsp;expression&nbsp;'for&nbsp;n&nbsp;in&nbsp;G'.<br>
&nbsp;<br>
Returns<br>
-------<br>
niter&nbsp;:&nbsp;iterator<br>
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;over&nbsp;all&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G:<br>
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n,<br>
0&nbsp;1&nbsp;2&nbsp;3</tt></dd></dl>
 
<dl><dt><a name="noc-__len__"><strong>__len__</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;nodes.&nbsp;Use&nbsp;the&nbsp;expression&nbsp;'len(G)'.<br>
&nbsp;<br>
Returns<br>
-------<br>
nnodes&nbsp;:&nbsp;int<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;len(G)<br>
4</tt></dd></dl>
 
<dl><dt><a name="noc-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;graph&nbsp;name.<br>
&nbsp;<br>
Returns<br>
-------<br>
name&nbsp;:&nbsp;string<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;name&nbsp;of&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.path_graph(4)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&gt;&gt;&gt;&nbsp;print&nbsp;G<br>
path_graph(4)</tt></dd></dl>
 
<dl><dt><a name="noc-add_cycle"><strong>add_cycle</strong></a>(self, nlist, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;cycle.<br>
&nbsp;<br>
Parameters<br>
----------<br>
nlist&nbsp;:&nbsp;list&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;A&nbsp;cycle&nbsp;will&nbsp;be&nbsp;constructed&nbsp;from<br>
&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;nodes&nbsp;(in&nbsp;order)&nbsp;and&nbsp;added&nbsp;to&nbsp;the&nbsp;graph.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Attributes&nbsp;to&nbsp;add&nbsp;to&nbsp;every&nbsp;edge&nbsp;in&nbsp;cycle.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_path,&nbsp;add_star<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G=nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_cycle">add_cycle</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_cycle">add_cycle</a>([10,11,12],weight=7)</tt></dd></dl>
 
<dl><dt><a name="noc-add_edge"><strong>add_edge</strong></a>(self, u, v, attr_dict<font color="#909090">=None</font>, **attr)</dt><dd><tt>Add&nbsp;an&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
&nbsp;<br>
The&nbsp;nodes&nbsp;u&nbsp;and&nbsp;v&nbsp;will&nbsp;be&nbsp;automatically&nbsp;added&nbsp;if&nbsp;they&nbsp;are&nbsp;<br>
not&nbsp;already&nbsp;in&nbsp;the&nbsp;graph.&nbsp;&nbsp;<br>
&nbsp;<br>
Edge&nbsp;attributes&nbsp;can&nbsp;be&nbsp;specified&nbsp;with&nbsp;keywords&nbsp;or&nbsp;by&nbsp;providing<br>
a&nbsp;dictionary&nbsp;with&nbsp;key/value&nbsp;pairs.&nbsp;&nbsp;See&nbsp;examples&nbsp;below.<br>
&nbsp;<br>
Parameters<br>
----------<br>
u,v&nbsp;:&nbsp;nodes<br>
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;can&nbsp;be,&nbsp;for&nbsp;example,&nbsp;strings&nbsp;or&nbsp;numbers.&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;must&nbsp;be&nbsp;hashable&nbsp;(and&nbsp;not&nbsp;None)&nbsp;Python&nbsp;objects.<br>
attr_dict&nbsp;:&nbsp;dictionary,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;of&nbsp;edge&nbsp;attributes.&nbsp;&nbsp;Key/value&nbsp;pairs&nbsp;will<br>
&nbsp;&nbsp;&nbsp;&nbsp;update&nbsp;existing&nbsp;data&nbsp;associated&nbsp;with&nbsp;the&nbsp;edge.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional<br>
&nbsp;&nbsp;&nbsp;&nbsp;Edge&nbsp;data&nbsp;(or&nbsp;labels&nbsp;or&nbsp;objects)&nbsp;can&nbsp;be&nbsp;assigned&nbsp;using<br>
&nbsp;&nbsp;&nbsp;&nbsp;keyword&nbsp;arguments.&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_edges_from&nbsp;:&nbsp;add&nbsp;a&nbsp;collection&nbsp;of&nbsp;edges<br>
&nbsp;<br>
Notes&nbsp;<br>
-----<br>
Adding&nbsp;an&nbsp;edge&nbsp;that&nbsp;already&nbsp;exists&nbsp;updates&nbsp;the&nbsp;edge&nbsp;data.<br>
&nbsp;<br>
NetworkX&nbsp;algorithms&nbsp;designed&nbsp;for&nbsp;weighted&nbsp;graphs&nbsp;use&nbsp;as<br>
the&nbsp;edge&nbsp;weight&nbsp;a&nbsp;numerical&nbsp;value&nbsp;assigned&nbsp;to&nbsp;the&nbsp;keyword<br>
'weight'.<br>
&nbsp;<br>
Examples<br>
--------<br>
The&nbsp;following&nbsp;all&nbsp;add&nbsp;the&nbsp;edge&nbsp;e=(1,2)&nbsp;to&nbsp;graph&nbsp;G:<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(1,2)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,&nbsp;2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;explicit&nbsp;two-node&nbsp;form<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(*e)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;single&nbsp;edge&nbsp;as&nbsp;tuple&nbsp;of&nbsp;two&nbsp;nodes<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>(&nbsp;[(1,2)]&nbsp;)&nbsp;#&nbsp;add&nbsp;edges&nbsp;from&nbsp;iterable&nbsp;container<br>
&nbsp;<br>
Associate&nbsp;data&nbsp;to&nbsp;edges&nbsp;using&nbsp;keywords:<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,&nbsp;2,&nbsp;weight=3)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,&nbsp;3,&nbsp;weight=7,&nbsp;capacity=15,&nbsp;length=342.7)</tt></dd></dl>
 
<dl><dt><a name="noc-add_edges_from"><strong>add_edges_from</strong></a>(self, ebunch, attr_dict<font color="#909090">=None</font>, **attr)</dt><dd><tt>Add&nbsp;all&nbsp;the&nbsp;edges&nbsp;in&nbsp;ebunch.<br>
&nbsp;<br>
Parameters<br>
----------<br>
ebunch&nbsp;:&nbsp;container&nbsp;of&nbsp;edges<br>
&nbsp;&nbsp;&nbsp;&nbsp;Each&nbsp;edge&nbsp;given&nbsp;in&nbsp;the&nbsp;container&nbsp;will&nbsp;be&nbsp;added&nbsp;to&nbsp;the<br>
&nbsp;&nbsp;&nbsp;&nbsp;graph.&nbsp;The&nbsp;edges&nbsp;must&nbsp;be&nbsp;given&nbsp;as&nbsp;as&nbsp;2-tuples&nbsp;(u,v)&nbsp;or<br>
&nbsp;&nbsp;&nbsp;&nbsp;3-tuples&nbsp;(u,v,d)&nbsp;where&nbsp;d&nbsp;is&nbsp;a&nbsp;dictionary&nbsp;containing&nbsp;edge<br>
&nbsp;&nbsp;&nbsp;&nbsp;data.<br>
attr_dict&nbsp;:&nbsp;dictionary,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;of&nbsp;edge&nbsp;attributes.&nbsp;&nbsp;Key/value&nbsp;pairs&nbsp;will<br>
&nbsp;&nbsp;&nbsp;&nbsp;update&nbsp;existing&nbsp;data&nbsp;associated&nbsp;with&nbsp;each&nbsp;edge.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional<br>
&nbsp;&nbsp;&nbsp;&nbsp;Edge&nbsp;data&nbsp;(or&nbsp;labels&nbsp;or&nbsp;objects)&nbsp;can&nbsp;be&nbsp;assigned&nbsp;using<br>
&nbsp;&nbsp;&nbsp;&nbsp;keyword&nbsp;arguments.&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_edge&nbsp;:&nbsp;add&nbsp;a&nbsp;single&nbsp;edge<br>
add_weighted_edges_from&nbsp;:&nbsp;convenient&nbsp;way&nbsp;to&nbsp;add&nbsp;weighted&nbsp;edges<br>
&nbsp;<br>
Notes<br>
-----<br>
Adding&nbsp;the&nbsp;same&nbsp;edge&nbsp;twice&nbsp;has&nbsp;no&nbsp;effect&nbsp;but&nbsp;any&nbsp;edge&nbsp;data<br>
will&nbsp;be&nbsp;updated&nbsp;when&nbsp;each&nbsp;duplicate&nbsp;edge&nbsp;is&nbsp;added.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>([(0,1),(1,2)])&nbsp;#&nbsp;using&nbsp;a&nbsp;list&nbsp;of&nbsp;edge&nbsp;tuples<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;zip(range(0,3),range(1,4))<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>(e)&nbsp;#&nbsp;Add&nbsp;the&nbsp;path&nbsp;graph&nbsp;0-1-2-3<br>
&nbsp;<br>
Associate&nbsp;data&nbsp;to&nbsp;edges<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>([(1,2),(2,3)],&nbsp;weight=3)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edges_from">add_edges_from</a>([(3,4),(1,4)],&nbsp;label='WN2898')</tt></dd></dl>
 
<dl><dt><a name="noc-add_node"><strong>add_node</strong></a>(self, n, attr_dict<font color="#909090">=None</font>, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;single&nbsp;node&nbsp;n&nbsp;and&nbsp;update&nbsp;node&nbsp;attributes.<br>
&nbsp;<br>
Parameters<br>
----------<br>
n&nbsp;:&nbsp;node<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;can&nbsp;be&nbsp;any&nbsp;hashable&nbsp;Python&nbsp;object&nbsp;except&nbsp;None.<br>
attr_dict&nbsp;:&nbsp;dictionary,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Dictionary&nbsp;of&nbsp;node&nbsp;attributes.&nbsp;&nbsp;Key/value&nbsp;pairs&nbsp;will<br>
&nbsp;&nbsp;&nbsp;&nbsp;update&nbsp;existing&nbsp;data&nbsp;associated&nbsp;with&nbsp;the&nbsp;node.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional<br>
&nbsp;&nbsp;&nbsp;&nbsp;Set&nbsp;or&nbsp;change&nbsp;attributes&nbsp;using&nbsp;key=value.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_nodes_from<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>('Hello')<br>
&gt;&gt;&gt;&nbsp;K3&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>([(0,1),(1,2),(2,0)])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(K3)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_nodes">number_of_nodes</a>()<br>
3<br>
&nbsp;<br>
Use&nbsp;keywords&nbsp;set/change&nbsp;node&nbsp;attributes:<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(1,size=10)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(3,weight=0.4,UTM=('13S',382871,3972649))<br>
&nbsp;<br>
Notes<br>
-----<br>
A&nbsp;hashable&nbsp;object&nbsp;is&nbsp;one&nbsp;that&nbsp;can&nbsp;be&nbsp;used&nbsp;as&nbsp;a&nbsp;key&nbsp;in&nbsp;a&nbsp;Python<br>
dictionary.&nbsp;This&nbsp;includes&nbsp;strings,&nbsp;numbers,&nbsp;tuples&nbsp;of&nbsp;strings<br>
and&nbsp;numbers,&nbsp;etc.<br>
&nbsp;<br>
On&nbsp;many&nbsp;platforms&nbsp;hashable&nbsp;items&nbsp;also&nbsp;include&nbsp;mutables&nbsp;such&nbsp;as<br>
NetworkX&nbsp;Graphs,&nbsp;though&nbsp;one&nbsp;should&nbsp;be&nbsp;careful&nbsp;that&nbsp;the&nbsp;hash<br>
doesn't&nbsp;change&nbsp;on&nbsp;mutables.</tt></dd></dl>
 
<dl><dt><a name="noc-add_nodes_from"><strong>add_nodes_from</strong></a>(self, nodes, **attr)</dt><dd><tt>Add&nbsp;multiple&nbsp;nodes.<br>
&nbsp;<br>
Parameters<br>
----------<br>
nodes&nbsp;:&nbsp;iterable&nbsp;container<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes&nbsp;(list,&nbsp;<a href="__builtin__.html#dict">dict</a>,&nbsp;set,&nbsp;etc.).&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;OR<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;(node,&nbsp;attribute&nbsp;<a href="__builtin__.html#dict">dict</a>)&nbsp;tuples.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Node&nbsp;attributes&nbsp;are&nbsp;updated&nbsp;using&nbsp;the&nbsp;attribute&nbsp;<a href="__builtin__.html#dict">dict</a>.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Update&nbsp;attributes&nbsp;for&nbsp;all&nbsp;nodes&nbsp;in&nbsp;nodes.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Node&nbsp;attributes&nbsp;specified&nbsp;in&nbsp;nodes&nbsp;as&nbsp;a&nbsp;tuple<br>
&nbsp;&nbsp;&nbsp;&nbsp;take&nbsp;precedence&nbsp;over&nbsp;attributes&nbsp;specified&nbsp;generally.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_node<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>('Hello')<br>
&gt;&gt;&gt;&nbsp;K3&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>([(0,1),(1,2),(2,0)])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>(K3)<br>
&gt;&gt;&gt;&nbsp;sorted(G.<a href="#noc-nodes">nodes</a>())<br>
[0,&nbsp;1,&nbsp;2,&nbsp;'H',&nbsp;'e',&nbsp;'l',&nbsp;'o']<br>
&nbsp;<br>
Use&nbsp;keywords&nbsp;to&nbsp;update&nbsp;specific&nbsp;node&nbsp;attributes&nbsp;for&nbsp;every&nbsp;node.<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>([1,2],&nbsp;size=10)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>([3,4],&nbsp;weight=0.4)<br>
&nbsp;<br>
Use&nbsp;(node,&nbsp;attrdict)&nbsp;tuples&nbsp;to&nbsp;update&nbsp;attributes&nbsp;for&nbsp;specific<br>
nodes.<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_nodes_from">add_nodes_from</a>([(1,<a href="__builtin__.html#dict">dict</a>(size=11)),&nbsp;(2,{'color':'blue'})])<br>
&gt;&gt;&gt;&nbsp;G.node[1]['size']<br>
11<br>
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()<br>
&gt;&gt;&gt;&nbsp;H.<a href="#noc-add_nodes_from">add_nodes_from</a>(G.<a href="#noc-nodes">nodes</a>(data=True))<br>
&gt;&gt;&gt;&nbsp;H.node[1]['size']<br>
11</tt></dd></dl>
 
<dl><dt><a name="noc-add_path"><strong>add_path</strong></a>(self, nlist, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;path.<br>
&nbsp;<br>
Parameters<br>
----------<br>
nlist&nbsp;:&nbsp;list&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;A&nbsp;path&nbsp;will&nbsp;be&nbsp;constructed&nbsp;from<br>
&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;nodes&nbsp;(in&nbsp;order)&nbsp;and&nbsp;added&nbsp;to&nbsp;the&nbsp;graph.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Attributes&nbsp;to&nbsp;add&nbsp;to&nbsp;every&nbsp;edge&nbsp;in&nbsp;path.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_star,&nbsp;add_cycle<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G=nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([10,11,12],weight=7)</tt></dd></dl>
 
<dl><dt><a name="noc-add_star"><strong>add_star</strong></a>(self, nlist, **attr)</dt><dd><tt>Add&nbsp;a&nbsp;star.<br>
&nbsp;<br>
The&nbsp;first&nbsp;node&nbsp;in&nbsp;nlist&nbsp;is&nbsp;the&nbsp;middle&nbsp;of&nbsp;the&nbsp;star.&nbsp;&nbsp;It&nbsp;is&nbsp;connected&nbsp;<br>
to&nbsp;all&nbsp;other&nbsp;nodes&nbsp;in&nbsp;nlist.<br>
&nbsp;<br>
Parameters<br>
----------<br>
nlist&nbsp;:&nbsp;list&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Attributes&nbsp;to&nbsp;add&nbsp;to&nbsp;every&nbsp;edge&nbsp;in&nbsp;star.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_path,&nbsp;add_cycle<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_star">add_star</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_star">add_star</a>([10,11,12],weight=2)</tt></dd></dl>
 
<dl><dt><a name="noc-add_weighted_edges_from"><strong>add_weighted_edges_from</strong></a>(self, ebunch, **attr)</dt><dd><tt>Add&nbsp;all&nbsp;the&nbsp;edges&nbsp;in&nbsp;ebunch&nbsp;as&nbsp;weighted&nbsp;edges&nbsp;with&nbsp;specified<br>
weights.<br>
&nbsp;<br>
Parameters<br>
----------<br>
ebunch&nbsp;:&nbsp;container&nbsp;of&nbsp;edges<br>
&nbsp;&nbsp;&nbsp;&nbsp;Each&nbsp;edge&nbsp;given&nbsp;in&nbsp;the&nbsp;list&nbsp;or&nbsp;container&nbsp;will&nbsp;be&nbsp;added<br>
&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;the&nbsp;graph.&nbsp;The&nbsp;edges&nbsp;must&nbsp;be&nbsp;given&nbsp;as&nbsp;3-tuples&nbsp;(u,v,w)<br>
&nbsp;&nbsp;&nbsp;&nbsp;where&nbsp;w&nbsp;is&nbsp;a&nbsp;number.<br>
attr&nbsp;:&nbsp;keyword&nbsp;arguments,&nbsp;optional&nbsp;(default=&nbsp;no&nbsp;attributes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Edge&nbsp;attributes&nbsp;to&nbsp;add/update&nbsp;for&nbsp;all&nbsp;edges.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
add_edge&nbsp;:&nbsp;add&nbsp;a&nbsp;single&nbsp;edge<br>
add_edges_from&nbsp;:&nbsp;add&nbsp;multiple&nbsp;edges<br>
&nbsp;<br>
Notes<br>
-----<br>
Adding&nbsp;the&nbsp;same&nbsp;edge&nbsp;twice&nbsp;has&nbsp;no&nbsp;effect&nbsp;but&nbsp;any&nbsp;edge&nbsp;data<br>
will&nbsp;be&nbsp;updated&nbsp;when&nbsp;each&nbsp;duplicate&nbsp;edge&nbsp;is&nbsp;added.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_weighted_edges_from">add_weighted_edges_from</a>([(0,1,3.0),(1,2,7.5)])</tt></dd></dl>
 
<dl><dt><a name="noc-adjacency_iter"><strong>adjacency_iter</strong></a>(self)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;of&nbsp;(node,&nbsp;adjacency&nbsp;<a href="__builtin__.html#dict">dict</a>)&nbsp;tuples&nbsp;for&nbsp;all&nbsp;nodes.<br>
&nbsp;<br>
This&nbsp;is&nbsp;the&nbsp;fastest&nbsp;way&nbsp;to&nbsp;look&nbsp;at&nbsp;every&nbsp;edge.&nbsp;<br>
For&nbsp;directed&nbsp;graphs,&nbsp;only&nbsp;outgoing&nbsp;adjacencies&nbsp;are&nbsp;included.<br>
&nbsp;<br>
Returns<br>
-------<br>
adj_iter&nbsp;:&nbsp;iterator<br>
&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;of&nbsp;(node,&nbsp;adjacency&nbsp;dictionary)&nbsp;for&nbsp;all&nbsp;nodes&nbsp;in<br>
&nbsp;&nbsp;&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
adjacency_list<br>
&nbsp;&nbsp;&nbsp;<br>
Examples&nbsp;&nbsp;&nbsp;<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;[(n,nbrdict)&nbsp;for&nbsp;n,nbrdict&nbsp;in&nbsp;G.<a href="#noc-adjacency_iter">adjacency_iter</a>()]<br>
[(0,&nbsp;{1:&nbsp;{}}),&nbsp;(1,&nbsp;{0:&nbsp;{},&nbsp;2:&nbsp;{}}),&nbsp;(2,&nbsp;{1:&nbsp;{},&nbsp;3:&nbsp;{}}),&nbsp;(3,&nbsp;{2:&nbsp;{}})]</tt></dd></dl>
 
<dl><dt><a name="noc-adjacency_list"><strong>adjacency_list</strong></a>(self)</dt><dd><tt>Return&nbsp;an&nbsp;adjacency&nbsp;list&nbsp;representation&nbsp;of&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
The&nbsp;output&nbsp;adjacency&nbsp;list&nbsp;is&nbsp;in&nbsp;the&nbsp;order&nbsp;of&nbsp;G.<a href="#noc-nodes">nodes</a>().<br>
For&nbsp;directed&nbsp;graphs,&nbsp;only&nbsp;outgoing&nbsp;adjacencies&nbsp;are&nbsp;included.&nbsp;<br>
&nbsp;<br>
Returns<br>
-------<br>
adj_list&nbsp;:&nbsp;lists&nbsp;of&nbsp;lists<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;adjacency&nbsp;structure&nbsp;of&nbsp;the&nbsp;graph&nbsp;as&nbsp;a&nbsp;list&nbsp;of&nbsp;lists.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
adjacency_iter<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-adjacency_list">adjacency_list</a>()&nbsp;#&nbsp;in&nbsp;order&nbsp;given&nbsp;by&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
[[1],&nbsp;[0,&nbsp;2],&nbsp;[1,&nbsp;3],&nbsp;[2]]</tt></dd></dl>
 
<dl><dt><a name="noc-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Remove&nbsp;all&nbsp;nodes&nbsp;and&nbsp;edges&nbsp;from&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
This&nbsp;also&nbsp;removes&nbsp;the&nbsp;name,&nbsp;and&nbsp;all&nbsp;graph,&nbsp;node,&nbsp;and&nbsp;edge&nbsp;attributes.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-clear">clear</a>()<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
[]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
[]</tt></dd></dl>
 
<dl><dt><a name="noc-copy"><strong>copy</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Returns<br>
-------<br>
G&nbsp;:&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
to_directed:&nbsp;return&nbsp;a&nbsp;directed&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Notes<br>
-----<br>
This&nbsp;makes&nbsp;a&nbsp;complete&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph&nbsp;including&nbsp;all&nbsp;of&nbsp;the&nbsp;<br>
node&nbsp;or&nbsp;edge&nbsp;attributes.&nbsp;<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-copy">copy</a>()</tt></dd></dl>
 
<dl><dt><a name="noc-degree"><strong>degree</strong></a>(self, nbunch<font color="#909090">=None</font>, weighted<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;the&nbsp;degree&nbsp;of&nbsp;a&nbsp;node&nbsp;or&nbsp;nodes.<br>
&nbsp;<br>
The&nbsp;node&nbsp;degree&nbsp;is&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;adjacent&nbsp;to&nbsp;that&nbsp;node.&nbsp;<br>
&nbsp;<br>
Parameters<br>
----------<br>
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=all&nbsp;nodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
weighted&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;the&nbsp;sum&nbsp;of&nbsp;edge&nbsp;weights&nbsp;adjacent&nbsp;to&nbsp;the&nbsp;node.&nbsp;&nbsp;<br>
&nbsp;<br>
Returns<br>
-------<br>
nd&nbsp;:&nbsp;dictionary,&nbsp;or&nbsp;number<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;dictionary&nbsp;with&nbsp;nodes&nbsp;as&nbsp;keys&nbsp;and&nbsp;degree&nbsp;as&nbsp;values&nbsp;or<br>
&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;number&nbsp;if&nbsp;a&nbsp;single&nbsp;node&nbsp;is&nbsp;specified.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-degree">degree</a>(0)<br>
1<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-degree">degree</a>([0,1])<br>
{0:&nbsp;1,&nbsp;1:&nbsp;2}<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-degree">degree</a>([0,1]).values()<br>
[1,&nbsp;2]</tt></dd></dl>
 
<dl><dt><a name="noc-degree_iter"><strong>degree_iter</strong></a>(self, nbunch<font color="#909090">=None</font>, weighted<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;for&nbsp;(node,&nbsp;degree).&nbsp;<br>
&nbsp;<br>
The&nbsp;node&nbsp;degree&nbsp;is&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;adjacent&nbsp;to&nbsp;the&nbsp;node.&nbsp;<br>
&nbsp;<br>
Parameters<br>
----------<br>
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=all&nbsp;nodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
weighted&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;the&nbsp;sum&nbsp;of&nbsp;edge&nbsp;weights&nbsp;adjacent&nbsp;to&nbsp;the&nbsp;node.&nbsp;&nbsp;<br>
&nbsp;<br>
Returns<br>
-------<br>
nd_iter&nbsp;:&nbsp;an&nbsp;iterator&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;iterator&nbsp;returns&nbsp;two-tuples&nbsp;of&nbsp;(node,&nbsp;degree).<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
degree<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-degree_iter">degree_iter</a>(0))&nbsp;#&nbsp;node&nbsp;0&nbsp;with&nbsp;degree&nbsp;1<br>
[(0,&nbsp;1)]<br>
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-degree_iter">degree_iter</a>([0,1]))<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;2)]</tt></dd></dl>
 
<dl><dt><a name="noc-edges"><strong>edges</strong></a>(self, nbunch<font color="#909090">=None</font>, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;edges.<br>
&nbsp;<br>
Edges&nbsp;are&nbsp;returned&nbsp;as&nbsp;tuples&nbsp;with&nbsp;optional&nbsp;data&nbsp;<br>
in&nbsp;the&nbsp;order&nbsp;(node,&nbsp;neighbor,&nbsp;data).<br>
&nbsp;<br>
Parameters<br>
----------<br>
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=&nbsp;all&nbsp;nodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.<br>
data&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Return&nbsp;two&nbsp;tuples&nbsp;(u,v)&nbsp;(False)&nbsp;or&nbsp;three-tuples&nbsp;(u,v,data)&nbsp;(True).<br>
&nbsp;<br>
Returns<br>
--------<br>
edge_list:&nbsp;list&nbsp;of&nbsp;edge&nbsp;tuples<br>
&nbsp;&nbsp;&nbsp;&nbsp;Edges&nbsp;that&nbsp;are&nbsp;adjacent&nbsp;to&nbsp;any&nbsp;node&nbsp;in&nbsp;nbunch,&nbsp;or&nbsp;a&nbsp;list<br>
&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;all&nbsp;edges&nbsp;if&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;specified.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
edges_iter&nbsp;:&nbsp;return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;edges<br>
&nbsp;<br>
Notes<br>
-----<br>
Nodes&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;not&nbsp;in&nbsp;the&nbsp;graph&nbsp;will&nbsp;be&nbsp;(quietly)&nbsp;ignored.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;2),&nbsp;(2,&nbsp;3)]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>(data=True)&nbsp;#&nbsp;default&nbsp;edge&nbsp;data&nbsp;is&nbsp;{}&nbsp;(empty&nbsp;dictionary)<br>
[(0,&nbsp;1,&nbsp;{}),&nbsp;(1,&nbsp;2,&nbsp;{}),&nbsp;(2,&nbsp;3,&nbsp;{})]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>([0,3])<br>
[(0,&nbsp;1),&nbsp;(3,&nbsp;2)]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>(0)<br>
[(0,&nbsp;1)]</tt></dd></dl>
 
<dl><dt><a name="noc-edges_iter"><strong>edges_iter</strong></a>(self, nbunch<font color="#909090">=None</font>, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;edges.<br>
&nbsp;<br>
Edges&nbsp;are&nbsp;returned&nbsp;as&nbsp;tuples&nbsp;with&nbsp;optional&nbsp;data&nbsp;<br>
in&nbsp;the&nbsp;order&nbsp;(node,&nbsp;neighbor,&nbsp;data).<br>
&nbsp;<br>
Parameters<br>
----------<br>
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=&nbsp;all&nbsp;nodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.<br>
data&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;True,&nbsp;return&nbsp;edge&nbsp;attribute&nbsp;<a href="__builtin__.html#dict">dict</a>&nbsp;in&nbsp;3-tuple&nbsp;(u,v,data).<br>
&nbsp;<br>
Returns<br>
-------<br>
edge_iter&nbsp;:&nbsp;iterator<br>
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;of&nbsp;(u,v)&nbsp;or&nbsp;(u,v,d)&nbsp;tuples&nbsp;of&nbsp;edges.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
edges&nbsp;:&nbsp;return&nbsp;a&nbsp;list&nbsp;of&nbsp;edges<br>
&nbsp;<br>
Notes<br>
-----<br>
Nodes&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;not&nbsp;in&nbsp;the&nbsp;graph&nbsp;will&nbsp;be&nbsp;(quietly)&nbsp;ignored.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;[e&nbsp;for&nbsp;e&nbsp;in&nbsp;G.<a href="#noc-edges_iter">edges_iter</a>()]<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;2),&nbsp;(2,&nbsp;3)]<br>
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-edges_iter">edges_iter</a>(data=True))&nbsp;#&nbsp;default&nbsp;data&nbsp;is&nbsp;{}&nbsp;(empty&nbsp;<a href="__builtin__.html#dict">dict</a>)<br>
[(0,&nbsp;1,&nbsp;{}),&nbsp;(1,&nbsp;2,&nbsp;{}),&nbsp;(2,&nbsp;3,&nbsp;{})]<br>
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-edges_iter">edges_iter</a>([0,3]))<br>
[(0,&nbsp;1),&nbsp;(3,&nbsp;2)]<br>
&gt;&gt;&gt;&nbsp;list(G.<a href="#noc-edges_iter">edges_iter</a>(0))<br>
[(0,&nbsp;1)]</tt></dd></dl>
 
<dl><dt><a name="noc-get_edge_data"><strong>get_edge_data</strong></a>(self, u, v, default<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;the&nbsp;attribute&nbsp;dictionary&nbsp;associated&nbsp;with&nbsp;edge&nbsp;(u,v).<br>
&nbsp;<br>
Parameters<br>
----------<br>
u,v&nbsp;:&nbsp;nodes<br>
default:&nbsp;&nbsp;any&nbsp;Python&nbsp;object&nbsp;(default=None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;to&nbsp;return&nbsp;if&nbsp;the&nbsp;edge&nbsp;(u,v)&nbsp;is&nbsp;not&nbsp;found.&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Returns<br>
-------<br>
edge_dict&nbsp;:&nbsp;dictionary<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;edge&nbsp;attribute&nbsp;dictionary.<br>
&nbsp;<br>
Notes<br>
-----<br>
It&nbsp;is&nbsp;faster&nbsp;to&nbsp;use&nbsp;G[u][v].<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G[0][1]<br>
{}<br>
&nbsp;<br>
Warning:&nbsp;Assigning&nbsp;G[u][v]&nbsp;corrupts&nbsp;the&nbsp;graph&nbsp;data&nbsp;structure.<br>
But&nbsp;it&nbsp;is&nbsp;safe&nbsp;to&nbsp;assign&nbsp;attributes&nbsp;to&nbsp;that&nbsp;dictionary,<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G[0][1]['weight']&nbsp;=&nbsp;7<br>
&gt;&gt;&gt;&nbsp;G[0][1]['weight']<br>
7<br>
&gt;&gt;&gt;&nbsp;G[1][0]['weight']<br>
7<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-get_edge_data">get_edge_data</a>(0,1)&nbsp;#&nbsp;default&nbsp;edge&nbsp;data&nbsp;is&nbsp;{}<br>
{}<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-get_edge_data">get_edge_data</a>(*e)&nbsp;#&nbsp;tuple&nbsp;form<br>
{}<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-get_edge_data">get_edge_data</a>('a','b',default=0)&nbsp;#&nbsp;edge&nbsp;not&nbsp;in&nbsp;graph,&nbsp;return&nbsp;0<br>
0</tt></dd></dl>
 
<dl><dt><a name="noc-has_edge"><strong>has_edge</strong></a>(self, u, v)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;the&nbsp;edge&nbsp;(u,v)&nbsp;is&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Parameters<br>
----------<br>
u,v&nbsp;:&nbsp;nodes<br>
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;can&nbsp;be,&nbsp;for&nbsp;example,&nbsp;strings&nbsp;or&nbsp;numbers.&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Nodes&nbsp;must&nbsp;be&nbsp;hashable&nbsp;(and&nbsp;not&nbsp;None)&nbsp;Python&nbsp;objects.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Returns<br>
-------<br>
edge_ind&nbsp;:&nbsp;bool<br>
&nbsp;&nbsp;&nbsp;&nbsp;True&nbsp;if&nbsp;edge&nbsp;is&nbsp;in&nbsp;the&nbsp;graph,&nbsp;False&nbsp;otherwise.<br>
&nbsp;<br>
Examples<br>
--------<br>
Can&nbsp;be&nbsp;called&nbsp;either&nbsp;using&nbsp;two&nbsp;nodes&nbsp;u,v&nbsp;or&nbsp;edge&nbsp;tuple&nbsp;(u,v)<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(0,1)&nbsp;&nbsp;#&nbsp;using&nbsp;two&nbsp;nodes<br>
True<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(*e)&nbsp;&nbsp;#&nbsp;&nbsp;e&nbsp;is&nbsp;a&nbsp;2-tuple&nbsp;(u,v)<br>
True<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1,{'weight':7})<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(*e[:2])&nbsp;&nbsp;#&nbsp;e&nbsp;is&nbsp;a&nbsp;3-tuple&nbsp;(u,v,data_dictionary)<br>
True<br>
&nbsp;<br>
The&nbsp;following&nbsp;syntax&nbsp;are&nbsp;all&nbsp;equivalent:&nbsp;<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-has_edge">has_edge</a>(0,1)<br>
True<br>
&gt;&gt;&gt;&nbsp;1&nbsp;in&nbsp;G[0]&nbsp;&nbsp;#&nbsp;though&nbsp;this&nbsp;gives&nbsp;KeyError&nbsp;if&nbsp;0&nbsp;not&nbsp;in&nbsp;G<br>
True</tt></dd></dl>
 
<dl><dt><a name="noc-has_node"><strong>has_node</strong></a>(self, n)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;the&nbsp;graph&nbsp;contains&nbsp;the&nbsp;node&nbsp;n.<br>
&nbsp;<br>
Parameters<br>
----------<br>
n&nbsp;:&nbsp;node<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;G.<a href="#noc-has_node">has_node</a>(0)<br>
True<br>
&nbsp;<br>
It&nbsp;is&nbsp;more&nbsp;readable&nbsp;and&nbsp;simpler&nbsp;to&nbsp;use<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;0&nbsp;in&nbsp;G<br>
True</tt></dd></dl>
 
<dl><dt><a name="noc-is_directed"><strong>is_directed</strong></a>(self)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;graph&nbsp;is&nbsp;directed,&nbsp;False&nbsp;otherwise.</tt></dd></dl>
 
<dl><dt><a name="noc-is_multigraph"><strong>is_multigraph</strong></a>(self)</dt><dd><tt>Return&nbsp;True&nbsp;if&nbsp;graph&nbsp;is&nbsp;a&nbsp;multigraph,&nbsp;False&nbsp;otherwise.</tt></dd></dl>
 
<dl><dt><a name="noc-nbunch_iter"><strong>nbunch_iter</strong></a>(self, nbunch<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;of&nbsp;nodes&nbsp;contained&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;<br>
also&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
The&nbsp;nodes&nbsp;in&nbsp;nbunch&nbsp;are&nbsp;checked&nbsp;for&nbsp;membership&nbsp;in&nbsp;the&nbsp;graph<br>
and&nbsp;if&nbsp;not&nbsp;are&nbsp;silently&nbsp;ignored.<br>
&nbsp;<br>
Parameters<br>
----------<br>
nbunch&nbsp;:&nbsp;iterable&nbsp;container,&nbsp;optional&nbsp;(default=all&nbsp;nodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes.&nbsp;&nbsp;The&nbsp;container&nbsp;will&nbsp;be&nbsp;iterated<br>
&nbsp;&nbsp;&nbsp;&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
Returns<br>
-------<br>
niter&nbsp;:&nbsp;iterator<br>
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;over&nbsp;nodes&nbsp;in&nbsp;nbunch&nbsp;that&nbsp;are&nbsp;also&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;nbunch&nbsp;is&nbsp;None,&nbsp;iterate&nbsp;over&nbsp;all&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Raises<br>
------<br>
NetworkXError<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;a&nbsp;node&nbsp;or&nbsp;or&nbsp;sequence&nbsp;of&nbsp;nodes.<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;a&nbsp;node&nbsp;in&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;hashable.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
<a href="networkx.classes.graph.html#Graph">Graph</a>.__iter__<br>
&nbsp;<br>
Notes&nbsp;<br>
-----<br>
When&nbsp;nbunch&nbsp;is&nbsp;an&nbsp;iterator,&nbsp;the&nbsp;returned&nbsp;iterator&nbsp;yields&nbsp;values&nbsp;<br>
directly&nbsp;from&nbsp;nbunch,&nbsp;becoming&nbsp;exhausted&nbsp;when&nbsp;nbunch&nbsp;is&nbsp;exhausted.<br>
&nbsp;<br>
To&nbsp;test&nbsp;whether&nbsp;nbunch&nbsp;is&nbsp;a&nbsp;single&nbsp;node,&nbsp;one&nbsp;can&nbsp;use&nbsp;<br>
"if&nbsp;nbunch&nbsp;in&nbsp;self:",&nbsp;even&nbsp;after&nbsp;processing&nbsp;with&nbsp;this&nbsp;routine.<br>
&nbsp;<br>
If&nbsp;nbunch&nbsp;is&nbsp;not&nbsp;a&nbsp;node&nbsp;or&nbsp;a&nbsp;(possibly&nbsp;empty)&nbsp;sequence/iterator<br>
or&nbsp;None,&nbsp;a&nbsp;NetworkXError&nbsp;is&nbsp;raised.&nbsp;&nbsp;Also,&nbsp;if&nbsp;any&nbsp;object&nbsp;in<br>
nbunch&nbsp;is&nbsp;not&nbsp;hashable,&nbsp;a&nbsp;NetworkXError&nbsp;is&nbsp;raised.</tt></dd></dl>
 
<dl><dt><a name="noc-neighbors"><strong>neighbors</strong></a>(self, n)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;nodes&nbsp;connected&nbsp;to&nbsp;the&nbsp;node&nbsp;n.<br>
&nbsp;<br>
Parameters<br>
----------<br>
n&nbsp;:&nbsp;node<br>
&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;in&nbsp;the&nbsp;graph<br>
&nbsp;<br>
Returns<br>
-------<br>
nlist&nbsp;:&nbsp;list<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes&nbsp;that&nbsp;are&nbsp;adjacent&nbsp;to&nbsp;n.<br>
&nbsp;<br>
Raises<br>
------<br>
NetworkXError<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;the&nbsp;node&nbsp;n&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph.&nbsp;&nbsp;<br>
&nbsp;<br>
Notes<br>
-----<br>
It&nbsp;is&nbsp;usually&nbsp;more&nbsp;convenient&nbsp;(and&nbsp;faster)&nbsp;to&nbsp;access&nbsp;the<br>
adjacency&nbsp;dictionary&nbsp;as&nbsp;G[n]:<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>('a','b',weight=7)<br>
&gt;&gt;&gt;&nbsp;G['a']<br>
{'b':&nbsp;{'weight':&nbsp;7}}<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-neighbors">neighbors</a>(0)<br>
[1]</tt></dd></dl>
 
<dl><dt><a name="noc-neighbors_iter"><strong>neighbors_iter</strong></a>(self, n)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;all&nbsp;neighbors&nbsp;of&nbsp;node&nbsp;n.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;[n&nbsp;for&nbsp;n&nbsp;in&nbsp;G.<a href="#noc-neighbors_iter">neighbors_iter</a>(0)]<br>
[1]<br>
&nbsp;<br>
Notes<br>
-----<br>
It&nbsp;is&nbsp;faster&nbsp;to&nbsp;use&nbsp;the&nbsp;idiom&nbsp;"in&nbsp;G[0]",&nbsp;e.g.<br>
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G[0]:<br>
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n<br>
1</tt></dd></dl>
 
<dl><dt><a name="noc-nodes"><strong>nodes</strong></a>(self, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Parameters<br>
----------<br>
data&nbsp;:&nbsp;boolean,&nbsp;optional&nbsp;(default=False)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;False&nbsp;return&nbsp;a&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;a<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;two-tuple&nbsp;of&nbsp;node&nbsp;and&nbsp;node&nbsp;data&nbsp;dictionary<br>
&nbsp;<br>
Returns<br>
-------<br>
nlist&nbsp;:&nbsp;list<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes.&nbsp;&nbsp;If&nbsp;data=True&nbsp;a&nbsp;list&nbsp;of&nbsp;two-tuples&nbsp;containing<br>
&nbsp;&nbsp;&nbsp;&nbsp;(node,&nbsp;node&nbsp;data&nbsp;dictionary).&nbsp;<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
[0,&nbsp;1,&nbsp;2]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_node">add_node</a>(1,&nbsp;time='5pm')<br>
&gt;&gt;&gt;&nbsp;print&nbsp;G.<a href="#noc-nodes">nodes</a>(data=True)<br>
[(0,&nbsp;{}),&nbsp;(1,&nbsp;{'time':&nbsp;'5pm'}),&nbsp;(2,&nbsp;{})]</tt></dd></dl>
 
<dl><dt><a name="noc-nodes_iter"><strong>nodes_iter</strong></a>(self, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;nodes.<br>
&nbsp;<br>
Parameters<br>
----------<br>
data&nbsp;:&nbsp;boolean,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;False&nbsp;the&nbsp;iterator&nbsp;returns&nbsp;nodes.&nbsp;&nbsp;If&nbsp;True<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;a&nbsp;two-tuple&nbsp;of&nbsp;node&nbsp;and&nbsp;node&nbsp;data&nbsp;dictionary<br>
&nbsp;<br>
Returns<br>
-------<br>
niter&nbsp;:&nbsp;iterator<br>
&nbsp;&nbsp;&nbsp;&nbsp;An&nbsp;iterator&nbsp;over&nbsp;nodes.&nbsp;&nbsp;If&nbsp;data=True&nbsp;the&nbsp;iterator&nbsp;gives&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;two-tuples&nbsp;containing&nbsp;(node,&nbsp;node&nbsp;data,&nbsp;dictionary)&nbsp;<br>
&nbsp;<br>
Notes<br>
-----<br>
If&nbsp;the&nbsp;node&nbsp;data&nbsp;is&nbsp;not&nbsp;required&nbsp;it&nbsp;is&nbsp;simpler&nbsp;and&nbsp;equivalent&nbsp;<br>
to&nbsp;use&nbsp;the&nbsp;expression&nbsp;'for&nbsp;n&nbsp;in&nbsp;G'.<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G:<br>
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n,<br>
0&nbsp;1&nbsp;2<br>
&nbsp;<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;for&nbsp;n&nbsp;in&nbsp;G.<a href="#noc-nodes_iter">nodes_iter</a>():<br>
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;n,<br>
0&nbsp;1&nbsp;2<br>
&gt;&gt;&gt;&nbsp;for&nbsp;n,d&nbsp;in&nbsp;G.<a href="#noc-nodes_iter">nodes_iter</a>(data=True):<br>
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;d,<br>
{}&nbsp;{}&nbsp;{}</tt></dd></dl>
 
<dl><dt><a name="noc-nodes_with_selfloops"><strong>nodes_with_selfloops</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;nodes&nbsp;with&nbsp;self&nbsp;loops.<br>
&nbsp;<br>
A&nbsp;node&nbsp;with&nbsp;a&nbsp;self&nbsp;loop&nbsp;has&nbsp;an&nbsp;edge&nbsp;with&nbsp;both&nbsp;ends&nbsp;adjacent<br>
to&nbsp;that&nbsp;node.<br>
&nbsp;<br>
Returns<br>
-------<br>
nodelist&nbsp;:&nbsp;list<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;nodes&nbsp;with&nbsp;self&nbsp;loops.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
selfloop_edges,&nbsp;number_of_selfloops<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,2)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-nodes_with_selfloops">nodes_with_selfloops</a>()<br>
[1]</tt></dd></dl>
 
<dl><dt><a name="noc-number_of_edges"><strong>number_of_edges</strong></a>(self, u<font color="#909090">=None</font>, v<font color="#909090">=None</font>)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;between&nbsp;two&nbsp;nodes.<br>
&nbsp;<br>
Parameters<br>
----------<br>
u,v&nbsp;:&nbsp;nodes,&nbsp;optional&nbsp;(default=all&nbsp;edges)<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;u&nbsp;and&nbsp;v&nbsp;are&nbsp;specified,&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;between&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;u&nbsp;and&nbsp;v.&nbsp;Otherwise&nbsp;return&nbsp;the&nbsp;total&nbsp;number&nbsp;of&nbsp;all&nbsp;edges.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Returns<br>
-------<br>
nedges&nbsp;:&nbsp;int<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;edges&nbsp;in&nbsp;the&nbsp;graph.&nbsp;&nbsp;If&nbsp;nodes&nbsp;u&nbsp;and&nbsp;v&nbsp;are&nbsp;specified<br>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges&nbsp;between&nbsp;those&nbsp;nodes.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
size<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_edges">number_of_edges</a>()<br>
3<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_edges">number_of_edges</a>(0,1)&nbsp;<br>
1<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(0,1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_edges">number_of_edges</a>(*e)<br>
1</tt></dd></dl>
 
<dl><dt><a name="noc-number_of_nodes"><strong>number_of_nodes</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Returns<br>
-------<br>
nnodes&nbsp;:&nbsp;int<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
order,&nbsp;__len__&nbsp;&nbsp;which&nbsp;are&nbsp;identical&nbsp;<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;len(G)<br>
3</tt></dd></dl>
 
<dl><dt><a name="noc-number_of_selfloops"><strong>number_of_selfloops</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;selfloop&nbsp;edges.<br>
&nbsp;<br>
A&nbsp;selfloop&nbsp;edge&nbsp;has&nbsp;the&nbsp;same&nbsp;node&nbsp;at&nbsp;both&nbsp;ends.<br>
&nbsp;<br>
Returns<br>
-------<br>
nloops&nbsp;:&nbsp;int<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;selfloops.&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
selfloop_nodes,&nbsp;selfloop_edges<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G=nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,2)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-number_of_selfloops">number_of_selfloops</a>()<br>
1</tt></dd></dl>
 
<dl><dt><a name="noc-order"><strong>order</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Returns<br>
-------<br>
nnodes&nbsp;:&nbsp;int<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;nodes&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
number_of_nodes,&nbsp;__len__&nbsp;&nbsp;which&nbsp;are&nbsp;identical</tt></dd></dl>
 
<dl><dt><a name="noc-remove_edge"><strong>remove_edge</strong></a>(self, u, v)</dt><dd><tt>Remove&nbsp;the&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
&nbsp;<br>
Parameters<br>
----------<br>
u,v:&nbsp;nodes&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Remove&nbsp;the&nbsp;edge&nbsp;between&nbsp;nodes&nbsp;u&nbsp;and&nbsp;v.<br>
&nbsp;<br>
Raises<br>
------<br>
NetworkXError<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;there&nbsp;is&nbsp;not&nbsp;an&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
remove_edges_from&nbsp;:&nbsp;remove&nbsp;a&nbsp;collection&nbsp;of&nbsp;edges<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edge">remove_edge</a>(0,1)<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(1,2)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edge">remove_edge</a>(*e)&nbsp;#&nbsp;unpacks&nbsp;e&nbsp;from&nbsp;an&nbsp;edge&nbsp;tuple<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;(2,3,{'weight':7})&nbsp;#&nbsp;an&nbsp;edge&nbsp;with&nbsp;attribute&nbsp;data<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edge">remove_edge</a>(*e[:2])&nbsp;#&nbsp;select&nbsp;first&nbsp;part&nbsp;of&nbsp;edge&nbsp;tuple</tt></dd></dl>
 
<dl><dt><a name="noc-remove_edges_from"><strong>remove_edges_from</strong></a>(self, ebunch)</dt><dd><tt>Remove&nbsp;all&nbsp;edges&nbsp;specified&nbsp;in&nbsp;ebunch.<br>
&nbsp;<br>
Parameters<br>
----------<br>
ebunch:&nbsp;list&nbsp;or&nbsp;container&nbsp;of&nbsp;edge&nbsp;tuples<br>
&nbsp;&nbsp;&nbsp;&nbsp;Each&nbsp;edge&nbsp;given&nbsp;in&nbsp;the&nbsp;list&nbsp;or&nbsp;container&nbsp;will&nbsp;be&nbsp;removed&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;the&nbsp;graph.&nbsp;The&nbsp;edges&nbsp;can&nbsp;be:<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;2-tuples&nbsp;(u,v)&nbsp;edge&nbsp;between&nbsp;u&nbsp;and&nbsp;v.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;3-tuples&nbsp;(u,v,k)&nbsp;where&nbsp;k&nbsp;is&nbsp;ignored.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
remove_edge&nbsp;:&nbsp;remove&nbsp;a&nbsp;single&nbsp;edge<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Notes<br>
-----<br>
Will&nbsp;fail&nbsp;silently&nbsp;if&nbsp;an&nbsp;edge&nbsp;in&nbsp;ebunch&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;ebunch=[(1,2),(2,3)]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_edges_from">remove_edges_from</a>(ebunch)</tt></dd></dl>
 
<dl><dt><a name="noc-remove_node"><strong>remove_node</strong></a>(self, n)</dt><dd><tt>Remove&nbsp;node&nbsp;n.<br>
&nbsp;<br>
Removes&nbsp;the&nbsp;node&nbsp;n&nbsp;and&nbsp;all&nbsp;adjacent&nbsp;edges.<br>
Attempting&nbsp;to&nbsp;remove&nbsp;a&nbsp;non-existent&nbsp;node&nbsp;will&nbsp;raise&nbsp;an&nbsp;exception.<br>
&nbsp;<br>
Parameters<br>
----------<br>
n&nbsp;:&nbsp;node<br>
&nbsp;&nbsp;&nbsp;A&nbsp;node&nbsp;in&nbsp;the&nbsp;graph<br>
&nbsp;<br>
Raises<br>
-------<br>
NetworkXError<br>
&nbsp;&nbsp;&nbsp;If&nbsp;n&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
remove_nodes_from<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;2)]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_node">remove_node</a>(1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-edges">edges</a>()<br>
[]</tt></dd></dl>
 
<dl><dt><a name="noc-remove_nodes_from"><strong>remove_nodes_from</strong></a>(self, nodes)</dt><dd><tt>Remove&nbsp;multiple&nbsp;nodes.<br>
&nbsp;<br>
Parameters<br>
----------<br>
nodes&nbsp;:&nbsp;iterable&nbsp;container<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes&nbsp;(list,&nbsp;<a href="__builtin__.html#dict">dict</a>,&nbsp;set,&nbsp;etc.).&nbsp;&nbsp;If&nbsp;a&nbsp;node<br>
&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;the&nbsp;container&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;graph&nbsp;it&nbsp;is&nbsp;silently<br>
&nbsp;&nbsp;&nbsp;&nbsp;ignored.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
remove_node<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;e&nbsp;=&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
&gt;&gt;&gt;&nbsp;e<br>
[0,&nbsp;1,&nbsp;2]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-remove_nodes_from">remove_nodes_from</a>(e)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-nodes">nodes</a>()<br>
[]</tt></dd></dl>
 
<dl><dt><a name="noc-selfloop_edges"><strong>selfloop_edges</strong></a>(self, data<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;selfloop&nbsp;edges.<br>
&nbsp;<br>
A&nbsp;selfloop&nbsp;edge&nbsp;has&nbsp;the&nbsp;same&nbsp;node&nbsp;at&nbsp;both&nbsp;ends.<br>
&nbsp;<br>
Parameters<br>
-----------<br>
data&nbsp;:&nbsp;bool,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;&nbsp;Return&nbsp;selfloop&nbsp;edges&nbsp;as&nbsp;two&nbsp;tuples&nbsp;(u,v)&nbsp;(data=False)<br>
&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;three-tuples&nbsp;(u,v,data)&nbsp;(data=True)<br>
&nbsp;<br>
Returns<br>
-------<br>
edgelist&nbsp;:&nbsp;list&nbsp;of&nbsp;edge&nbsp;tuples<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;all&nbsp;selfloop&nbsp;edges.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
selfloop_nodes,&nbsp;number_of_selfloops<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,1)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>(1,2)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-selfloop_edges">selfloop_edges</a>()<br>
[(1,&nbsp;1)]<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-selfloop_edges">selfloop_edges</a>(data=True)<br>
[(1,&nbsp;1,&nbsp;{})]</tt></dd></dl>
 
<dl><dt><a name="noc-size"><strong>size</strong></a>(self, weighted<font color="#909090">=False</font>)</dt><dd><tt>Return&nbsp;the&nbsp;number&nbsp;of&nbsp;edges.<br>
&nbsp;<br>
Parameters<br>
----------<br>
weighted&nbsp;:&nbsp;boolean,&nbsp;optional&nbsp;(default=False)<br>
&nbsp;&nbsp;&nbsp;If&nbsp;True&nbsp;return&nbsp;the&nbsp;sum&nbsp;of&nbsp;the&nbsp;edge&nbsp;weights.<br>
&nbsp;<br>
Returns<br>
-------<br>
nedges&nbsp;:&nbsp;int<br>
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;edges&nbsp;in&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
number_of_edges<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-size">size</a>()<br>
3<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>('a','b',weight=2)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_edge">add_edge</a>('b','c',weight=4)<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-size">size</a>()<br>
2<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-size">size</a>(weighted=True)<br>
6</tt></dd></dl>
 
<dl><dt><a name="noc-subgraph"><strong>subgraph</strong></a>(self, nbunch)</dt><dd><tt>Return&nbsp;the&nbsp;subgraph&nbsp;induced&nbsp;on&nbsp;nodes&nbsp;in&nbsp;nbunch.<br>
&nbsp;<br>
The&nbsp;induced&nbsp;subgraph&nbsp;of&nbsp;the&nbsp;graph&nbsp;contains&nbsp;the&nbsp;nodes&nbsp;in&nbsp;nbunch&nbsp;<br>
and&nbsp;the&nbsp;edges&nbsp;between&nbsp;those&nbsp;nodes.&nbsp;&nbsp;<br>
&nbsp;<br>
Parameters<br>
----------<br>
nbunch&nbsp;:&nbsp;list,&nbsp;iterable<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;container&nbsp;of&nbsp;nodes&nbsp;which&nbsp;will&nbsp;be&nbsp;iterated&nbsp;through&nbsp;once.&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
Returns<br>
-------<br>
G&nbsp;:&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;subgraph&nbsp;of&nbsp;the&nbsp;graph&nbsp;with&nbsp;the&nbsp;same&nbsp;edge&nbsp;attributes.&nbsp;&nbsp;<br>
&nbsp;<br>
Notes<br>
-----<br>
The&nbsp;graph,&nbsp;edge&nbsp;or&nbsp;node&nbsp;attributes&nbsp;just&nbsp;point&nbsp;to&nbsp;the&nbsp;original&nbsp;graph.<br>
So&nbsp;changes&nbsp;to&nbsp;the&nbsp;node&nbsp;or&nbsp;edge&nbsp;structure&nbsp;will&nbsp;not&nbsp;be&nbsp;reflected&nbsp;in<br>
the&nbsp;original&nbsp;graph&nbsp;while&nbsp;changes&nbsp;to&nbsp;the&nbsp;attributes&nbsp;will.<br>
&nbsp;<br>
To&nbsp;create&nbsp;a&nbsp;subgraph&nbsp;with&nbsp;its&nbsp;own&nbsp;copy&nbsp;of&nbsp;the&nbsp;edge/node&nbsp;attributes&nbsp;use:<br>
nx.<a href="networkx.classes.graph.html#Graph">Graph</a>(G.<a href="#noc-subgraph">subgraph</a>(nbunch))<br>
&nbsp;<br>
If&nbsp;edge&nbsp;attributes&nbsp;are&nbsp;containers,&nbsp;a&nbsp;deep&nbsp;copy&nbsp;can&nbsp;be&nbsp;obtained&nbsp;using:<br>
G.<a href="#noc-subgraph">subgraph</a>(nbunch).<a href="#noc-copy">copy</a>()<br>
&nbsp;<br>
For&nbsp;an&nbsp;in-place&nbsp;reduction&nbsp;of&nbsp;a&nbsp;graph&nbsp;to&nbsp;a&nbsp;subgraph&nbsp;you&nbsp;can&nbsp;remove&nbsp;nodes:<br>
G.<a href="#noc-remove_nodes_from">remove_nodes_from</a>([&nbsp;n&nbsp;in&nbsp;G&nbsp;if&nbsp;n&nbsp;not&nbsp;in&nbsp;set(nbunch)])&nbsp;&nbsp;<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;DiGraph,&nbsp;MultiGraph,&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1,2,3])<br>
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-subgraph">subgraph</a>([0,1,2])<br>
&gt;&gt;&gt;&nbsp;print&nbsp;H.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;2)]</tt></dd></dl>
 
<dl><dt><a name="noc-to_directed"><strong>to_directed</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;directed&nbsp;representation&nbsp;of&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
Returns<br>
-------<br>
G&nbsp;:&nbsp;DiGraph<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;directed&nbsp;graph&nbsp;with&nbsp;the&nbsp;same&nbsp;name,&nbsp;same&nbsp;nodes,&nbsp;and&nbsp;with<br>
&nbsp;&nbsp;&nbsp;&nbsp;each&nbsp;edge&nbsp;(u,v,data)&nbsp;replaced&nbsp;by&nbsp;two&nbsp;directed&nbsp;edges<br>
&nbsp;&nbsp;&nbsp;&nbsp;(u,v,data)&nbsp;and&nbsp;(v,u,data).<br>
&nbsp;<br>
Notes<br>
-----<br>
This&nbsp;returns&nbsp;a&nbsp;"deepcopy"&nbsp;of&nbsp;the&nbsp;edge,&nbsp;node,&nbsp;and&nbsp;<br>
graph&nbsp;attributes&nbsp;which&nbsp;attempts&nbsp;to&nbsp;completely&nbsp;copy<br>
all&nbsp;of&nbsp;the&nbsp;data&nbsp;and&nbsp;references.<br>
&nbsp;<br>
This&nbsp;is&nbsp;in&nbsp;contrast&nbsp;to&nbsp;the&nbsp;similar&nbsp;D=DiGraph(G)&nbsp;which&nbsp;returns&nbsp;a&nbsp;<br>
shallow&nbsp;copy&nbsp;of&nbsp;the&nbsp;data.&nbsp;<br>
&nbsp;<br>
See&nbsp;the&nbsp;Python&nbsp;copy&nbsp;module&nbsp;for&nbsp;more&nbsp;information&nbsp;on&nbsp;shallow<br>
and&nbsp;deep&nbsp;copies,&nbsp;<a href="http://docs.python.org/library/copy.html">http://docs.python.org/library/copy.html</a>.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1])<br>
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-to_directed">to_directed</a>()<br>
&gt;&gt;&gt;&nbsp;H.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;0)]<br>
&nbsp;<br>
If&nbsp;already&nbsp;directed,&nbsp;return&nbsp;a&nbsp;(deep)&nbsp;copy<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.DiGraph()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiDiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1])<br>
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-to_directed">to_directed</a>()<br>
&gt;&gt;&gt;&nbsp;H.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1)]</tt></dd></dl>
 
<dl><dt><a name="noc-to_undirected"><strong>to_undirected</strong></a>(self)</dt><dd><tt>Return&nbsp;an&nbsp;undirected&nbsp;copy&nbsp;of&nbsp;the&nbsp;graph.&nbsp;<br>
&nbsp;<br>
Returns<br>
-------<br>
G&nbsp;:&nbsp;<a href="networkx.classes.graph.html#Graph">Graph</a>/MultiGraph<br>
&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;deepcopy&nbsp;of&nbsp;the&nbsp;graph.<br>
&nbsp;<br>
See&nbsp;Also<br>
--------<br>
copy,&nbsp;add_edge,&nbsp;add_edges_from<br>
&nbsp;<br>
Notes<br>
-----<br>
This&nbsp;returns&nbsp;a&nbsp;"deepcopy"&nbsp;of&nbsp;the&nbsp;edge,&nbsp;node,&nbsp;and&nbsp;<br>
graph&nbsp;attributes&nbsp;which&nbsp;attempts&nbsp;to&nbsp;completely&nbsp;copy<br>
all&nbsp;of&nbsp;the&nbsp;data&nbsp;and&nbsp;references.<br>
&nbsp;<br>
This&nbsp;is&nbsp;in&nbsp;contrast&nbsp;to&nbsp;the&nbsp;similar&nbsp;G=DiGraph(D)&nbsp;which&nbsp;returns&nbsp;a&nbsp;<br>
shallow&nbsp;copy&nbsp;of&nbsp;the&nbsp;data.&nbsp;<br>
&nbsp;<br>
See&nbsp;the&nbsp;Python&nbsp;copy&nbsp;module&nbsp;for&nbsp;more&nbsp;information&nbsp;on&nbsp;shallow<br>
and&nbsp;deep&nbsp;copies,&nbsp;<a href="http://docs.python.org/library/copy.html">http://docs.python.org/library/copy.html</a>.<br>
&nbsp;<br>
Examples<br>
--------<br>
&gt;&gt;&gt;&nbsp;G&nbsp;=&nbsp;nx.<a href="networkx.classes.graph.html#Graph">Graph</a>()&nbsp;&nbsp;&nbsp;#&nbsp;or&nbsp;MultiGraph,&nbsp;etc<br>
&gt;&gt;&gt;&nbsp;G.<a href="#noc-add_path">add_path</a>([0,1])<br>
&gt;&gt;&gt;&nbsp;H&nbsp;=&nbsp;G.<a href="#noc-to_directed">to_directed</a>()<br>
&gt;&gt;&gt;&nbsp;H.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1),&nbsp;(1,&nbsp;0)]<br>
&gt;&gt;&gt;&nbsp;G2&nbsp;=&nbsp;H.<a href="#noc-to_undirected">to_undirected</a>()<br>
&gt;&gt;&gt;&nbsp;G2.<a href="#noc-edges">edges</a>()<br>
[(0,&nbsp;1)]</tt></dd></dl>
 
<hr>
Data descriptors inherited from <a href="networkx.classes.graph.html#Graph">networkx.classes.graph.Graph</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="nocobject">class <strong>nocobject</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>NoC&nbsp;base&nbsp;object<br>
&nbsp;<br>
This&nbsp;base&nbsp;class&nbsp;is&nbsp;used&nbsp;to&nbsp;implement&nbsp;common&nbsp;methods&nbsp;for&nbsp;NoC&nbsp;objects.<br>
Don't&nbsp;use&nbsp;directly.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="nocobject-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
 
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="packet">class <strong>packet</strong></a>(<a href="__builtin__.html#dict">__builtin__.dict</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Packet&nbsp;base&nbsp;object<br>
&nbsp;<br>
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;<a href="#packet">packet</a>&nbsp;data,&nbsp;related&nbsp;to&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object.&nbsp;It&nbsp;<br>
behaves&nbsp;exactly&nbsp;like&nbsp;a&nbsp;Python&nbsp;dictionary,&nbsp;but&nbsp;adds&nbsp;methods&nbsp;to&nbsp;simplify&nbsp;<br>
<a href="#packet">packet</a>&nbsp;transformations.&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;<br>
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
*&nbsp;It&nbsp;should&nbsp;be&nbsp;generated&nbsp;by&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;(and&nbsp;will&nbsp;have&nbsp;a&nbsp;reference&nbsp;<br>
&nbsp;&nbsp;in&nbsp;self.<strong>protocol_ref</strong>)<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;protocol_ref:&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;that&nbsp;created&nbsp;this&nbsp;object.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nocmodel.noc_base.html#packet">packet</a></dd>
<dd><a href="__builtin__.html#dict">__builtin__.dict</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="packet-__init__"><strong>__init__</strong></a>(self, *args, **kwargs)</dt><dd><tt>#&nbsp;the&nbsp;constructor</tt></dd></dl>
 
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
<dl><dt><a name="packet-__cmp__"><strong>__cmp__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__cmp__">__cmp__</a>(y)&nbsp;&lt;==&gt;&nbsp;cmp(x,y)</tt></dd></dl>
 
<dl><dt><a name="packet-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>D.<a href="#packet-__contains__">__contains__</a>(k)&nbsp;-&gt;&nbsp;True&nbsp;if&nbsp;D&nbsp;has&nbsp;a&nbsp;key&nbsp;k,&nbsp;else&nbsp;False</tt></dd></dl>
 
<dl><dt><a name="packet-__delitem__"><strong>__delitem__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__delitem__">__delitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;del&nbsp;x[y]</tt></dd></dl>
 
<dl><dt><a name="packet-__eq__"><strong>__eq__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__eq__">__eq__</a>(y)&nbsp;&lt;==&gt;&nbsp;x==y</tt></dd></dl>
 
<dl><dt><a name="packet-__ge__"><strong>__ge__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__ge__">__ge__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&gt;=y</tt></dd></dl>
 
<dl><dt><a name="packet-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__getattribute__">__getattribute__</a>('name')&nbsp;&lt;==&gt;&nbsp;x.name</tt></dd></dl>
 
<dl><dt><a name="packet-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>
 
<dl><dt><a name="packet-__gt__"><strong>__gt__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__gt__">__gt__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&gt;y</tt></dd></dl>
 
<dl><dt><a name="packet-__iter__"><strong>__iter__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__iter__">__iter__</a>()&nbsp;&lt;==&gt;&nbsp;iter(x)</tt></dd></dl>
 
<dl><dt><a name="packet-__le__"><strong>__le__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__le__">__le__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&lt;=y</tt></dd></dl>
 
<dl><dt><a name="packet-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__len__">__len__</a>()&nbsp;&lt;==&gt;&nbsp;len(x)</tt></dd></dl>
 
<dl><dt><a name="packet-__lt__"><strong>__lt__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__lt__">__lt__</a>(y)&nbsp;&lt;==&gt;&nbsp;x&lt;y</tt></dd></dl>
 
<dl><dt><a name="packet-__ne__"><strong>__ne__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__ne__">__ne__</a>(y)&nbsp;&lt;==&gt;&nbsp;x!=y</tt></dd></dl>
 
<dl><dt><a name="packet-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>
 
<dl><dt><a name="packet-__setitem__"><strong>__setitem__</strong></a>(...)</dt><dd><tt>x.<a href="#packet-__setitem__">__setitem__</a>(i,&nbsp;y)&nbsp;&lt;==&gt;&nbsp;x[i]=y</tt></dd></dl>
 
<dl><dt><a name="packet-__sizeof__"><strong>__sizeof__</strong></a>(...)</dt><dd><tt>D.<a href="#packet-__sizeof__">__sizeof__</a>()&nbsp;-&gt;&nbsp;size&nbsp;of&nbsp;D&nbsp;in&nbsp;memory,&nbsp;in&nbsp;bytes</tt></dd></dl>
 
<dl><dt><a name="packet-clear"><strong>clear</strong></a>(...)</dt><dd><tt>D.<a href="#packet-clear">clear</a>()&nbsp;-&gt;&nbsp;None.&nbsp;&nbsp;Remove&nbsp;all&nbsp;items&nbsp;from&nbsp;D.</tt></dd></dl>
 
<dl><dt><a name="packet-copy"><strong>copy</strong></a>(...)</dt><dd><tt>D.<a href="#packet-copy">copy</a>()&nbsp;-&gt;&nbsp;a&nbsp;shallow&nbsp;copy&nbsp;of&nbsp;D</tt></dd></dl>
 
<dl><dt><a name="packet-get"><strong>get</strong></a>(...)</dt><dd><tt>D.<a href="#packet-get">get</a>(k[,d])&nbsp;-&gt;&nbsp;D[k]&nbsp;if&nbsp;k&nbsp;in&nbsp;D,&nbsp;else&nbsp;d.&nbsp;&nbsp;d&nbsp;defaults&nbsp;to&nbsp;None.</tt></dd></dl>
 
<dl><dt><a name="packet-has_key"><strong>has_key</strong></a>(...)</dt><dd><tt>D.<a href="#packet-has_key">has_key</a>(k)&nbsp;-&gt;&nbsp;True&nbsp;if&nbsp;D&nbsp;has&nbsp;a&nbsp;key&nbsp;k,&nbsp;else&nbsp;False</tt></dd></dl>
 
<dl><dt><a name="packet-items"><strong>items</strong></a>(...)</dt><dd><tt>D.<a href="#packet-items">items</a>()&nbsp;-&gt;&nbsp;list&nbsp;of&nbsp;D's&nbsp;(key,&nbsp;value)&nbsp;pairs,&nbsp;as&nbsp;2-tuples</tt></dd></dl>
 
<dl><dt><a name="packet-iteritems"><strong>iteritems</strong></a>(...)</dt><dd><tt>D.<a href="#packet-iteritems">iteritems</a>()&nbsp;-&gt;&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;(key,&nbsp;value)&nbsp;items&nbsp;of&nbsp;D</tt></dd></dl>
 
<dl><dt><a name="packet-iterkeys"><strong>iterkeys</strong></a>(...)</dt><dd><tt>D.<a href="#packet-iterkeys">iterkeys</a>()&nbsp;-&gt;&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;keys&nbsp;of&nbsp;D</tt></dd></dl>
 
<dl><dt><a name="packet-itervalues"><strong>itervalues</strong></a>(...)</dt><dd><tt>D.<a href="#packet-itervalues">itervalues</a>()&nbsp;-&gt;&nbsp;an&nbsp;iterator&nbsp;over&nbsp;the&nbsp;values&nbsp;of&nbsp;D</tt></dd></dl>
 
<dl><dt><a name="packet-keys"><strong>keys</strong></a>(...)</dt><dd><tt>D.<a href="#packet-keys">keys</a>()&nbsp;-&gt;&nbsp;list&nbsp;of&nbsp;D's&nbsp;keys</tt></dd></dl>
 
<dl><dt><a name="packet-pop"><strong>pop</strong></a>(...)</dt><dd><tt>D.<a href="#packet-pop">pop</a>(k[,d])&nbsp;-&gt;&nbsp;v,&nbsp;remove&nbsp;specified&nbsp;key&nbsp;and&nbsp;return&nbsp;the&nbsp;corresponding&nbsp;value.<br>
If&nbsp;key&nbsp;is&nbsp;not&nbsp;found,&nbsp;d&nbsp;is&nbsp;returned&nbsp;if&nbsp;given,&nbsp;otherwise&nbsp;KeyError&nbsp;is&nbsp;raised</tt></dd></dl>
 
<dl><dt><a name="packet-popitem"><strong>popitem</strong></a>(...)</dt><dd><tt>D.<a href="#packet-popitem">popitem</a>()&nbsp;-&gt;&nbsp;(k,&nbsp;v),&nbsp;remove&nbsp;and&nbsp;return&nbsp;some&nbsp;(key,&nbsp;value)&nbsp;pair&nbsp;as&nbsp;a<br>
2-tuple;&nbsp;but&nbsp;raise&nbsp;KeyError&nbsp;if&nbsp;D&nbsp;is&nbsp;empty.</tt></dd></dl>
 
<dl><dt><a name="packet-setdefault"><strong>setdefault</strong></a>(...)</dt><dd><tt>D.<a href="#packet-setdefault">setdefault</a>(k[,d])&nbsp;-&gt;&nbsp;D.<a href="#packet-get">get</a>(k,d),&nbsp;also&nbsp;set&nbsp;D[k]=d&nbsp;if&nbsp;k&nbsp;not&nbsp;in&nbsp;D</tt></dd></dl>
 
<dl><dt><a name="packet-update"><strong>update</strong></a>(...)</dt><dd><tt>D.<a href="#packet-update">update</a>(E,&nbsp;**F)&nbsp;-&gt;&nbsp;None.&nbsp;&nbsp;Update&nbsp;D&nbsp;from&nbsp;<a href="__builtin__.html#dict">dict</a>/iterable&nbsp;E&nbsp;and&nbsp;F.<br>
If&nbsp;E&nbsp;has&nbsp;a&nbsp;.<a href="#packet-keys">keys</a>()&nbsp;method,&nbsp;does:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;k&nbsp;in&nbsp;E:&nbsp;D[k]&nbsp;=&nbsp;E[k]<br>
If&nbsp;E&nbsp;lacks&nbsp;.<a href="#packet-keys">keys</a>()&nbsp;method,&nbsp;does:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(k,&nbsp;v)&nbsp;in&nbsp;E:&nbsp;D[k]&nbsp;=&nbsp;v<br>
In&nbsp;either&nbsp;case,&nbsp;this&nbsp;is&nbsp;followed&nbsp;by:&nbsp;for&nbsp;k&nbsp;in&nbsp;F:&nbsp;D[k]&nbsp;=&nbsp;F[k]</tt></dd></dl>
 
<dl><dt><a name="packet-values"><strong>values</strong></a>(...)</dt><dd><tt>D.<a href="#packet-values">values</a>()&nbsp;-&gt;&nbsp;list&nbsp;of&nbsp;D's&nbsp;values</tt></dd></dl>
 
<hr>
Data and other attributes inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
 
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object&gt;<dd><tt>T.<a href="#packet-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;object&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>
 
<dl><dt><strong>fromkeys</strong> = &lt;built-in method fromkeys of type object&gt;<dd><tt><a href="__builtin__.html#dict">dict</a>.<a href="#packet-fromkeys">fromkeys</a>(S[,v])&nbsp;-&gt;&nbsp;New&nbsp;<a href="__builtin__.html#dict">dict</a>&nbsp;with&nbsp;keys&nbsp;from&nbsp;S&nbsp;and&nbsp;values&nbsp;equal&nbsp;to&nbsp;v.<br>
v&nbsp;defaults&nbsp;to&nbsp;None.</tt></dl>
 
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="protocol">class <strong>protocol</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Protocol&nbsp;base&nbsp;object<br>
&nbsp;<br>
This&nbsp;object&nbsp;represents&nbsp;the&nbsp;<a href="#protocol">protocol</a>&nbsp;that&nbsp;the&nbsp;NoC&nbsp;objects&nbsp;use.&nbsp;This&nbsp;<br>
object&nbsp;has&nbsp;attributes&nbsp;that&nbsp;define&nbsp;the&nbsp;<a href="#protocol">protocol</a>&nbsp;used,&nbsp;mainly&nbsp;it&nbsp;can&nbsp;be<br>
used&nbsp;to&nbsp;generate,&nbsp;encode,&nbsp;decode&nbsp;or&nbsp;interpret&nbsp;packets&nbsp;on&nbsp;the&nbsp;NoC.<br>
This&nbsp;base&nbsp;class&nbsp;can&nbsp;be&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;<br>
other&nbsp;attributes.<br>
&nbsp;<br>
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
*&nbsp;Each&nbsp;object&nbsp;on&nbsp;the&nbsp;NoC&nbsp;(routers,&nbsp;channels&nbsp;and&nbsp;ipcores)&nbsp;may&nbsp;have<br>
&nbsp;&nbsp;one&nbsp;reference&nbsp;to&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;(object.protocol_ref)<br>
*&nbsp;A&nbsp;NoC&nbsp;model&nbsp;may&nbsp;have&nbsp;a&nbsp;<a href="#protocol">protocol</a>&nbsp;object:&nbsp;in&nbsp;this&nbsp;case,&nbsp;all&nbsp;objects&nbsp;in<br>
&nbsp;&nbsp;the&nbsp;model&nbsp;will&nbsp;use&nbsp;this&nbsp;<a href="#protocol">protocol</a>&nbsp;(nocmodel.protocol_ref)<br>
*&nbsp;A&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;is&nbsp;a&nbsp;generator&nbsp;of&nbsp;<a href="#packet">packet</a>&nbsp;objects<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;name<br>
&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;Optional&nbsp;arguments&nbsp;"packet_format"&nbsp;and&nbsp;"packet_order"&nbsp;can&nbsp;be<br>
&nbsp;&nbsp;added&nbsp;at&nbsp;object&nbsp;construction,&nbsp;but&nbsp;will&nbsp;not&nbsp;check&nbsp;its&nbsp;data&nbsp;consistency.&nbsp;<br>
&nbsp;&nbsp;At&nbsp;the&nbsp;moment,&nbsp;we&nbsp;recommend&nbsp;using&nbsp;<a href="#protocol-update_packet_field">update_packet_field</a>()&nbsp;method&nbsp;to<br>
&nbsp;&nbsp;fill&nbsp;this&nbsp;data&nbsp;structures.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="protocol-__init__"><strong>__init__</strong></a>(self, name<font color="#909090">=''</font>, **kwargs)</dt><dd><tt>Constructor<br>
&nbsp;<br>
Notes:<br>
*&nbsp;Optional&nbsp;arguments&nbsp;will&nbsp;be&nbsp;added&nbsp;as&nbsp;object&nbsp;attributes.</tt></dd></dl>
 
<dl><dt><a name="protocol-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt></dl>
 
<dl><dt><a name="protocol-newpacket"><strong>newpacket</strong></a>(self, zerodefault<font color="#909090">=True</font>, *args, **kwargs)</dt><dd><tt>Return&nbsp;a&nbsp;new&nbsp;<a href="#packet">packet</a>&nbsp;with&nbsp;all&nbsp;required&nbsp;fields.<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;zerodefault:&nbsp;If&nbsp;True,&nbsp;all&nbsp;missing&nbsp;fields&nbsp;will&nbsp;be&nbsp;zeroed&nbsp;by&nbsp;default.<br>
&nbsp;&nbsp;If&nbsp;False,&nbsp;a&nbsp;missing&nbsp;value&nbsp;in&nbsp;arguments&nbsp;will&nbsp;throw&nbsp;an&nbsp;exception.<br>
*&nbsp;args:&nbsp;Nameless&nbsp;arguments&nbsp;will&nbsp;add&nbsp;field&nbsp;values&nbsp;based&nbsp;on&nbsp;<a href="#packet">packet</a>&nbsp;field<br>
&nbsp;&nbsp;order.<br>
*&nbsp;kwargs:&nbsp;Key-based&nbsp;arguments&nbsp;will&nbsp;add&nbsp;specified&nbsp;field&nbsp;values&nbsp;based&nbsp;in&nbsp;<br>
&nbsp;&nbsp;its&nbsp;keys<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;kwargs&nbsp;takes&nbsp;precedence&nbsp;over&nbsp;args:&nbsp;i.e.&nbsp;named&nbsp;arguments&nbsp;can&nbsp;overwrite<br>
&nbsp;&nbsp;nameless&nbsp;arguments.</tt></dd></dl>
 
<dl><dt><a name="protocol-register_packet_generator"><strong>register_packet_generator</strong></a>(self, packet_class)</dt><dd><tt>Register&nbsp;a&nbsp;special&nbsp;<a href="#packet">packet</a>&nbsp;generator&nbsp;class.<br>
&nbsp;<br>
Must&nbsp;be&nbsp;a&nbsp;derived&nbsp;class&nbsp;of&nbsp;<a href="#packet">packet</a></tt></dd></dl>
 
<dl><dt><a name="protocol-update_packet_field"><strong>update_packet_field</strong></a>(self, name, type, bitlen, description<font color="#909090">=''</font>)</dt><dd><tt>Add&nbsp;or&nbsp;update&nbsp;a&nbsp;<a href="#packet">packet</a>&nbsp;field.<br>
&nbsp;<br>
Arguments<br>
*&nbsp;name<br>
*&nbsp;type:&nbsp;string&nbsp;that&nbsp;can&nbsp;be&nbsp;"int",&nbsp;"fixed"&nbsp;or&nbsp;"float"<br>
*&nbsp;bitlen:&nbsp;bit&nbsp;length&nbsp;of&nbsp;this&nbsp;field<br>
*&nbsp;description:&nbsp;optional&nbsp;description&nbsp;of&nbsp;this&nbsp;field<br>
&nbsp;<br>
Notes:&nbsp;<br>
*&nbsp;Each&nbsp;new&nbsp;field&nbsp;will&nbsp;be&nbsp;added&nbsp;at&nbsp;the&nbsp;end.</tt></dd></dl>
 
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="router">class <strong>router</strong></a>(<a href="nocmodel.noc_base.html#nocobject">nocobject</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Router&nbsp;base&nbsp;object<br>
&nbsp;<br>
This&nbsp;object&nbsp;represents&nbsp;a&nbsp;<a href="#router">router</a>&nbsp;object&nbsp;and&nbsp;its&nbsp;properties.&nbsp;This&nbsp;base&nbsp;class<br>
is&nbsp;meant&nbsp;to&nbsp;either&nbsp;be&nbsp;inherited&nbsp;or&nbsp;extended&nbsp;by&nbsp;adding&nbsp;other&nbsp;attributes.<br>
&nbsp;<br>
Relations&nbsp;with&nbsp;other&nbsp;objects:<br>
*&nbsp;It&nbsp;should&nbsp;be&nbsp;related&nbsp;to&nbsp;one&nbsp;NoC&nbsp;model&nbsp;object&nbsp;(self.<strong>graph_ref</strong>)<br>
*&nbsp;It&nbsp;should&nbsp;be&nbsp;one&nbsp;of&nbsp;the&nbsp;node&nbsp;attributes&nbsp;in&nbsp;the&nbsp;graph&nbsp;model&nbsp;<br>
&nbsp;&nbsp;(node["router_ref"])<br>
*&nbsp;It&nbsp;may&nbsp;have&nbsp;one&nbsp;reference&nbsp;to&nbsp;an&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;(self.<strong>ipcore_ref</strong>)<br>
*&nbsp;It&nbsp;has&nbsp;a&nbsp;port&nbsp;list&nbsp;with&nbsp;relations&nbsp;to&nbsp;other&nbsp;routers&nbsp;through&nbsp;<a href="#channel">channel</a>&nbsp;objects,<br>
&nbsp;&nbsp;and&nbsp;only&nbsp;one&nbsp;relation&nbsp;to&nbsp;its&nbsp;<a href="#ipcore">ipcore</a>&nbsp;object&nbsp;through&nbsp;one&nbsp;<a href="#channel">channel</a>.<br>
&nbsp;&nbsp;(self.<strong>ports</strong>).&nbsp;Note&nbsp;that&nbsp;this&nbsp;attribute&nbsp;must&nbsp;be&nbsp;updated&nbsp;after&nbsp;changing&nbsp;<br>
&nbsp;&nbsp;the&nbsp;NoC&nbsp;model.<br>
&nbsp;<br>
Attributes:<br>
*&nbsp;index:&nbsp;index&nbsp;on&nbsp;a&nbsp;<a href="#noc">noc</a>&nbsp;object.&nbsp;Essential&nbsp;to&nbsp;search&nbsp;for&nbsp;a&nbsp;<a href="#router">router</a>&nbsp;object<br>
*&nbsp;name<br>
*&nbsp;ipcore_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;related&nbsp;<a href="#ipcore">ipcore</a><br>
*&nbsp;graph_ref:&nbsp;optional&nbsp;reference&nbsp;to&nbsp;its&nbsp;graph&nbsp;model<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="router-__init__"><strong>__init__</strong></a>(self, index, name, **kwargs)</dt></dl>
 
<dl><dt><a name="router-update_ports_info"><strong>update_ports_info</strong></a>(self)</dt><dd><tt>Update&nbsp;the&nbsp;dictionary&nbsp;"ports":&nbsp;information&nbsp;about&nbsp;<a href="#router">router</a>&nbsp;neighbors,<br>
the&nbsp;channels&nbsp;that&nbsp;connect&nbsp;them&nbsp;and&nbsp;its&nbsp;references.<br>
&nbsp;<br>
Ports&nbsp;dictionary&nbsp;has&nbsp;the&nbsp;following&nbsp;structure:<br>
*&nbsp;key:&nbsp;address&nbsp;of&nbsp;the&nbsp;neighbor&nbsp;<a href="#router">router</a>&nbsp;that&nbsp;this&nbsp;port&nbsp;connects.<br>
*&nbsp;value:&nbsp;dictionary&nbsp;with&nbsp;the&nbsp;following&nbsp;keys:<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"peer"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;the&nbsp;neighbor&nbsp;<a href="#router">router</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"<a href="#channel">channel</a>"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;that&nbsp;connects&nbsp;this&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#router">router</a>&nbsp;and&nbsp;its&nbsp;neighbor&nbsp;<a href="#router">router</a>.<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Optional&nbsp;keys&nbsp;can&nbsp;be&nbsp;added&nbsp;to&nbsp;this&nbsp;dictionary.<br>
*&nbsp;Also,&nbsp;the&nbsp;special&nbsp;key&nbsp;"local&nbsp;address"&nbsp;holds&nbsp;the&nbsp;port&nbsp;to&nbsp;<br>
&nbsp;&nbsp;<a href="#router">router</a>'s&nbsp;<a href="#ipcore">ipcore</a>.&nbsp;Its&nbsp;values&nbsp;are:<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"peer"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;its&nbsp;<a href="#ipcore">ipcore</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"<a href="#channel">channel</a>"&nbsp;(required):&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#channel">channel</a>&nbsp;that&nbsp;connects&nbsp;this&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#router">router</a>&nbsp;and&nbsp;its&nbsp;<a href="#ipcore">ipcore</a>.<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Optional&nbsp;keys&nbsp;can&nbsp;be&nbsp;added&nbsp;to&nbsp;this&nbsp;dictionary&nbsp;with&nbsp;the&nbsp;same&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;meaning&nbsp;as&nbsp;other&nbsp;ports.</tt></dd></dl>
 
<dl><dt><a name="router-update_routes_info"><strong>update_routes_info</strong></a>(self)</dt><dd><tt>Update&nbsp;the&nbsp;dictionary&nbsp;"routes_info":&nbsp;it&nbsp;is&nbsp;a&nbsp;table&nbsp;with&nbsp;information&nbsp;<br>
about&nbsp;how&nbsp;a&nbsp;package,&nbsp;starting&nbsp;from&nbsp;this&nbsp;<a href="#router">router</a>,&nbsp;can&nbsp;reach&nbsp;another&nbsp;one.<br>
&nbsp;<br>
routes_info&nbsp;dictionary&nbsp;has&nbsp;the&nbsp;following&nbsp;structure:<br>
*&nbsp;keys&nbsp;:&nbsp;the&nbsp;address&nbsp;of&nbsp;all&nbsp;the&nbsp;routers&nbsp;in&nbsp;NoC<br>
*&nbsp;values&nbsp;:&nbsp;an&nbsp;ordered&nbsp;list&nbsp;of&nbsp;dictionaries&nbsp;with&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"next"&nbsp;:&nbsp;address&nbsp;of&nbsp;the&nbsp;next&nbsp;<a href="#router">router</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;"paths"&nbsp;:&nbsp;list&nbsp;of&nbsp;possible&nbsp;paths&nbsp;for&nbsp;key&nbsp;destination</tt></dd></dl>
 
<hr>
Methods inherited from <a href="nocmodel.noc_base.html#nocobject">nocobject</a>:<br>
<dl><dt><a name="router-get_protocol_ref"><strong>get_protocol_ref</strong></a>(self)</dt><dd><tt>Get&nbsp;<a href="#protocol">protocol</a>&nbsp;object&nbsp;for&nbsp;this&nbsp;instance</tt></dd></dl>
 
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-all_shortest_paths"><strong>all_shortest_paths</strong></a>(G, a, b)</dt><dd><tt>Return&nbsp;a&nbsp;list&nbsp;of&nbsp;all&nbsp;shortest&nbsp;paths&nbsp;in&nbsp;graph&nbsp;G&nbsp;between&nbsp;nodes&nbsp;a&nbsp;and&nbsp;b<br>
This&nbsp;is&nbsp;a&nbsp;function&nbsp;not&nbsp;available&nbsp;in&nbsp;NetworkX&nbsp;(checked&nbsp;at&nbsp;22-02-2011)<br>
&nbsp;<br>
Taken&nbsp;from:&nbsp;<br>
<a href="http://groups.google.com/group/networkx-discuss/browse_thread/thread/55465e6bb9bae12e">http://groups.google.com/group/networkx-discuss/browse_thread/thread/55465e6bb9bae12e</a></tt></dd></dl>
</td></tr></table>
</body></html>
/trunk/doc/nocmodel.noc_guilib.html
0,0 → 1,44
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nocmodel.noc_guilib</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.noc_guilib</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_guilib.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_guilib.py</a></font></td></tr></table>
<p><tt>================<br>
NoCmodel&nbsp;Graphic&nbsp;utilities<br>
================<br>
&nbsp;&nbsp;<br>
This&nbsp;module&nbsp;declares&nbsp;functions&nbsp;to&nbsp;draw&nbsp;graphical&nbsp;representations&nbsp;of&nbsp;<br>
NoCmodel&nbsp;objects.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="networkx.html">networkx</a><br>
</td><td width="25%" valign=top><a href="matplotlib.pyplot.html">matplotlib.pyplot</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-draw_noc"><strong>draw_noc</strong></a>(noc, rectangular<font color="#909090">=True</font>, nodepos<font color="#909090">=None</font>)</dt><dd><tt>Draw&nbsp;a&nbsp;representation&nbsp;of&nbsp;a&nbsp;NoC<br>
&nbsp;<br>
Arguments:<br>
*&nbsp;noc:&nbsp;Model&nbsp;to&nbsp;draw<br>
*&nbsp;rectangular:&nbsp;If&nbsp;True&nbsp;assumes&nbsp;rectangular&nbsp;layout,&nbsp;with&nbsp;routers&nbsp;<br>
&nbsp;&nbsp;having&nbsp;coord_x&nbsp;and&nbsp;coord_y&nbsp;attributes.&nbsp;If&nbsp;false,&nbsp;expect&nbsp;router's&nbsp;<br>
&nbsp;&nbsp;positions&nbsp;in&nbsp;nodepos&nbsp;argument<br>
*&nbsp;nodepos:&nbsp;Optional&nbsp;dictionary&nbsp;where&nbsp;keys&nbsp;are&nbsp;router's&nbsp;indexes&nbsp;and&nbsp;values&nbsp;<br>
&nbsp;&nbsp;are&nbsp;tuples&nbsp;with&nbsp;x&nbsp;and&nbsp;y&nbsp;positions.</tt></dd></dl>
</td></tr></table>
</body></html>
/trunk/doc/nocmodel.noc_tlm_utils.html
0,0 → 1,35
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nocmodel.noc_tlm_utils</title>
</head><body bgcolor="#f0f0f8">
 
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="nocmodel.html"><font color="#ffffff">nocmodel</font></a>.noc_tlm_utils</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_tlm_utils.py">/home/oscard/Documentos/proyectos/nocmodel-0.1/nocmodel/noc_tlm_utils.py</a></font></td></tr></table>
<p><tt>#&nbsp;-*-&nbsp;coding:&nbsp;utf-8&nbsp;-*-</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="nocmodel.basicmodels.basic_channel.html">nocmodel.basicmodels.basic_channel</a><br>
<a href="nocmodel.basicmodels.basic_ipcore.html">nocmodel.basicmodels.basic_ipcore</a><br>
</td><td width="25%" valign=top><a href="nocmodel.basicmodels.basic_router.html">nocmodel.basicmodels.basic_router</a><br>
<a href="logging.html">logging</a><br>
</td><td width="25%" valign=top><a href="myhdl.html">myhdl</a><br>
<a href="networkx.html">networkx</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-add_tlm_basic_support"><strong>add_tlm_basic_support</strong></a>(instance, **kwargs)</dt><dd><tt>This&nbsp;function&nbsp;will&nbsp;add&nbsp;for&nbsp;every&nbsp;object&nbsp;in&nbsp;noc_instance&nbsp;a&nbsp;noc_tlm&nbsp;object</tt></dd></dl>
</td></tr></table>
</body></html>
/trunk/CHANGELOG.txt
0,0 → 1,8
nocmodel (0.1) urgency=low
 
* First release:
- Basic model framework
- Initial TLM simulation support
- Basic set of NoC object models
 
-- Oscar Diaz <dargor@opencores.org> Thr, 03 Mar 2011 23:05:45 +0100
/trunk/setup.py
0,0 → 1,59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoCmodel - setup file
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
from distutils.core import setup
 
classifiers = """\
Development Status :: 3 - Alpha
Intended Audience :: Developers
License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Operating System :: OS Independent
Programming Language :: Python
Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
"""
 
setup(name='nocmodel',
version='0.1',
description='Network-on-Chip modeling library',
author='Oscar Diaz',
author_email='dargor@opencores.org',
url='http://opencores.org/project,nocmodel',
license='LGPL',
requires=['networkx', 'myhdl'],
platforms=["Any"],
keywords="HDL ASIC FPGA SoC NoC hardware design",
classifiers=filter(None, classifiers.split("\n")),
packages=[
'nocmodel',
],
)
/trunk/README.txt
0,0 → 1,47
NoCmodel 0.1
============
 
What is NoCmodel?
-----------------
 
NoCmodel is a Python module for Network-on-Chip modeling, with add-ons for
simulation (functional or RTL) and code generation (initially VHDL).
 
Based on Python language, this module provides a framework for generic modeling
of a NoC (IP Core nodes, routers, or channels), and provides some add-ons that
extends the model to support design features like functional simulation,
RTL simulation, VHDL code generation, etc.
 
Requirements
------------
 
* Python (version 2.6 or later)
* NetworkX (version 1.4 or later) [http://networkx.lanl.gov]
* MyHDL (version 0.6 or later) [http://www.myhdl.org]
 
Installation
------------
System-wide install:
 
python setup.py install
 
Like a normal Python package, it uses distutils for its installation.
Check the distutils documentation in the standard Python library
if necessary.
 
Documentation
-------------
 
Documentation generated by pydoc is available on "src" directory. Also, there's
basic examples in "examples" directory.
License
-------
NoCmodel is available under the LGPL license version 2.1 . See LICENSE.txt.
 
Authors
-------
 
* Oscar Diaz <dargor@opencores.org>
 
Last update: Thu, 03 Mar 2011 18:00:20 +0100
/trunk/examples/basic_example.py
0,0 → 1,133
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
#
# NoCmodel basic example
#
# Author: Oscar Diaz
# Version: 0.1
# Date: 03-03-2011
 
#
# This code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
#
 
#
# Changelog:
#
# 03-03-2011 : (OD) initial release
#
 
import matplotlib.pyplot as plt
import myhdl
import logging
 
from nocmodel import *
from nocmodel.basicmodels import *
 
# Basic example model with TLM simulation
 
# 1. Create the model
 
basicnoc = noc(name="Basic 2x2 NoC example")
 
# 1.1 create a rectangular 2x2 NoC, make its connections and add default protocol
 
R11 = basicnoc.add_router("R11", with_ipcore=True, coord_x = 1, coord_y = 1)
R12 = basicnoc.add_router("R12", with_ipcore=True, coord_x = 1, coord_y = 2)
R21 = basicnoc.add_router("R21", with_ipcore=True, coord_x = 2, coord_y = 1)
R22 = basicnoc.add_router("R22", with_ipcore=True, coord_x = 2, coord_y = 2)
 
basicnoc.add_channel(R11,R12)
basicnoc.add_channel(R11,R21)
basicnoc.add_channel(R12,R22)
basicnoc.add_channel(R21,R22)
 
basicnoc.protocol_ref = basic_protocol()
 
for r in basicnoc.router_list():
r.update_ports_info()
r.update_routes_info()
 
# 2. add tlm support, and configure logging
add_tlm_basic_support(basicnoc, log_file="simulation.log", log_level=logging.DEBUG)
 
# 3. Declare generators to put in the TLM simulation
 
# set ip_cores functionality as myhdl generators
def sourcegen(din, dout, tlm_ref, mydest, data=None, startdelay=100, period=100):
# this generator only drives dout
@myhdl.instance
def putnewdata():
datacount = 0
protocol_ref = tlm_ref.ipcore_ref.get_protocol_ref()
mysrc = tlm_ref.ipcore_ref.router_ref.address
tlm_ref.debug("sourcegen: init dout is %s" % repr(dout.val))
yield myhdl.delay(startdelay)
while True:
if len(data) == datacount:
tlm_ref.debug("sourcegen: end of data. waiting for %d steps" % (period*10))
yield myhdl.delay(period*10)
raise myhdl.StopSimulation("data ended at time %d" % myhdl.now())
dout.next = protocol_ref.newpacket(False, mysrc, mydest, data[datacount])
tlm_ref.debug("sourcegen: data next element %d dout is %s datacount is %d" % (data[datacount], repr(dout.val), datacount))
yield myhdl.delay(period)
datacount += 1
return putnewdata
def checkgen(din, dout, tlm_ref, mysrc, data=None):
# this generator only respond to din
@myhdl.instance
def checkdata():
datacount = 0
protocol_ref = tlm_ref.ipcore_ref.get_protocol_ref()
mydest = tlm_ref.ipcore_ref.router_ref.address
while True:
yield din
if len(data) > datacount:
checkdata = din.val["data"]
tlm_ref.debug("checkgen: assert checkdata != data[datacount] => %d != %d [%d]" % (checkdata, data[datacount], datacount))
if checkdata != data[datacount]:
tlm_ref.error("checkgen: value != %d (%d)" % (data[datacount], checkdata))
tlm_ref.debug("checkgen: assert source address != mysrc => %d != %d " % (din.val["src"], mysrc))
if din.val["src"] != mysrc:
tlm_ref.error("checkgen: source address != %d (%d)" % (mysrc, din.val["src"]))
tlm_ref.debug("checkgen: assert destination address != mydest => %d != %d " % (din.val["dst"], mydest))
if din.val["dst"] != mydest:
tlm_ref.error("checkgen: destination address != %d (%d)" % (mydest, din.val["dst"]))
datacount += 1
return checkdata
 
# 4. Set test vectors
R11_testdata = [5, 12, 50, -11, 6, 9, 0, 3, 25]
R12_testdata = [x*5 for x in R11_testdata]
 
# 5. assign generators to ip cores (in TLM model !)
# R11 will send to R22, R12 will send to R21
R11.ipcore_ref.tlm.register_generator(sourcegen, mydest=R22.address, data=R11_testdata, startdelay=10, period=20)
R12.ipcore_ref.tlm.register_generator(sourcegen, mydest=R21.address, data=R12_testdata, startdelay=15, period=25)
R21.ipcore_ref.tlm.register_generator(checkgen, mysrc=R12.address, data=R12_testdata)
R22.ipcore_ref.tlm.register_generator(checkgen, mysrc=R11.address, data=R11_testdata)
# 6. configure simulation and run!
basicnoc.tlmsim.configure_simulation(max_time=1000)
print "Starting simulation..."
basicnoc.tlmsim.run()
print "Simulation finished. Pick the results in log files."
 
# 7. View graphical representation
 
draw_noc(basicnoc)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.