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: - 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.connect
instead.-
_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.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
andj
are the same. Otherwise returnNone
.
-
classmethod
_NetUtils__connect
(module, source, sink, **kwargs)¶ Connect
source
andsink
. This method should only be used inNetUtils.connect
andNetUtils._break_bits
because it doesn’t validatesource
orsink
.
-
classmethod
_NetUtils__pair_bitwise
(sources, sinks)¶
-
classmethod
_break_bits
(bus)¶ Break
bus
into bits and keep connections in sync. That is, ifbus
is a sink, the source connected to it is broken and connected bit-wisely.Parameters: bus ( Port
orPin
) –
-
classmethod
_dereference
(module, ref, *, byname=False)¶ Dereference
ref
inmodule
.Parameters: - module (
Module
) – - ref – Typically generated by
NetUtils._reference
Keyword Arguments: byname (
bool
) – If set,ref
is a string generated byNetUtils._reference
instead 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)¶ Slice
orAbstractNet
: Create a slice ofbus
.index
won’t be validated, so use with care.
-
classmethod
connect
(sources, sinks, *, fully=False, **kwargs)¶ Connect
sources
andsinks
.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 insources
is 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 fromsource
tosink
.Parameters: - type (
TimingArcType
orstr
) – 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 informationReturns: The created timing arc
Return type: - type (
-
classmethod
disconnect
(sources=None, sinks=None)¶ Disconnect
sources
andsinks
.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
orsinks
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
tosink
.Parameters: - source (
AbstractNonReferenceNet
) – - sink (
AbstractNonReferenceNet
) –
Keyword Arguments: - raise_error_if_unconnected (
bool
) – If set, this method raises aPRGAInternalError
if 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: NetConnection
orNone
- 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 toConst
for more information) placeholders.Examples
- Suppose module
m
does 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
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'])
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 aConst
object whensink
is not connected to any sources. Otherwise this method returnsNone
.Returns: Return type: AbstractNet
orNone
-
classmethod
get_timing_arcs
(*, source=None, sink=None, types=<enum 'TimingArcType'>)¶ Get the timing arc(s) of the specified
types
fromsource
tosink
.Keyword Arguments: - source (
AbstractNet
) – If not specified, all timing arcs tosink
are returned - sink (
AbstractNet
) – If not specified, all timing arcs fromsource
are returned - types (
TimingArcType
orContainer
[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.Object
Timing arcs.
Parameters: - type (
TimingArcType
orstr
) – 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
-sink
pair iftype_
isTimingArcType.comb_bitwise
,TimingArcType.seq_start
orTimingArcType.seq_end
. This is the setup value iftype_
isTimingArcType.seq_end
- max – Maximum values for each
source
-sink
pair iftype_
isTimingArcType.comb_matrix
. The 2D array should be index-able bysource
index first, thensink
index - 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 (