prga.netlist.net.util module

Utility methods for accessing nets.

class prga.netlist.net.util.NetConnection(source, sink, **kwargs)

Bases: prga.util.Object

Connection between non-reference nets.

Parameters:
Keyword Arguments:
 

**kwargs – Custom key-value arguments. These attributes are added to __dict__ of this object and accessible as dynamic attributes

Direct instantiation of this class is not recommended. Use NetUtils.connect instead.

_arc
_sink
_source
arc

Timing arc associated with this connection.

Type:TimingArc
sink

The drivee of this connection.

Type:AbstractNonReferenceNet
source

The driver of this connection.

Type:AbstractNonReferenceNet
class prga.netlist.net.util.NetUtils

Bases: prga.util.Object

A wrapper class for utility functions for nets.

classmethod _NetUtils__break_bits_if_needed(net)
classmethod _NetUtils__concat_append(l, i)
classmethod _NetUtils__concat_same(i, j)

Return the bus if i and j are the same. Otherwise return None.

classmethod _NetUtils__connect(module, source, sink, **kwargs)

Connect source and sink. This method should only be used in NetUtils.connect and NetUtils._break_bits because it doesn’t validate source or sink.

classmethod _NetUtils__pair_bitwise(sources, sinks)
classmethod _break_bits(bus)

Break bus into bits and keep connections in sync. That is, if bus is a sink, the source connected to it is broken and connected bit-wisely.

Parameters:bus (Port or Pin) –
classmethod _dereference(module, ref, *, byname=False)

Dereference ref in module.

Parameters:
Keyword Arguments:
 

byname (bool) – If set, ref is a string generated by NetUtils._reference instead of a sequence of keys

Returns:

Return type:

net (AbstractNet)

classmethod _reference(net, *, byname=False)

Get a hashable key for net.

Parameters:net (AbstractNet) –
Keyword Arguments:
 byname (bool) – If set, this method returns a string instead of a sequence of keys
Returns:
Return type:Sequence [Hashable ] or str
classmethod _slice(bus, index)

Slice or AbstractNet: Create a slice of bus.

index won’t be validated, so use with care.

classmethod concat(items)

Slice, Concat or other nets: Concatenate the provided iterable of nets.

classmethod connect(sources, sinks, *, fully=False, **kwargs)

Connect sources and sinks.

Parameters:
  • sources – a bus, a slice of a bus, a bit of a bus, or an iterable of the items listed above
  • sink – a bus, a slice of a bus, a bit of a bus, or an iterable of the items listed above
Keyword Arguments:
 
  • fully (bool) – If set, every bit in sources is connected to all bits in sinks.
  • **kwargs – Custom attibutes assigned to all connections
classmethod create_timing_arc(type_, source, sink, *, max_=None, min_=None)

Create a type_-typed timing arc from source to sink.

Parameters:
  • type (TimingArcType or str) – Type of the timing arc
  • source (Port) – An input port or a clock in a cell module
  • sink (Port) – A port in the same cell module
Keyword Arguments:
 

min (max,) – Refer to TimingArc for more information

Returns:

The created timing arc

Return type:

TimingArc

classmethod disconnect(sources=None, sinks=None)

Disconnect sources and sinks.

Parameters:
  • sources – a bus, a slice of a bus, a bit of a bus, or an iterable of the items listed above
  • sink – a bus, a slice of a bus, a bit of a bus, or an iterable of the items listed above

Notes

If either sources or sinks is not given, all connections are removed from/to the given parameter.

classmethod get_connection(source, sink, *, raise_error_if_unconnected=False, skip_validations=False)

Get the connection from source to sink.

Parameters:
Keyword Arguments:
 
  • raise_error_if_unconnected (bool) – If set, this method raises a PRGAInternalError if the specified nets are not connected. Otherwise, this method returns None.
  • skip_validations (bool) – If set, this method skips all validations. This option saves runtime but should be used with care
Returns:

Return type:

NetConnection or None

classmethod get_multisource(sink)

Get the sources connected to sink. This method is for accessing connections in modules that allow multi-source connections.

classmethod get_sinks(source)

Get the sinks connected to source. This method can be used whether the parent module allows multi-source connections or not, and whether the parent module supports bit-wise connections or not.

Parameters:source (AbstractNet) –
Returns:
Return type:Sequence [AbstractNet ]

This method returns a sequence of nets. Each element in the sequence has the same number of bits as source, and each bit is a sink driven by the corresponding bit in source. The element may contain unconnected (refer to Const for more information) placeholders.

Examples

  1. Suppose module m does not support bit-wise connections (i.e. m.coalesce_connections = True), and port m.ports['i'] drives m.ports['o'] and m.instances['sth'].pins['i']. Then, NetUtils.get_sinks(m.ports['i']) returns tuple(m.ports['o'], m.instances['sth'].pins['i']). NetUtils.get_sinks(m.ports['i'][0]) returns tuple(m.ports['o'][0], m.instances['sth'].pins['i'][0]).
  2. Suppose module m supports bit-wise connections (i.e. m.coalesce_connections = False), and the following connections exist: m.ports['i'][0] -> m.ports['o'][0], m.ports['i'][1] -> m.ports['o'][1], m.ports['i'][1] -> m.instances['sth'].pins['i'][0]. Then, NetUtils.get_sinks(m.ports['i']) returns tuple(m.ports['o'], Concat(Unconnected(1), m.instances['sth'].pins['i'][0])).
classmethod get_source(sink, *, return_const_if_unconnected=False)

Get the source connected to sink. This method is only for accessing connections in modules that do not allow multi-source connections.

Parameters:sink (AbstractNet) –
Keyword Arguments:
 return_const_if_unconnected (bool) – If set, this method returns a Const object when sink is not connected to any sources. Otherwise this method returns None.
Returns:
Return type:AbstractNet or None
classmethod get_timing_arcs(*, source=None, sink=None, types=<enum 'TimingArcType'>)

Get the timing arc(s) of the specified types from source to sink.

Keyword Arguments:
 
  • source (AbstractNet) – If not specified, all timing arcs to sink are returned
  • sink (AbstractNet) – If not specified, all timing arcs from source are returned
  • types (TimingArcType or Container [TimingArcType ]) – Only return the specified type(s) of timing arcs
Returns:

Return type:

Sequence [TimingArc]

class prga.netlist.net.util.TimingArc(type_, source, sink, *, max_=None, min_=None)

Bases: prga.util.Object

Timing arcs.

Parameters:
Keyword Arguments:
 
_max
_min
_sink
_source
_type
max_

The max/setup value(s) of this timing arc.

Type:list [float ] or list [list [float ]]
min_

The min/hold value(s) of this timing arc.

Type:list [float ] or list [list [float ]]
sink

The combinational sink or sequential startpoint/endpoint of this timing arc.

Type:AbstractNonReferenceNet
source

The combinational source or clock of this timing arc.

Type:AbstractNonReferenceNet
type_

Type of this timing arc.

Type:TimingArcType