KLayout 0.29.8 (2024-10-28 63dd591e5) [master]

API reference - Class SubCircuit

Notation used in Ruby API documentation

Module: db

Description: A subcircuit inside a circuit.

Class hierarchy: SubCircuit » NetlistObject

Circuits may instantiate other circuits as subcircuits similar to cells in layouts. Such an instance is a subcircuit. A subcircuit refers to a circuit implementation (a Circuit object), and presents connections through pins. The pins of a subcircuit can be connected to nets. The subcircuit pins are identical to the outgoing pins of the circuit the subcircuit refers to.

Subcircuits connect to nets through the SubCircuit#connect_pin method. SubCircuit pins can be disconnected using SubCircuit#disconnect_pin.

Subcircuit objects are created inside a circuit with Circuit#create_subcircuit.

This class has been added in version 0.26.

Public methods

void_assign(const SubCircuit other)Assigns another object to self
[const]SubCircuit ptr_const_castReturns a non-const reference to self.
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]new SubCircuit ptr_dupCreates a copy of self
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
[const]const Circuit ptrcircuitGets the circuit the subcircuit lives in.
Circuit ptrcircuitGets the circuit the subcircuit lives in (non-const version).
[const]const Circuit ptrcircuit_refGets the circuit referenced by the subcircuit.
Circuit ptrcircuit_refGets the circuit referenced by the subcircuit (non-const version).
voidconnect_pin(unsigned long pin_id,
Net ptr net)
Connects the given pin to the specified net.
voidconnect_pin(const Pin ptr pin,
Net ptr net)
Connects the given pin to the specified net.
voiddisconnect_pin(unsigned long pin_id)Disconnects the given pin from any net.
voiddisconnect_pin(const Pin ptr pin)Disconnects the given pin from any net.
[const]stringexpanded_nameGets the expanded name of the subcircuit.
[const]unsigned longidGets the subcircuit ID.
[const]stringnameGets the name of the subcircuit.
voidname=(string name)Sets the name of the subcircuit.
[const]const Net ptrnet_for_pin(unsigned long pin_id)Gets the net connected to the specified pin of the subcircuit.
Net ptrnet_for_pin(unsigned long pin_id)Gets the net connected to the specified pin of the subcircuit (non-const version).
[const]DCplxTranstransGets the physical transformation for the subcircuit.
voidtrans=(const DCplxTrans trans)Sets the physical transformation for the subcircuit.

Detailed description

_assign

Signature: void _assign (const SubCircuit other)

Description: Assigns another object to self

_const_cast

Signature: [const] SubCircuit ptr _const_cast

Description: Returns a non-const reference to self.

Basically, this method allows turning a const object reference to a non-const one. This method is provided as last resort to remove the constness from an object. Usually there is a good reason for a const object reference, so using this method may have undesired side effects.

This method has been introduced in version 0.29.6.

_create

Signature: void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

_destroyed?

Signature: [const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

_dup

Signature: [const] new SubCircuit ptr _dup

Description: Creates a copy of self

_is_const_object?

Signature: [const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

circuit

(1) Signature: [const] const Circuit ptr circuit

Description: Gets the circuit the subcircuit lives in.

This is NOT the circuit which is referenced. For getting the circuit that the subcircuit references, use circuit_ref.

(2) Signature: Circuit ptr circuit

Description: Gets the circuit the subcircuit lives in (non-const version).

This is NOT the circuit which is referenced. For getting the circuit that the subcircuit references, use circuit_ref.

This constness variant has been introduced in version 0.26.8

circuit_ref

(1) Signature: [const] const Circuit ptr circuit_ref

Description: Gets the circuit referenced by the subcircuit.

(2) Signature: Circuit ptr circuit_ref

Description: Gets the circuit referenced by the subcircuit (non-const version).

This constness variant has been introduced in version 0.26.8

connect_pin

(1) Signature: void connect_pin (unsigned long pin_id, Net ptr net)

Description: Connects the given pin to the specified net.

(2) Signature: void connect_pin (const Pin ptr pin, Net ptr net)

Description: Connects the given pin to the specified net.

This version takes a Pin reference instead of a pin ID.

disconnect_pin

(1) Signature: void disconnect_pin (unsigned long pin_id)

Description: Disconnects the given pin from any net.

(2) Signature: void disconnect_pin (const Pin ptr pin)

Description: Disconnects the given pin from any net.

This version takes a Pin reference instead of a pin ID.

expanded_name

Signature: [const] string expanded_name

Description: Gets the expanded name of the subcircuit.

The expanded name takes the name of the subcircuit. If the name is empty, the numeric ID will be used to build a name.

id

Signature: [const] unsigned long id

Description: Gets the subcircuit ID.

The ID is a unique integer which identifies the subcircuit. It can be used to retrieve the subcircuit from the circuit using Circuit#subcircuit_by_id. When assigned, the subcircuit ID is not 0.

name

Signature: [const] string name

Description: Gets the name of the subcircuit.

Python specific notes:
The object exposes a readable attribute 'name'. This is the getter.

name=

Signature: void name= (string name)

Description: Sets the name of the subcircuit.

SubCircuit names are used to name a subcircuits inside a netlist file. SubCircuit names should be unique within a circuit.

Python specific notes:
The object exposes a writable attribute 'name'. This is the setter.

net_for_pin

(1) Signature: [const] const Net ptr net_for_pin (unsigned long pin_id)

Description: Gets the net connected to the specified pin of the subcircuit.

If the pin is not connected, nil is returned for the net.

(2) Signature: Net ptr net_for_pin (unsigned long pin_id)

Description: Gets the net connected to the specified pin of the subcircuit (non-const version).

If the pin is not connected, nil is returned for the net.

This constness variant has been introduced in version 0.26.8

trans

Signature: [const] DCplxTrans trans

Description: Gets the physical transformation for the subcircuit.

This property applies to subcircuits derived from a layout. It specifies the placement of the respective cell.

This property has been introduced in version 0.27.

Python specific notes:
The object exposes a readable attribute 'trans'. This is the getter.

trans=

Signature: void trans= (const DCplxTrans trans)

Description: Sets the physical transformation for the subcircuit.

See trans for details about this property.

This property has been introduced in version 0.27.

Python specific notes:
The object exposes a writable attribute 'trans'. This is the setter.