Clocking State

Gate and cell layouts own clocking::state<Coordinate> objects in their storage. The state contains a clocking scheme, its overrides, and synchronization delays. It has no layout base or geometry parameter. Copying the state copies its contents independently.

Layouts provide the public clocking methods and perform geometry traversal. A clock zone is a tile: in a gate-level layout, a tile usually holds one gate or wire; in a cell-level layout, a tile is a region of get_tile_size_x() by get_tile_size_y() cells that one clock signal governs on every layer. Clock-number lookups and overrides therefore ignore the z-coordinate of a clock zone.

Synchronization elements (SEs) [30] use the external clock generator to produce additional asymmetric clock signals with extended Hold phases. A nonzero synchronization delay turns a clock zone into such a latch-like SE, which extends the Hold phase by that many full clock cycles. Distinct zones can exchange information when their phases follow each other or either zone is an SE. A zone cannot feed itself.

Header: fiction/layouts/clocking_state.hpp

class state

Clock numbers and synchronization delays, independent of layout geometry. Copies own independent schemes and synchronization maps.

Public Types

using clock_zone = layout_base::coordinate

Coordinate identifying a clock zone.

using clocking_scheme_t = scheme

Clocking scheme over tile positions.

using clock_number_t = typename clocking_scheme_t::clock_number

Clock phase index.

using sync_elem_t = uint8_t

Hold-phase extension in full clock cycles.

Public Functions

inline explicit state(clocking_scheme_t s)

Creates state with the given scheme.

Parameters:

s – Initial scheme.

state(const state&) = default

Copies the scheme and synchronization delays independently.

state(state&&) noexcept = default

Moves the scheme and synchronization delays.

inline state &operator=(const state &other)

Replaces this state with an independent copy. Copy failure preserves this state.

Parameters:

other – State to copy.

Throws:

std::bad_alloc – If allocation fails.

Returns:

This state.

state &operator=(state&&) noexcept = default

Moves the scheme and synchronization delays.

Returns:

This state.

~state() = default

Releases owned clocking state.

inline void replace_clocking_scheme(const clocking_scheme_t &scheme)

Replaces the stored clocking scheme with the provided one. Copy failure preserves the stored scheme.

Parameters:

scheme – New clocking scheme.

Throws:

std::bad_alloc – If allocation fails.

inline void assign_clock_number(const clock_zone &cz, const clock_number_t cn)

Overrides the clock number of a clock zone in the stored scheme. A clock zone spans every layer, so the override ignores the z-coordinate of cz.

Parameters:
  • cz – Clock zone to override.

  • cn – New clock number for cz.

Throws:

std::bad_alloc – If allocation fails.

inline clock_number_t get_clock_number(const clock_zone &cz) const noexcept

Returns the clock number of a clock zone. A clock zone spans every layer, so the lookup ignores the z-coordinate of cz.

Parameters:

cz – Clock zone.

Returns:

Clock number of cz.

inline clock_number_t num_clocks() const noexcept

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 noexcept

Returns whether the layout is clocked by a regular clocking scheme with no overwritten zones.

Returns:

true iff 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 noexcept

Compares the stored clocking scheme against the provided name. Predefined names are constants in fiction::layouts::clocking.

Parameters:

name – Clocking scheme name.

Returns:

true iff the layout is clocked by a clocking scheme of name name.

inline const clocking_scheme_t &get_clocking_scheme() const noexcept

Returns a read-only reference to the stored clocking scheme object. Assignment or moving from the state replaces the referenced contents; the reference stays attached to the state that supplied it.

Returns:

A reference valid for the lifetime of this state.

inline bool is_incoming_clocked(const clock_zone &cz1, const clock_zone &cz2) const noexcept

Evaluates whether clock zone cz2 feeds information to clock zone cz1, i.e., whether cz2 is clocked with a clock number that is lower by 1 modulo num_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:

true iff cz2 can feed information to cz1.

inline bool is_outgoing_clocked(const clock_zone &cz1, const clock_zone &cz2) const noexcept

Evaluates whether clock zone cz2 accepts information from clock zone cz1, i.e., whether cz2 is clocked with a clock number that is higher by 1 modulo num_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:

true iff cz2 can accept information from cz1.

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, cz is turned back into a normal clock zone.

Throws:

std::bad_alloc – If allocation fails.

inline bool is_synchronization_element(const clock_zone &cz) const noexcept

Check whether the provided clock zone is a synchronization element.

Parameters:

cz – Clock zone to check.

Returns:

true iff cz is a synchronization element.

inline sync_elem_t get_synchronization_element(const clock_zone &cz) const noexcept

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 noexcept

Counts zones with a nonzero Hold-phase extension.

Returns:

Synchronization element count.

template<typename Fn>
inline void foreach_synchronization_element(Fn &&fn) const

Visits zones with a nonzero synchronization delay.

Template Parameters:

Fn – Callable accepting a clock zone and delay.

Parameters:

fn – Callback for each synchronization element.