Gate-level Layout¶
gate_level_layout<CoordinateLayout> places Boolean gates and wires on a coordinate layout.
The layout owns its clocking scheme, synchronization delays, and persistent obstructions.
Tile operations are available directly. Geometry remains a template argument; clocking
schemes and obstruction assignments do not change the layout type.
The layout represents logic placement and routing independently of a cell technology. A gate library supplies physical cell implementations and tile dimensions.
Each gate, wire, input, and output is a placed object with a generation-checked object_id.
Coordinates describe positions; IDs describe objects and their single output; an input_port
names the object and the truth-table argument where a connection enters. Wires and fanouts
are explicit objects. An empty layout contains no objects or implicit constants.
A sink is a destination input port driven by a source object’s output. foreach_sink(source, fn)
in C++ and sinks(source) in Python report each port as the destination object and its input index.
If a source drives inputs 0 and 2 of one gate, both ports are sinks. fanout_size(source) counts
these ports, and foreach_fanout visits the destination once per connected port. Sink order is
unspecified, and declared connections need not satisfy physical adjacency or clocking.
is_wire, foreach_wire, and num_wires identify physical wire objects and exclude PIs and POs.
Python’s wires() returns the same objects. is_buf identifies the identity function, including terminals;
is_fanout identifies identity objects that drive more than one input port. num_gates excludes wires and terminals.
Use find_object(tile) to look up an occupied coordinate and get_tile(id) to read an object’s
position. Moving an object preserves its ID and connections. Creation and movement reject an
occupied coordinate. Removing an object disconnects its destinations without renumbering their
input ports. IDs are local to a layout; removing and recreating an object invalidates its old ID.
Editing permits disconnected input ports, cycles, and placement outside the frame. Design-rule
checks validate adjacency, clocking, and frame membership separately. Algorithms that need a
mockturtle network use fiction::networks::extract_layout_network: extraction retains every PI
in declared order and visits only output dependency cones. A missing input or cycle in an output
cone raises an error. Unused PIs and disconnected logic outside those cones do not prevent extraction.
Header: fiction/layouts/gate_level_layout.hpp
-
template<typename CoordinateLayout>
class gate_level_layout : public CoordinateLayout¶ Placed FCN objects, ordered ports, clocking, and obstructions.
Objects have stable identities independent of their coordinates. Connections describe declared topology; physical validation checks adjacency, clocking, and geometry separately. Copies own independent state. A sink is a destination input port driven by a source object’s output. One destination object may receive the same source at several input indices; each connected input port is a distinct sink. Visitors may edit coordinates, names, and capabilities. Object and terminal visitors must not create or remove objects, change terminal order, or replace the layout during traversal. Connection visitors must also preserve the traversed input or sink connections, as specified on each visitor.
- Template Parameters:
CoordinateLayout – Coordinate geometry used for placement.
Public Types
-
using clock_zone = layout_base::coordinate¶
Coordinate identifying a clock zone.
-
using clock_number_t = typename clocking_scheme_t::clock_number¶
Clock phase.
-
using degree_t = uint8_t¶
Number of clocked neighbors.
-
using sync_elem_t = clocking::state::sync_elem_t¶
Hold extension in full cycles.
-
using tile = layout_base::coordinate¶
Placement coordinate.
-
using object_id = layout_object_id¶
Stable layout-local identity.
-
using input_port = layout_input_port¶
Ordered destination endpoint.
-
using base_type = gate_level_layout¶
Concrete layout type.
Public Functions
-
inline explicit gate_level_layout(const layout_base::extent &size = {}, std::string name = {})¶
Creates an empty layout with the given geometry and name.
-
inline gate_level_layout(const layout_base::extent &size, const clocking::scheme &scheme, const std::string &name = {})¶
Creates an empty layout with the given geometry, clocking, and name.
-
inline explicit gate_level_layout(const layouts::arrangement a, const layout_base::extent &size = {}, std::string name = {})¶
Creates an empty layout with shifted rows or columns.
-
inline gate_level_layout(const layouts::arrangement a, const layout_base::extent &size, const clocking::scheme &scheme, const std::string &name = {})¶
Creates an empty layout with shifted rows or columns and clocking.
-
inline explicit gate_level_layout(const CoordinateLayout &geometry)¶
Creates an empty layout with an independent copy of the geometry.
-
inline gate_level_layout(const gate_level_layout &other)¶
Copies geometry, identities, connections, and owned capabilities independently.
-
inline gate_level_layout &operator=(const gate_level_layout &other)¶
Replaces this layout with an independent value copy.
-
inline gate_level_layout(gate_level_layout &&other)¶
Moves owned state and leaves an empty reusable source with its original geometry.
Note
Exceptions from cloning or constructing the coordinate geometry propagate to the caller.
-
inline gate_level_layout &operator=(gate_level_layout &&other)¶
Moves owned state and leaves an empty reusable source.
Note
Geometry failures preserve both operands’ owned state. The destination geometry follows CoordinateLayout’s assignment guarantee. Exceptions from geometry operations propagate to the caller.
-
~gate_level_layout() = default¶
Releases owned layout state.
-
inline gate_level_layout clone() const¶
Returns an independent value copy.
-
inline object_id create_pi(const std::string &name, const tile &t)¶
Creates a primary input at
t. Occupied coordinates reject without mutation.
-
inline object_id create_po(const object_id s, const std::string &name, const tile &t)¶
Creates a primary output driven by
satt.
-
inline object_id create_po(const std::string &name, const tile &t)¶
Creates a primary output with its input disconnected.
-
inline object_id create_and(const object_id a, const object_id b, const tile &t)¶
Creates a AND gate.
-
inline object_id create_nand(const object_id a, const object_id b, const tile &t)¶
Creates a NAND gate.
-
inline object_id create_nor(const object_id a, const object_id b, const tile &t)¶
Creates a NOR gate.
-
inline object_id create_xor(const object_id a, const object_id b, const tile &t)¶
Creates a XOR gate.
-
inline object_id create_xnor(const object_id a, const object_id b, const tile &t)¶
Creates a XNOR gate.
-
inline object_id create_maj(const object_id a, const object_id b, const object_id c, const tile &t)¶
Creates a majority gate.
-
inline object_id create_gate(const std::vector<object_id> &children, const kitty::dynamic_truth_table &function, const tile &t)¶
Creates a gate with an ordered truth table and initial input connections.
Unspecified trailing inputs remain disconnected. Constant functions require an explicit placed object.
- Throws:
std::invalid_argument – If placement is occupied, or children exceed the function arity.
-
inline bool contains(const object_id id) const noexcept¶
Returns whether this identity names a live object.
-
inline std::optional<object_id> find_object(const tile &t) const noexcept¶
Finds the object at a coordinate; empty coordinates have no identity.
-
inline tile get_tile(const object_id id) const¶
Returns the object’s coordinate.
- Throws:
std::invalid_argument – If the identity is stale.
-
inline kitty::dynamic_truth_table object_function(const object_id id) const¶
Returns the truth table in logical input-index order.
-
inline uint32_t input_count(const object_id id) const¶
Returns the number of input slots, including disconnected slots.
-
inline std::optional<object_id> source(const input_port port) const¶
Returns the declared source of an input, or no source if disconnected.
-
inline void connect(const object_id src, const input_port dst)¶
Connects an output to an ordered input, replacing the input’s existing source.
Port and identity checks precede mutation. Adjacency, clocking, and geometry need not be valid during editing.
-
inline void disconnect(const input_port port)¶
Disconnects one input without changing the indices of other inputs.
-
inline object_id move_object(const object_id id, const tile &t)¶
Moves an object without changing its identity or connections.
-
inline void remove(const object_id id)¶
Removes an object and disconnects all inputs and sinks. Stale identities reject.
-
inline uint32_t size() const noexcept¶
Counts live objects.
-
inline uint32_t num_pis() const noexcept¶
Counts primary inputs.
-
inline uint32_t num_pos() const noexcept¶
Counts primary outputs.
-
inline uint32_t num_gates() const noexcept¶
Counts logic gates, excluding wires and terminals.
-
inline uint32_t num_wires() const noexcept¶
Counts physical wires, excluding primary inputs and outputs.
-
inline bool is_empty() const noexcept¶
Returns whether the layout has no objects.
-
inline uint32_t num_crossings() const noexcept¶
Counts crossing-layer wires above occupied ground-layer tiles.
-
inline uint32_t fanin_size(const object_id id) const¶
Counts connected input slots, irrespective of physical legality.
-
inline uint32_t fanout_size(const object_id id) const¶
Counts destination input ports driven by this object’s output. Each connected input port is a sink, including multiple ports on the same destination object.
-
inline object_id pi_at(const uint32_t index) const¶
Returns a primary input in declared interface order.
-
inline object_id po_at(const uint32_t index) const¶
Returns a primary output in declared interface order.
-
inline void set_input_order(const std::span<const object_id> order)¶
Sets the complete input permutation. Invalid orders reject without mutation.
-
inline void set_output_order(const std::span<const object_id> order)¶
Sets the complete output permutation. Invalid orders reject without mutation.
-
inline bool is_gate(const object_id id) const¶
Returns whether an object is a logic gate rather than a wire or terminal.
-
inline bool is_buf(const object_id id) const¶
Returns whether an object computes the identity function.
-
inline bool is_wire(const object_id id) const¶
Returns whether an object is a physical wire rather than a terminal.
-
inline bool is_fanout(const object_id id) const¶
Returns whether an identity object drives more than one input port.
-
inline bool is_empty_tile(const tile &t) const noexcept¶
Returns whether a coordinate has no occupant.
-
template<typename Fn>
inline void foreach_object(Fn &&fn) const¶ Visits live objects. Callbacks may accept an object and enumeration index and return false to stop. Callbacks must not create or remove objects, change terminal order, or replace the layout. Traversal scans one bitmap word per 64 retained slots and visits each live object.
-
template<typename Fn>
inline void foreach_pi(Fn &&fn) const¶ Visits primary inputs in declared interface order. Callbacks must not create or remove objects, change terminal order, or replace the layout.
-
template<typename Fn>
inline void foreach_po(Fn &&fn) const¶ Visits primary outputs in declared interface order. Callbacks must not create or remove objects, change terminal order, or replace the layout.
-
template<typename Fn>
inline void foreach_gate(Fn &&fn) const¶ Visits logic gates. Callbacks must not create or remove objects, change terminal order, or replace the layout.
-
template<typename Fn>
inline void foreach_wire(Fn &&fn) const¶ Visits physical wires, excluding primary inputs and outputs. Callbacks must not create or remove objects, change terminal order, or replace the layout.
-
template<typename Fn>
inline void foreach_fanin(const object_id id, Fn &&fn) const¶ Visits declared sources in input-index order. Disconnected inputs retain their indices. Callbacks must not remove the traversed object or change its input connections.
-
template<typename Fn>
inline void foreach_sink(const object_id src, Fn &&fn) const¶ Visits destination input ports driven by the source object’s output. Each sink is an
input_portnaming a destination object and its truth-table argument index. Connecting one source to several inputs of the same destination yields a sink for each input. Connections need not be physically legal, and sink order is unspecified. Callbacks must not remove the source object or change its sink connections.- Parameters:
src – Source object whose output drives the visited input ports.
fn – Callable accepting an input port and optionally its traversal index.
-
template<typename Fn>
inline void foreach_fanout(const object_id id, Fn &&fn) const¶ Visits destination objects once per connected input port in unspecified order.
-
template<bool RespectClocking = true>
inline std::vector<tile> incoming_data_flow(const tile &t) const¶ Returns coordinates of declared sources; optionally filters physical clocking and adjacency.
-
template<bool RespectClocking = true>
inline std::vector<tile> outgoing_data_flow(const tile &t) const¶ Returns adjacent destination coordinates once per connected input port. Multiple connected inputs on one destination yield repeated coordinates.
- Template Parameters:
RespectClocking – Require outgoing clocking in addition to adjacency; enabled by default.
- Parameters:
t – Source-object coordinate.
- Returns:
Destination coordinates of the selected connections, in unspecified order.
-
inline std::string get_name(const object_id id) const¶
Returns an object’s name, or an empty string for an unnamed object.
-
inline std::string get_input_name(const uint32_t index) const¶
Returns the input name at an interface index.
-
inline void set_input_name(const uint32_t index, const std::string &name)¶
Sets the input name at an interface index.
-
inline bool has_input_name(const uint32_t index) const¶
Returns whether an input has a name.
-
inline std::string get_output_name(const uint32_t index) const¶
Returns the output name at an interface index.
-
inline void set_output_name(const uint32_t index, const std::string &name)¶
Sets the output name at an interface index.
-
inline bool has_output_name(const uint32_t index) const¶
Returns whether an output has a name.
-
inline std::string get_layout_name() const¶
Returns the layout name.
-
inline void set_layout_name(const std::string &name)¶
Sets the layout name.
-
template<bool RespectClocking = true>
inline bool is_incoming_signal(const tile &t, const std::optional<tile> &source_tile) const¶ Checks for a physical incoming connection from the given x/y location.
-
template<bool RespectClocking = true>
inline bool is_outgoing_signal(const tile &t, const std::optional<tile> &target_tile) const¶ Checks for a physical outgoing connection to the given x/y location.
-
template<bool RespectClocking = true>
inline bool has_northern_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in northern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffnorth(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_north_eastern_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in north-eastern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffnorth_east(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_eastern_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in eastern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffeast(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_south_eastern_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in south-eastern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffsouth_east(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_southern_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in southern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffsouth(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_south_western_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in south-western direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffsouth_west(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_western_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in western direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffwest(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_north_western_incoming_signal(const tile &t) const¶ Checks whether the given tile has an incoming one in north-western direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueiffnorth_west(t)is incoming tot.
-
template<bool RespectClocking = true>
inline bool has_no_incoming_signal(const tile &t) const¶ Checks whether the given tile has no incoming tiles.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Parameters:
t – Base tile.
- Returns:
trueifftdoes not have incoming tiles.
-
template<bool RespectClocking = true>
inline bool has_northern_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in northern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffnorth(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_north_eastern_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in north-eastern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffnorth_east(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_eastern_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in eastern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffeast(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_south_eastern_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in south-eastern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffsouth_east(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_southern_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in southern direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffsouth(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_south_western_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in south-western direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffsouth_west(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_western_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in western direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffwest(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_north_western_outgoing_signal(const tile &t) const¶ Checks whether the given tile has an outgoing one in north-western direction.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueiffnorth_west(t)is outgoing fromt.
-
template<bool RespectClocking = true>
inline bool has_no_outgoing_signal(const tile &t) const¶ Checks whether the given tile has no outgoing tiles.
- Template Parameters:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Parameters:
t – Base tile.
- Returns:
trueifftdoes not have outgoing tiles.
-
template<bool RespectClocking = true>
inline bool has_opposite_incoming_and_outgoing_signals(const tile &t) const¶ Checks whether incoming and outgoing signals lie on opposite sides of
t.Uses
foreach_adjacent_opposite_coordinatesof the underlying coordinate layout.- Template Parameters:
RespectClocking – Whether signal queries respect the clocking scheme.
- Parameters:
t – Base tile.
- Returns:
Whether
thas incoming and outgoing signals on opposite sides.
-
inline void replace_clocking_scheme(const clocking_scheme_t &scheme)¶
Replaces the stored clocking scheme with the provided one.
- Parameters:
scheme – New clocking scheme.
-
inline void assign_clock_number(const clock_zone &cz, const clock_number_t cn)¶
Overrides the clock number of a tile in the stored scheme. The clock number applies to every layer of the tile, so the z-coordinate of
czis ignored.- Parameters:
cz – Clock zone to override.
cn – New clock number for
cz.
-
inline clock_number_t get_clock_number(const clock_zone &cz) const¶
Returns the clock number of a tile. Every layer of a tile has the same clock number, so the z-coordinate of
czis ignored.- Parameters:
cz – Clock zone.
- Returns:
Clock number of
cz.
-
inline clock_number_t num_clocks() const¶
Returns the number of clock phases in the layout. Each clock cycle is divided into n phases. In QCA, the number of phases is usually 4. In iNML it is 3. Clocking schemes support 3 or 4 phases.
- Returns:
The number of different clock signals in the layout.
-
inline bool is_regularly_clocked() const¶
Returns whether the layout is clocked by a regular clocking scheme with no overwritten zones.
- Returns:
trueiff the layout is clocked by a regular scheme and no zones have been overwritten.
-
inline bool is_clocking_scheme(const std::string_view &name) const¶
Compares the stored clocking scheme against the provided name. Predefined names are constants in
fiction::layouts::clocking.- Parameters:
name – Clocking scheme name.
- Returns:
trueiff the layout is clocked by a clocking scheme of namename.
-
inline const clocking_scheme_t &get_clocking_scheme() const noexcept¶
Returns a read-only reference to the stored clocking scheme object. Clock overrides and scheme replacements update the referenced object. Assignment or moving from the layout replaces the referenced contents; the reference stays attached to the layout that supplied it.
- Returns:
A reference valid for the lifetime of this layout.
-
inline bool is_incoming_clocked(const clock_zone &cz1, const clock_zone &cz2) const¶
Evaluates whether clock zone
cz2feeds information to clock zonecz1, i.e., whethercz2is clocked with a clock number that is lower by 1 modulonum_clocks(), or either zone is a synchronization element.- Parameters:
cz1 – Base clock zone.
cz2 – Clock zone to check whether its clock number is lower by 1.
- Returns:
trueiffcz2can feed information tocz1.
-
inline bool is_outgoing_clocked(const clock_zone &cz1, const clock_zone &cz2) const¶
Evaluates whether clock zone
cz2accepts information from clock zonecz1, i.e., whethercz2is clocked with a clock number that is higher by 1 modulonum_clocks(), or either zone is a synchronization element.- Parameters:
cz1 – Base clock zone.
cz2 – Clock zone to check whether its clock number is higher by 1.
- Returns:
trueiffcz2can accept information fromcz1.
-
inline void assign_synchronization_element(const clock_zone &cz, const sync_elem_t se)¶
Assigns a synchronization element to the provided clock zone.
- Parameters:
cz – Clock zone to turn into a synchronization element.
se – Number of full clock cycles to extend
cz’s Hold phase by. If this value is 0,czis turned back into a normal clock zone.
-
inline bool is_synchronization_element(const clock_zone &cz) const¶
Check whether the provided clock zone is a synchronization element.
- Parameters:
cz – Clock zone to check.
- Returns:
trueiffczis a synchronization element.
-
inline sync_elem_t get_synchronization_element(const clock_zone &cz) const¶
Returns the Hold phase extension in clock cycles of clock zone
cz.- Parameters:
cz – Clock zone to check.
- Returns:
Synchronization element value, i.e., Hold phase extension, of clock zone
cz.
-
inline uint32_t num_se() const¶
Counts zones with a nonzero Hold-phase extension.
- Returns:
Synchronization element count.
-
inline void obstruct_coordinate(const clock_zone &c)¶
Marks the given coordinate as obstructed.
- Parameters:
c – clock_zone to obstruct.
-
inline void obstruct_connection(const clock_zone &src, const clock_zone &tgt)¶
Marks the connection from coordinate
srcto coordinatetgtas obstructed.Note
clock_zones marked this way will not be crossed with wires by path finding algorithms.
- Parameters:
src – Source coordinate.
tgt – Target coordinate.
-
inline void clear_obstructed_coordinate(const clock_zone &c)¶
Clears the obstruction status of the given coordinate
cif the obstruction was manually marked viaobstruct_coordinate.- Parameters:
c – clock_zone to clear.
-
inline void clear_obstructed_connection(const clock_zone &src, const clock_zone &tgt)¶
Clears the obstruction status of the connection from coordinate
srcto coordinatetgtif the obstruction was manually marked viaobstruct_connection.- Parameters:
src – Source coordinate.
tgt – Target coordinate.
-
inline void clear_obstructed_coordinates()¶
Clears all obstructed coordinates that were manually marked via
obstruct_coordinate.
-
inline void clear_obstructed_connections()¶
Clears all obstructed connections that were manually marked via
obstruct_connection.
-
template<typename Fn>
inline void foreach_obstructed_coordinate(Fn &&fn) const¶ Visits manual coordinate obstructions without implicit occupancy.
- Template Parameters:
Fn – Callable accepting one coordinate.
- Parameters:
fn – Callback for each manual obstruction.
-
template<typename Fn>
inline void foreach_obstructed_connection(Fn &&fn) const¶ Visits manual directed-connection obstructions without implicit physical connections.
- Template Parameters:
Fn – Callable accepting source and target coordinates.
- Parameters:
fn – Callback for each manual obstruction.
-
inline bool is_obstructed_coordinate(const clock_zone &c) const¶
Checks if the given coordinate is obstructed of some sort.
- Parameters:
c – Coordinate to check.
- Returns:
trueiffcis obstructed.
-
inline bool is_obstructed_connection(const clock_zone &src, const clock_zone &tgt) const¶
Checks if the given coordinate-coordinate connection is obstructed of some sort.
- Parameters:
src – Source coordinate.
tgt – Target coordinate.
- Returns:
trueiff the connection fromsrctotgtis obstructed.
-
inline auto incoming_clocked_zones(const clock_zone &cz) const¶
Returns a container with all clock zones that are incoming to the given one.
- Parameters:
cz – Base clock zone.
- Returns:
A container with all clock zones that are incoming to
cz.
-
template<typename Fn>
inline void foreach_incoming_clocked_zone(const clock_zone &cz, Fn &&fn) const¶ Applies a function as an lvalue to all incoming clock zones of a given one.
- Template Parameters:
Fn – Functor type.
- Parameters:
cz – Base clock zone.
fn – Functor to apply to each of
cz’s incoming clock zones.
-
inline auto outgoing_clocked_zones(const clock_zone &cz) const¶
Returns a container with all clock zones that are outgoing from the given one.
- Parameters:
cz – Base clock zone.
- Returns:
A container with all clock zones that are outgoing from
cz.
-
template<typename Fn>
inline void foreach_outgoing_clocked_zone(const clock_zone &cz, Fn &&fn) const¶ Applies a function as an lvalue to all outgoing clock zones of a given one.
- Template Parameters:
Fn – Functor type.
- Parameters:
cz – Base clock zone.
fn – Functor to apply to each of
cz’s outgoing clock zones.
-
inline degree_t in_degree(const clock_zone &cz) const¶
Returns the number of incoming clock zones to the given one.
- Parameters:
cz – Base clock zone.
- Returns:
Number of
cz’s incoming clock zones.
-
inline degree_t out_degree(const clock_zone &cz) const¶
Returns the number of outgoing clock zones from the given one.
- Parameters:
cz – Base clock zone.
- Returns:
Number of
cz’s outgoing clock zones.
-
inline degree_t degree(const clock_zone &cz) const¶
Returns the number of distinct incoming or outgoing neighboring clock zones.
- Parameters:
cz – Base clock zone.
- Returns:
Number of distinct clocked neighbors of
cz.
-
inline auto tiles(const std::optional<tile> &start = std::nullopt, const std::optional<tile> &stop = std::nullopt) const¶
Returns the tiles in the coordinate range.
- Parameters:
start – First tile.
stop – Exclusive end tile; absence selects the layout end.
- Returns:
Tile range.
-
template<typename Fn>
inline void foreach_tile(Fn &&fn, const std::optional<tile> &start = std::nullopt, const std::optional<tile> &stop = std::nullopt) const¶ Applies a function to each tile in the coordinate range.
- Template Parameters:
Fn – Functor type.
- Parameters:
fn – Functor applied to each tile.
start – First tile.
stop – Exclusive end tile; absence selects the layout end.
-
inline auto ground_tiles(const std::optional<tile> &start = std::nullopt, const std::optional<tile> &stop = std::nullopt) const¶
Returns ground-layer tiles in the coordinate range.
- Parameters:
start – First tile.
stop – Exclusive end tile; absence selects the layout end.
- Returns:
Tile range.
-
template<typename Fn>
inline void foreach_ground_tile(Fn &&fn, const std::optional<tile> &start = std::nullopt, const std::optional<tile> &stop = std::nullopt) const¶ Applies a function to each ground-layer tile in the coordinate range.
- Template Parameters:
Fn – Functor type.
- Parameters:
fn – Functor applied to each tile.
start – First tile.
stop – Exclusive end tile; absence selects the layout end.
-
inline std::vector<tile> adjacent_tiles(const tile &t) const¶
Returns adjacent tiles.
- Parameters:
t – Base tile.
- Returns:
Adjacent tiles in the coordinate geometry.
-
template<typename Fn>
inline void foreach_adjacent_tile(const tile &t, Fn &&fn) const¶ Applies a function to each adjacent tile.
- Template Parameters:
Fn – Functor type.
- Parameters:
t – Base tile.
fn – Functor applied to adjacent tiles.
-
inline std::vector<std::pair<tile, tile>> adjacent_opposite_tiles(const tile &t) const¶
Returns pairs of opposite adjacent tiles.
- Parameters:
t – Base tile.
- Returns:
Adjacent tiles in the coordinate geometry.
- class cartesian_gate_layout¶
- class cartesian_gate_layout(extent: extent | tuple[int, int] | tuple[int, int, int])
- class cartesian_gate_layout(extent: extent | tuple[int, int] | tuple[int, int, int], clocking_scheme: str = '2DDWave', layout_name: str = '')
Placed FCN objects, ordered ports, clocking, and obstructions.
Objects have stable identities independent of their coordinates. Connections describe declared topology; physical validation checks adjacency, clocking, and geometry separately. Copies own independent state. A sink is a destination input port driven by a source object’s output. One destination object may receive the same source at several input indices; each connected input port is a distinct sink. Visitors may edit coordinates, names, and capabilities. Object and terminal visitors must not create or remove objects, change terminal order, or replace the layout during traversal. Connection visitors must also preserve the traversed input or sink connections, as specified on each visitor.
- Template Args:
CoordinateLayout – Coordinate geometry used for placement.
- assign_clock_number(cz: coordinate | tuple[int, int] | tuple[int, int, int], cn: int) None¶
Overrides the clock number of a tile in the stored scheme. The clock number applies to every layer of the tile, so the z-coordinate of
czis ignored.- Parameters:
cz – Clock zone to override.
cn – New clock number for
cz.
- assign_synchronization_element(coordinate: coordinate | tuple[int, int] | tuple[int, int, int], delay: int) None¶
Assigns a synchronization element to the provided clock zone.
- Parameters:
cz – Clock zone to turn into a synchronization element.
se – Number of full clock cycles to extend
cz’s Hold phase by. If this value is 0,czis turned back into a normal clock zone.
- bounding_box() tuple[coordinate | None, coordinate | None]¶
Returns the minimum and maximum corner of the bounding box. A 2D bounding box object computes a minimum-sized box around all non-empty coordinates in a given layout. Layouts can be of arbitrary size and, thus, may be larger than their contained elements. Sometimes, it might be necessary to know exactly which space the associated layout internals occupy. A bounding box computes coordinates that span a minimum-sized rectangle that encloses all non- empty layout coordinates.
- Returns:
The minimum and maximum enclosing coordinate in the associated layout.
- clear_obstructed_connection(src: coordinate | tuple[int, int] | tuple[int, int, int], tgt: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Clears the obstruction status of the connection from coordinate
srcto coordinatetgtif the obstruction was manually marked viaobstruct_connection.- Parameters:
src – Source coordinate.
tgt – Target coordinate.
- clear_obstructed_connections() None¶
Clears all obstructed connections that were manually marked via
obstruct_connection.
- clear_obstructed_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Clears the obstruction status of the given coordinate
cif the obstruction was manually marked viaobstruct_coordinate.- Parameters:
c – clock_zone to clear.
- clear_obstructed_coordinates() None¶
Clears all obstructed coordinates that were manually marked via
obstruct_coordinate.
- clear_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Removes the occupant of a coordinate if present.
- clone() cartesian_gate_layout¶
Returns an independent value copy.
- connect(source: mnt.pyfiction.layouts.layout_object_id, input: mnt.pyfiction.layouts.layout_input_port) None¶
Connects an output to an ordered input, replacing the input’s existing source.
Port and identity checks precede mutation. Adjacency, clocking, and geometry need not be valid during editing.
- contains(object: mnt.pyfiction.layouts.layout_object_id) bool¶
Returns whether this identity names a live object.
- create_and(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a AND gate.
- create_buf(a: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
- create_buf(t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id
Overloaded function.
create_buf(self, a: mnt.pyfiction.layouts.layout_object_id, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a wire driven by
a.create_buf(self, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a wire with its input disconnected.
- create_gate(inputs: Sequence[layout_object_id], function: mnt.pyfiction.synthesis.dynamic_truth_table, t: coordinate | tuple[int, int] | tuple[int, int, int]) layout_object_id¶
Creates a placed gate. Input indices follow truth-table variable order; trailing inputs may be disconnected.
- create_ge(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a GE gate.
- create_gt(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a GT gate.
- create_le(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a LE gate.
- create_lt(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a LT gate.
- create_maj(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, c: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a majority gate.
- create_nand(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a NAND gate.
- create_nor(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a NOR gate.
- create_not(a: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a NOT gate.
- create_or(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a OR gate.
- create_pi(name: str, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a primary input at
t. Occupied coordinates reject without mutation.
- create_po(s: mnt.pyfiction.layouts.layout_object_id, name: str, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
- create_po(name: str, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id
Overloaded function.
create_po(self, s: mnt.pyfiction.layouts.layout_object_id, name: str, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a primary output driven by
satt.create_po(self, name: str, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a primary output with its input disconnected.
- create_xnor(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a XNOR gate.
- create_xor(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a XOR gate.
- degree(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the number of distinct incoming or outgoing neighboring clock zones.
- Parameters:
cz – Base clock zone.
- Returns:
Number of distinct clocked neighbors of
cz.
- disconnect(input: mnt.pyfiction.layouts.layout_input_port) None¶
Disconnects one input without changing the indices of other inputs.
- fanin_size(object: mnt.pyfiction.layouts.layout_object_id) int¶
Counts connected input slots, irrespective of physical legality.
- fanout_size(object: mnt.pyfiction.layouts.layout_object_id) int¶
Counts destination input ports driven by this object’s output.
Each connected input port is a sink, including multiple ports on the same destination object.
- find_object(t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id | None¶
Finds the object at a coordinate; empty coordinates have no identity.
- get_clock_number(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the clock number of a tile. Every layer of a tile has the same clock number, so the z-coordinate of
czis ignored.- Parameters:
cz – Clock zone.
- Returns:
Clock number of
cz.
- get_clocking_scheme_name() str¶
Returns the name of the layout’s clocking scheme, e.g.,
2DDWaveorUSE.
- get_name(object: mnt.pyfiction.layouts.layout_object_id) str¶
Returns an object’s name, or an empty string for an unnamed object.
- get_synchronization_element(coordinate: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the Hold phase extension in clock cycles of clock zone
cz.- Parameters:
cz – Clock zone to check.
- Returns:
Synchronization element value, i.e., Hold phase extension, of clock zone
cz.
- get_tile(object: mnt.pyfiction.layouts.layout_object_id) coordinate¶
Returns the object’s coordinate. @throws std::invalid_argument If the identity is stale.
- has_eastern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffeast(t)is incoming tot.
- has_eastern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffeast(t)is outgoing fromt.
- has_no_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has no incoming tiles.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueifftdoes not have incoming tiles.
- has_no_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has no outgoing tiles.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueifftdoes not have outgoing tiles.
- has_north_eastern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in north-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffnorth_east(t)is incoming tot.
- has_north_eastern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in north-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffnorth_east(t)is outgoing fromt.
- has_north_western_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in north-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffnorth_west(t)is incoming tot.
- has_north_western_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in north-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffnorth_west(t)is outgoing fromt.
- has_northern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in northern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffnorth(t)is incoming tot.
- has_northern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in northern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffnorth(t)is outgoing fromt.
- has_south_eastern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in south-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffsouth_east(t)is incoming tot.
- has_south_eastern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in south-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffsouth_east(t)is outgoing fromt.
- has_south_western_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in south-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffsouth_west(t)is incoming tot.
- has_south_western_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in south-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffsouth_west(t)is outgoing fromt.
- has_southern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in southern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffsouth(t)is incoming tot.
- has_southern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in southern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffsouth(t)is outgoing fromt.
- has_western_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffwest(t)is incoming tot.
- has_western_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffwest(t)is outgoing fromt.
- in_degree(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the number of incoming clock zones to the given one.
- Parameters:
cz – Base clock zone.
- Returns:
Number of
cz’s incoming clock zones.
- incoming_clocked_zones(cz: coordinate | tuple[int, int] | tuple[int, int, int]) list[coordinate]¶
Returns a container with all clock zones that are incoming to the given one.
- Parameters:
cz – Base clock zone.
- Returns:
A container with all clock zones that are incoming to
cz.
- input_count(object: mnt.pyfiction.layouts.layout_object_id) int¶
Returns the number of input slots, including disconnected slots.
- inputs(object: mnt.pyfiction.layouts.layout_object_id) list[mnt.pyfiction.layouts.layout_object_id | None]¶
Returns input sources in port-index order, including None for disconnected ports.
- is_and(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes AND.
- is_buf(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether an object computes the identity function.
- is_clocking_scheme(name: str) bool¶
Compares the stored clocking scheme against the provided name. Predefined names are constants in
fiction::layouts::clocking.- Parameters:
name – Clocking scheme name.
- Returns:
trueiff the layout is clocked by a clocking scheme of namename.
- is_empty_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether a coordinate has no occupant.
- is_fanout(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether an identity object drives more than one input port.
- is_gate_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a gate.
- is_incoming_clocked(cz1: coordinate | tuple[int, int] | tuple[int, int, int], cz2: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Evaluates whether clock zone
cz2feeds information to clock zonecz1, i.e., whethercz2is clocked with a clock number that is lower by 1 modulonum_clocks(), or either zone is a synchronization element.- Parameters:
cz1 – Base clock zone.
cz2 – Clock zone to check whether its clock number is lower by 1.
- Returns:
trueiffcz2can feed information tocz1.
- is_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int], s: coordinate | tuple[int, int] | tuple[int, int, int] | None) bool¶
Checks for a physical incoming connection from the given x/y location.
- is_inv(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes INV.
- is_maj(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes MAJ.
- is_nand(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes NAND.
- is_nor(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes NOR.
- is_obstructed_connection(src: coordinate | tuple[int, int] | tuple[int, int, int], tgt: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks if the given coordinate-coordinate connection is obstructed of some sort.
- Parameters:
src – Source coordinate.
tgt – Target coordinate.
- Returns:
trueiff the connection fromsrctotgtis obstructed.
- is_obstructed_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks if the given coordinate is obstructed of some sort.
- Parameters:
c – Coordinate to check.
- Returns:
trueiffcis obstructed.
- is_outgoing_clocked(cz1: coordinate | tuple[int, int] | tuple[int, int, int], cz2: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Evaluates whether clock zone
cz2accepts information from clock zonecz1, i.e., whethercz2is clocked with a clock number that is higher by 1 modulonum_clocks(), or either zone is a synchronization element.- Parameters:
cz1 – Base clock zone.
cz2 – Clock zone to check whether its clock number is higher by 1.
- Returns:
trueiffcz2can accept information fromcz1.
- is_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int], s: coordinate | tuple[int, int] | tuple[int, int, int] | None) bool¶
Checks for a physical outgoing connection to the given x/y location.
- is_pi(n: mnt.pyfiction.layouts.layout_object_id) bool¶
Returns whether an object is a primary input.
- is_pi_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a pi.
- is_po(n: mnt.pyfiction.layouts.layout_object_id) bool¶
Returns whether an object is a primary output.
- is_po_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a po.
- is_regularly_clocked() bool¶
Returns whether the layout is clocked by a regular clocking scheme with no overwritten zones.
- Returns:
trueiff the layout is clocked by a regular scheme and no zones have been overwritten.
- is_synchronization_element(coordinate: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Check whether the provided clock zone is a synchronization element.
- Parameters:
cz – Clock zone to check.
- Returns:
trueiffczis a synchronization element.
- is_wire(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether an object is a physical wire rather than a terminal.
- is_wire_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a wire.
- is_xnor(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes XNOR.
- is_xor(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes XOR.
- move_object(object: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Moves an object without changing its identity or connections.
- num_clocks() int¶
Returns the number of clock phases in the layout. Each clock cycle is divided into n phases. In QCA, the number of phases is usually 4. In iNML it is 3. Clocking schemes support 3 or 4 phases.
- Returns:
The number of different clock signals in the layout.
- num_se() int¶
Counts zones with a nonzero Hold-phase extension. @return Synchronization element count.
- object_function(object: layout_object_id) mnt.pyfiction.synthesis.dynamic_truth_table¶
Returns the object’s truth table.
- obstruct_connection(src: coordinate | tuple[int, int] | tuple[int, int, int], tgt: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Marks the connection from coordinate
srcto coordinatetgtas obstructed.- Parameters:
src – Source coordinate.
tgt – Target coordinate.
Note
clock_zones marked this way will not be crossed with wires by path finding algorithms.
- obstruct_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Marks the given coordinate as obstructed.
- Parameters:
c – clock_zone to obstruct.
- obstructed_connections() list[tuple[coordinate, coordinate]]¶
Returns manual directed-connection obstructions in unspecified order, without physical connections.
- obstructed_coordinates() list[coordinate]¶
Returns manual coordinate obstructions in unspecified order, without implicit occupancy.
- out_degree(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the number of outgoing clock zones from the given one.
- Parameters:
cz – Base clock zone.
- Returns:
Number of
cz’s outgoing clock zones.
- outgoing_clocked_zones(cz: coordinate | tuple[int, int] | tuple[int, int, int]) list[coordinate]¶
Returns a container with all clock zones that are outgoing from the given one.
- Parameters:
cz – Base clock zone.
- Returns:
A container with all clock zones that are outgoing from
cz.
- outgoing_data_flow(t: coordinate | tuple[int, int] | tuple[int, int, int]) list[coordinate]¶
Returns adjacent, outgoing-clocked destination coordinates once per connected input port. Multiple connected inputs on one destination yield repeated coordinates; order is unspecified.
- pi_at(index: int) mnt.pyfiction.layouts.layout_object_id¶
Returns a primary input in declared interface order.
- po_at(index: int) mnt.pyfiction.layouts.layout_object_id¶
Returns a primary output in declared interface order.
- remove(object: mnt.pyfiction.layouts.layout_object_id) None¶
Removes an object and disconnects all inputs and sinks. Stale identities reject.
- replace_clocking_scheme(name: str) None¶
Replaces the clocking scheme by the predefined scheme of the given name. Clock-number overrides are discarded; synchronization elements are kept. Raises ValueError for an unknown name.
- set_input_order(order: Sequence[mnt.pyfiction.layouts.layout_object_id]) None¶
Sets the complete input permutation. Invalid orders reject without mutation.
- set_output_order(order: Sequence[mnt.pyfiction.layouts.layout_object_id]) None¶
Sets the complete output permutation. Invalid orders reject without mutation.
- sinks(object: mnt.pyfiction.layouts.layout_object_id) list[mnt.pyfiction.layouts.layout_input_port]¶
Returns the destination input ports driven by this object’s output. Each sink identifies the destination object and its input index. If the source drives several inputs of one destination, each input is a separate sink. Connections need not be physically legal; order is unspecified.
- class hexagonal_gate_layout(arrangement: arrangement)¶
- class hexagonal_gate_layout(arrangement: arrangement, extent: extent | tuple[int, int] | tuple[int, int, int])
- class hexagonal_gate_layout(arrangement: arrangement, extent: extent | tuple[int, int] | tuple[int, int, int], clocking_scheme: str = '2DDWave', layout_name: str = '')
Placed FCN objects, ordered ports, clocking, and obstructions.
Objects have stable identities independent of their coordinates. Connections describe declared topology; physical validation checks adjacency, clocking, and geometry separately. Copies own independent state. A sink is a destination input port driven by a source object’s output. One destination object may receive the same source at several input indices; each connected input port is a distinct sink. Visitors may edit coordinates, names, and capabilities. Object and terminal visitors must not create or remove objects, change terminal order, or replace the layout during traversal. Connection visitors must also preserve the traversed input or sink connections, as specified on each visitor.
- Template Args:
CoordinateLayout – Coordinate geometry used for placement.
- assign_clock_number(cz: coordinate | tuple[int, int] | tuple[int, int, int], cn: int) None¶
Overrides the clock number of a tile in the stored scheme. The clock number applies to every layer of the tile, so the z-coordinate of
czis ignored.- Parameters:
cz – Clock zone to override.
cn – New clock number for
cz.
- assign_synchronization_element(coordinate: coordinate | tuple[int, int] | tuple[int, int, int], delay: int) None¶
Assigns a synchronization element to the provided clock zone.
- Parameters:
cz – Clock zone to turn into a synchronization element.
se – Number of full clock cycles to extend
cz’s Hold phase by. If this value is 0,czis turned back into a normal clock zone.
- bounding_box() tuple[coordinate | None, coordinate | None]¶
Returns the minimum and maximum corner of the bounding box. A 2D bounding box object computes a minimum-sized box around all non-empty coordinates in a given layout. Layouts can be of arbitrary size and, thus, may be larger than their contained elements. Sometimes, it might be necessary to know exactly which space the associated layout internals occupy. A bounding box computes coordinates that span a minimum-sized rectangle that encloses all non- empty layout coordinates.
- Returns:
The minimum and maximum enclosing coordinate in the associated layout.
- clear_obstructed_connection(src: coordinate | tuple[int, int] | tuple[int, int, int], tgt: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Clears the obstruction status of the connection from coordinate
srcto coordinatetgtif the obstruction was manually marked viaobstruct_connection.- Parameters:
src – Source coordinate.
tgt – Target coordinate.
- clear_obstructed_connections() None¶
Clears all obstructed connections that were manually marked via
obstruct_connection.
- clear_obstructed_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Clears the obstruction status of the given coordinate
cif the obstruction was manually marked viaobstruct_coordinate.- Parameters:
c – clock_zone to clear.
- clear_obstructed_coordinates() None¶
Clears all obstructed coordinates that were manually marked via
obstruct_coordinate.
- clear_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Removes the occupant of a coordinate if present.
- clone() hexagonal_gate_layout¶
Returns an independent value copy.
- connect(source: mnt.pyfiction.layouts.layout_object_id, input: mnt.pyfiction.layouts.layout_input_port) None¶
Connects an output to an ordered input, replacing the input’s existing source.
Port and identity checks precede mutation. Adjacency, clocking, and geometry need not be valid during editing.
- contains(object: mnt.pyfiction.layouts.layout_object_id) bool¶
Returns whether this identity names a live object.
- create_and(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a AND gate.
- create_buf(a: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
- create_buf(t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id
Overloaded function.
create_buf(self, a: mnt.pyfiction.layouts.layout_object_id, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a wire driven by
a.create_buf(self, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a wire with its input disconnected.
- create_gate(inputs: Sequence[layout_object_id], function: mnt.pyfiction.synthesis.dynamic_truth_table, t: coordinate | tuple[int, int] | tuple[int, int, int]) layout_object_id¶
Creates a placed gate. Input indices follow truth-table variable order; trailing inputs may be disconnected.
- create_ge(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a GE gate.
- create_gt(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a GT gate.
- create_le(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a LE gate.
- create_lt(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a LT gate.
- create_maj(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, c: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a majority gate.
- create_nand(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a NAND gate.
- create_nor(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a NOR gate.
- create_not(a: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a NOT gate.
- create_or(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a OR gate.
- create_pi(name: str, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a primary input at
t. Occupied coordinates reject without mutation.
- create_po(s: mnt.pyfiction.layouts.layout_object_id, name: str, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
- create_po(name: str, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id
Overloaded function.
create_po(self, s: mnt.pyfiction.layouts.layout_object_id, name: str, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a primary output driven by
satt.create_po(self, name: str, t: mnt.pyfiction.layouts.coordinate | tuple[int, int] | tuple[int, int, int]) -> mnt.pyfiction.layouts.layout_object_id
Creates a primary output with its input disconnected.
- create_xnor(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a XNOR gate.
- create_xor(a: mnt.pyfiction.layouts.layout_object_id, b: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Creates a XOR gate.
- degree(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the number of distinct incoming or outgoing neighboring clock zones.
- Parameters:
cz – Base clock zone.
- Returns:
Number of distinct clocked neighbors of
cz.
- disconnect(input: mnt.pyfiction.layouts.layout_input_port) None¶
Disconnects one input without changing the indices of other inputs.
- fanin_size(object: mnt.pyfiction.layouts.layout_object_id) int¶
Counts connected input slots, irrespective of physical legality.
- fanout_size(object: mnt.pyfiction.layouts.layout_object_id) int¶
Counts destination input ports driven by this object’s output.
Each connected input port is a sink, including multiple ports on the same destination object.
- find_object(t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id | None¶
Finds the object at a coordinate; empty coordinates have no identity.
- get_clock_number(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the clock number of a tile. Every layer of a tile has the same clock number, so the z-coordinate of
czis ignored.- Parameters:
cz – Clock zone.
- Returns:
Clock number of
cz.
- get_clocking_scheme_name() str¶
Returns the name of the layout’s clocking scheme, e.g.,
2DDWaveorUSE.
- get_name(object: mnt.pyfiction.layouts.layout_object_id) str¶
Returns an object’s name, or an empty string for an unnamed object.
- get_synchronization_element(coordinate: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the Hold phase extension in clock cycles of clock zone
cz.- Parameters:
cz – Clock zone to check.
- Returns:
Synchronization element value, i.e., Hold phase extension, of clock zone
cz.
- get_tile(object: mnt.pyfiction.layouts.layout_object_id) coordinate¶
Returns the object’s coordinate. @throws std::invalid_argument If the identity is stale.
- has_eastern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffeast(t)is incoming tot.
- has_eastern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffeast(t)is outgoing fromt.
- has_no_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has no incoming tiles.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueifftdoes not have incoming tiles.
- has_no_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has no outgoing tiles.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueifftdoes not have outgoing tiles.
- has_north_eastern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in north-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffnorth_east(t)is incoming tot.
- has_north_eastern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in north-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffnorth_east(t)is outgoing fromt.
- has_north_western_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in north-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffnorth_west(t)is incoming tot.
- has_north_western_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in north-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffnorth_west(t)is outgoing fromt.
- has_northern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in northern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffnorth(t)is incoming tot.
- has_northern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in northern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffnorth(t)is outgoing fromt.
- has_south_eastern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in south-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffsouth_east(t)is incoming tot.
- has_south_eastern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in south-eastern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffsouth_east(t)is outgoing fromt.
- has_south_western_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in south-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffsouth_west(t)is incoming tot.
- has_south_western_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in south-western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffsouth_west(t)is outgoing fromt.
- has_southern_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in southern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffsouth(t)is incoming tot.
- has_southern_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in southern direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffsouth(t)is outgoing fromt.
- has_western_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an incoming one in western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanins.
- Returns:
trueiffwest(t)is incoming tot.
- has_western_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks whether the given tile has an outgoing one in western direction.
- Parameters:
t – Base tile.
- Template Args:
RespectClocking – Flag to indicate that the underlying clocking is to be respected when evaluating fanouts.
- Returns:
trueiffwest(t)is outgoing fromt.
- in_degree(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the number of incoming clock zones to the given one.
- Parameters:
cz – Base clock zone.
- Returns:
Number of
cz’s incoming clock zones.
- incoming_clocked_zones(cz: coordinate | tuple[int, int] | tuple[int, int, int]) list[coordinate]¶
Returns a container with all clock zones that are incoming to the given one.
- Parameters:
cz – Base clock zone.
- Returns:
A container with all clock zones that are incoming to
cz.
- input_count(object: mnt.pyfiction.layouts.layout_object_id) int¶
Returns the number of input slots, including disconnected slots.
- inputs(object: mnt.pyfiction.layouts.layout_object_id) list[mnt.pyfiction.layouts.layout_object_id | None]¶
Returns input sources in port-index order, including None for disconnected ports.
- is_and(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes AND.
- is_buf(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether an object computes the identity function.
- is_clocking_scheme(name: str) bool¶
Compares the stored clocking scheme against the provided name. Predefined names are constants in
fiction::layouts::clocking.- Parameters:
name – Clocking scheme name.
- Returns:
trueiff the layout is clocked by a clocking scheme of namename.
- is_empty_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether a coordinate has no occupant.
- is_fanout(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether an identity object drives more than one input port.
- is_gate_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a gate.
- is_incoming_clocked(cz1: coordinate | tuple[int, int] | tuple[int, int, int], cz2: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Evaluates whether clock zone
cz2feeds information to clock zonecz1, i.e., whethercz2is clocked with a clock number that is lower by 1 modulonum_clocks(), or either zone is a synchronization element.- Parameters:
cz1 – Base clock zone.
cz2 – Clock zone to check whether its clock number is lower by 1.
- Returns:
trueiffcz2can feed information tocz1.
- is_incoming_signal(t: coordinate | tuple[int, int] | tuple[int, int, int], s: coordinate | tuple[int, int] | tuple[int, int, int] | None) bool¶
Checks for a physical incoming connection from the given x/y location.
- is_inv(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes INV.
- is_maj(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes MAJ.
- is_nand(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes NAND.
- is_nor(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes NOR.
- is_obstructed_connection(src: coordinate | tuple[int, int] | tuple[int, int, int], tgt: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks if the given coordinate-coordinate connection is obstructed of some sort.
- Parameters:
src – Source coordinate.
tgt – Target coordinate.
- Returns:
trueiff the connection fromsrctotgtis obstructed.
- is_obstructed_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Checks if the given coordinate is obstructed of some sort.
- Parameters:
c – Coordinate to check.
- Returns:
trueiffcis obstructed.
- is_outgoing_clocked(cz1: coordinate | tuple[int, int] | tuple[int, int, int], cz2: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Evaluates whether clock zone
cz2accepts information from clock zonecz1, i.e., whethercz2is clocked with a clock number that is higher by 1 modulonum_clocks(), or either zone is a synchronization element.- Parameters:
cz1 – Base clock zone.
cz2 – Clock zone to check whether its clock number is higher by 1.
- Returns:
trueiffcz2can accept information fromcz1.
- is_outgoing_signal(t: coordinate | tuple[int, int] | tuple[int, int, int], s: coordinate | tuple[int, int] | tuple[int, int, int] | None) bool¶
Checks for a physical outgoing connection to the given x/y location.
- is_pi(n: mnt.pyfiction.layouts.layout_object_id) bool¶
Returns whether an object is a primary input.
- is_pi_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a pi.
- is_po(n: mnt.pyfiction.layouts.layout_object_id) bool¶
Returns whether an object is a primary output.
- is_po_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a po.
- is_regularly_clocked() bool¶
Returns whether the layout is clocked by a regular clocking scheme with no overwritten zones.
- Returns:
trueiff the layout is clocked by a regular scheme and no zones have been overwritten.
- is_synchronization_element(coordinate: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Check whether the provided clock zone is a synchronization element.
- Parameters:
cz – Clock zone to check.
- Returns:
trueiffczis a synchronization element.
- is_wire(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether an object is a physical wire rather than a terminal.
- is_wire_tile(t: coordinate | tuple[int, int] | tuple[int, int, int]) bool¶
Returns whether the coordinate hosts a wire.
- is_xnor(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes XNOR.
- is_xor(arg: mnt.pyfiction.layouts.layout_object_id, /) bool¶
Returns whether the object computes XOR.
- move_object(object: mnt.pyfiction.layouts.layout_object_id, t: coordinate | tuple[int, int] | tuple[int, int, int]) mnt.pyfiction.layouts.layout_object_id¶
Moves an object without changing its identity or connections.
- num_clocks() int¶
Returns the number of clock phases in the layout. Each clock cycle is divided into n phases. In QCA, the number of phases is usually 4. In iNML it is 3. Clocking schemes support 3 or 4 phases.
- Returns:
The number of different clock signals in the layout.
- num_se() int¶
Counts zones with a nonzero Hold-phase extension. @return Synchronization element count.
- object_function(object: layout_object_id) mnt.pyfiction.synthesis.dynamic_truth_table¶
Returns the object’s truth table.
- obstruct_connection(src: coordinate | tuple[int, int] | tuple[int, int, int], tgt: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Marks the connection from coordinate
srcto coordinatetgtas obstructed.- Parameters:
src – Source coordinate.
tgt – Target coordinate.
Note
clock_zones marked this way will not be crossed with wires by path finding algorithms.
- obstruct_coordinate(c: coordinate | tuple[int, int] | tuple[int, int, int]) None¶
Marks the given coordinate as obstructed.
- Parameters:
c – clock_zone to obstruct.
- obstructed_connections() list[tuple[coordinate, coordinate]]¶
Returns manual directed-connection obstructions in unspecified order, without physical connections.
- obstructed_coordinates() list[coordinate]¶
Returns manual coordinate obstructions in unspecified order, without implicit occupancy.
- out_degree(cz: coordinate | tuple[int, int] | tuple[int, int, int]) int¶
Returns the number of outgoing clock zones from the given one.
- Parameters:
cz – Base clock zone.
- Returns:
Number of
cz’s outgoing clock zones.
- outgoing_clocked_zones(cz: coordinate | tuple[int, int] | tuple[int, int, int]) list[coordinate]¶
Returns a container with all clock zones that are outgoing from the given one.
- Parameters:
cz – Base clock zone.
- Returns:
A container with all clock zones that are outgoing from
cz.
- outgoing_data_flow(t: coordinate | tuple[int, int] | tuple[int, int, int]) list[coordinate]¶
Returns adjacent, outgoing-clocked destination coordinates once per connected input port. Multiple connected inputs on one destination yield repeated coordinates; order is unspecified.
- pi_at(index: int) mnt.pyfiction.layouts.layout_object_id¶
Returns a primary input in declared interface order.
- po_at(index: int) mnt.pyfiction.layouts.layout_object_id¶
Returns a primary output in declared interface order.
- remove(object: mnt.pyfiction.layouts.layout_object_id) None¶
Removes an object and disconnects all inputs and sinks. Stale identities reject.
- replace_clocking_scheme(name: str) None¶
Replaces the clocking scheme by the predefined scheme of the given name. Clock-number overrides are discarded; synchronization elements are kept. Raises ValueError for an unknown name.
- set_input_order(order: Sequence[mnt.pyfiction.layouts.layout_object_id]) None¶
Sets the complete input permutation. Invalid orders reject without mutation.
- set_output_order(order: Sequence[mnt.pyfiction.layouts.layout_object_id]) None¶
Sets the complete output permutation. Invalid orders reject without mutation.
- sinks(object: mnt.pyfiction.layouts.layout_object_id) list[mnt.pyfiction.layouts.layout_input_port]¶
Returns the destination input ports driven by this object’s output. Each sink identifies the destination object and its input index. If the source drives several inputs of one destination, each input is a separate sink. Connections need not be physically legal; order is unspecified.
Construction and capabilities¶
using layout = fiction::layouts::gate_level_layout<fiction::layouts::cartesian_layout>;
layout lyt{{4, 4}, fiction::layouts::clocking::twoddwave()};
lyt.assign_synchronization_element({1, 1}, 2);
lyt.obstruct_coordinate({2, 2});
const auto input = lyt.create_pi("a", {0, 0});
const auto wire = lyt.create_buf(input, {1, 0});
lyt.create_po(wire, "f", {2, 0});
lyt.move_object(wire, {1, 1});
lyt.disconnect({wire, 0});
lyt.connect(input, {wire, 0});
auto independent = lyt.clone();
from mnt.pyfiction.layouts import layout_input_port, cartesian_gate_layout
lyt = cartesian_gate_layout((4, 4), "2DDWave")
lyt.assign_synchronization_element((1, 1), 2)
lyt.obstruct_coordinate((2, 2))
input_port = lyt.create_pi("a", (0, 0))
wire = lyt.create_buf(input_port, (1, 0))
lyt.create_po(wire, "f", (2, 0))
lyt.move_object(wire, (1, 1))
lyt.disconnect(layout_input_port(wire, 0))
lyt.connect(input_port, layout_input_port(wire, 0))
independent = lyt.clone()
Ordinary C++ copies, clone(), Python copy.copy(), and Python copy.deepcopy() copy
geometry, objects, connections, clocking,
synchronization, and obstructions independently. Corresponding objects retain their numeric IDs;
an ID must still be used with the layout that owns it. Explicit obstructions survive clearing
or moving gates; removing an explicit obstruction does not remove a gate or wire.
Replacing a whole layout invalidates handles into the destination’s old contents. Moving a whole layout transfers its objects and numeric IDs to the destination; handles into the emptied source cannot be used with that source after reuse.
PI and PO order is independent of coordinates and object iteration. set_input_order and
set_output_order accept a permutation of all live terminals of the corresponding role and
validate the full permutation before changing the order. Interface matching uses names that are
unique on both sides first, then pairs the remaining terminals in declared order.
An empty layout uses the four-phase OPEN scheme. Assigning a synchronization delay of zero removes the synchronization element. Replacing the clocking scheme preserves synchronization delays. Synchronization changes clocked traversal; it does not add support for sequential circuits.
Generations detect removed-slot reuse within one layout contents lifetime. IDs do not carry a layout identity;
contains cannot detect IDs from unrelated layouts or contents invalidated by whole-layout assignment.
The caller must use an ID only with its owning contents.
Object and terminal visitors permit coordinate, name, and capability edits. Callbacks must not create or remove objects, change terminal order, or replace the layout. Connection visitors preserve the traversed object and its input or sink connections. Connection callbacks may create or remove unrelated objects if those connections remain unchanged. Collect IDs before changing traversed membership or connections. Object traversal scans one bitmap word per 64 retained slots and visits each live object. Its cost is \(O(H / 64 + L)\) for \(H\) historical slots and \(L\) live objects.
The layout stores object records and mutable connections in contiguous reusable pools. Indexed sink lists permit constant-time unlinking. Every built-in gate keeps its ordered inputs inline; objects whose arity exceeds the inline capacity use separate overflow storage. This capacity does not limit the number of inputs or depend on the coordinate geometry. Names and truth-table payloads live outside object records. Removing an object releases its overflow inputs; the object and connection pools retain capacity for reuse. The live-object bitmap adds one bit per retained slot without enlarging object records.
Contiguous connection storage does not make each object’s sink list contiguous. Reconnecting inputs reuses free edge slots, so sink traversal follows indices that can span the pool. This representation supports local routing edits without shifting neighboring adjacency lists. Analyses that need repeated dense logic traversal can extract a network; the editable layout does not maintain a second adjacency representation.
Coordinates use a sparse flat hash map rather than an array proportional to the layout’s frame. Names and truth-table payloads live outside the records read by ordinary topology traversal, which needs neither payload. The three inline input indices cover the built-in gate set without an allocation per gate. Object IDs keep their slot and generation across moves; compacting slots would require a separate identity mapping.