prga.netlist.net.util module¶
Utility methods for accessing nets.
-
class
prga.netlist.net.util.NetConnection(source, sink, **kwargs)¶ Bases:
prga.util.ObjectConnection between non-reference nets.
Parameters: - source (
AbstractNonReferenceNet) – The driver of this connection - sink (
AbstractNonReferenceNet) – The drivee of this connection
Keyword Arguments: **kwargs – Custom key-value arguments. These attributes are added to
__dict__of this object and accessible as dynamic attributesDirect instantiation of this class is not recommended. Use
NetUtils.connectinstead.-
_arc¶
-
_sink¶
-
_source¶
-
sink¶ The drivee of this connection.
Type: AbstractNonReferenceNet
-
source¶ The driver of this connection.
Type: AbstractNonReferenceNet
- source (
-
class
prga.netlist.net.util.NetUtils¶ Bases:
prga.util.ObjectA 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
iandjare the same. Otherwise returnNone.
-
classmethod
_NetUtils__connect(module, source, sink, **kwargs)¶ Connect
sourceandsink. This method should only be used inNetUtils.connectandNetUtils._break_bitsbecause it doesn’t validatesourceorsink.
-
classmethod
_NetUtils__pair_bitwise(sources, sinks)¶
-
classmethod
_break_bits(bus)¶ Break
businto bits and keep connections in sync. That is, ifbusis a sink, the source connected to it is broken and connected bit-wisely.Parameters: bus ( PortorPin) –
-
classmethod
_dereference(module, ref, *, byname=False)¶ Dereference
refinmodule.Parameters: - module (
Module) – - ref – Typically generated by
NetUtils._reference
Keyword Arguments: byname (
bool) – If set,refis a string generated byNetUtils._referenceinstead of a sequence of keysReturns: Return type: net (
AbstractNet)- module (
-
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 keysReturns: Return type: Sequence[Hashable] orstr
-
classmethod
_slice(bus, index)¶ SliceorAbstractNet: Create a slice ofbus.indexwon’t be validated, so use with care.
-
classmethod
connect(sources, sinks, *, fully=False, **kwargs)¶ Connect
sourcesandsinks.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 insourcesis connected to all bits insinks. - **kwargs – Custom attibutes assigned to all connections
-
classmethod
create_timing_arc(type_, source, sink, *, max_=None, min_=None)¶ Create a
type_-typed timing arc fromsourcetosink.Parameters: - type (
TimingArcTypeorstr) – 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
TimingArcfor more informationReturns: The created timing arc
Return type: - type (
-
classmethod
disconnect(sources=None, sinks=None)¶ Disconnect
sourcesandsinks.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
sourcesorsinksis 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
sourcetosink.Parameters: - source (
AbstractNonReferenceNet) – - sink (
AbstractNonReferenceNet) –
Keyword Arguments: - raise_error_if_unconnected (
bool) – If set, this method raises aPRGAInternalErrorif the specified nets are not connected. Otherwise, this method returnsNone. - skip_validations (
bool) – If set, this method skips all validations. This option saves runtime but should be used with care
Returns: Return type: NetConnectionorNone- source (
-
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 insource. The element may containunconnected(refer toConstfor more information) placeholders.Examples
- Suppose module
mdoes not support bit-wise connections (i.e.m.coalesce_connections = True), and portm.ports['i']drivesm.ports['o']andm.instances['sth'].pins['i']. Then,NetUtils.get_sinks(m.ports['i'])returnstuple(m.ports['o'], m.instances['sth'].pins['i']).NetUtils.get_sinks(m.ports['i'][0])returnstuple(m.ports['o'][0], m.instances['sth'].pins['i'][0]). - Suppose module
msupports 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'])returnstuple(m.ports['o'], Concat(Unconnected(1), m.instances['sth'].pins['i'][0])).
- Suppose module
-
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 aConstobject whensinkis not connected to any sources. Otherwise this method returnsNone.Returns: Return type: AbstractNetorNone
-
classmethod
get_timing_arcs(*, source=None, sink=None, types=<enum 'TimingArcType'>)¶ Get the timing arc(s) of the specified
typesfromsourcetosink.Keyword Arguments: - source (
AbstractNet) – If not specified, all timing arcs tosinkare returned - sink (
AbstractNet) – If not specified, all timing arcs fromsourceare returned - types (
TimingArcTypeorContainer[TimingArcType]) – Only return the specified type(s) of timing arcs
Returns: Return type: Sequence[TimingArc]- source (
-
classmethod
-
class
prga.netlist.net.util.TimingArc(type_, source, sink, *, max_=None, min_=None)¶ Bases:
prga.util.ObjectTiming arcs.
Parameters: - type (
TimingArcTypeorstr) – Type of this timing arc - source (
AbstractNonReferenceNet) – The combinational source or clock of this timing arc - sink (
AbstractNonReferenceNet) – The conbinational sink or sequential startpoint/endpoint of this timing arc
Keyword Arguments: - max (
list[list[float]]) – Maximum values for eachsource-sinkpair iftype_isTimingArcType.comb_bitwise,TimingArcType.seq_startorTimingArcType.seq_end. This is the setup value iftype_isTimingArcType.seq_end - max – Maximum values for each
source-sinkpair iftype_isTimingArcType.comb_matrix. The 2D array should be index-able bysourceindex first, thensinkindex - min – The minimum counterpart for the above maximum values. If
type_isTimingArcType.seq_end, this is the hold value
-
_max¶
-
_min¶
-
_sink¶
-
_source¶
-
_type¶
-
max_¶ The max/setup value(s) of this timing arc.
Type: list[float] orlist[list[float]]
-
min_¶ The min/hold value(s) of this timing arc.
Type: list[float] orlist[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
- type (