pub struct Handle { /* private fields */ }Expand description
Wrapper around a raw VPI object handle.
This type provides convenience helpers for common handle operations and iteration over child objects.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn register_cb<F>(&self, reason: CbReason, callback: F) -> Handle
pub fn register_cb<F>(&self, reason: CbReason, callback: F) -> Handle
Registers a callback associated with this handle.
Returns a callback handle that can be removed with remove_cb.
Sourcepub fn register_full_cb<F>(&self, reason: CbReason, callback: F) -> Handle
pub fn register_full_cb<F>(&self, reason: CbReason, callback: F) -> Handle
Registers a callback with persistent time/value registration buffers.
This variant populates t_cb_data.time and t_cb_data.value at
registration time so simulators can write callback payloads through
those pointers.
Sourcepub fn register_value_change_cb<F>(
&self,
value_type: ValueType,
callback: F,
) -> Handle
pub fn register_value_change_cb<F>( &self, value_type: ValueType, callback: F, ) -> Handle
Registers a value-change callback with an explicit value format.
Some simulators require t_cb_data.value.format to match the expected
callback value encoding for cbValueChange callbacks. This helper sets
that format during registration.
Source§impl Handle
impl Handle
Sourcepub fn get_delays(
&self,
capacity: usize,
time_type: DelayTimeType,
) -> Option<DelayData>
pub fn get_delays( &self, capacity: usize, time_type: DelayTimeType, ) -> Option<DelayData>
Reads delay values from an object using vpi_get_delays.
capacity controls how many delay entries are allocated for the C API.
Use 1 for simple delays and 3 for min/typ/max delay sets.
Sourcepub fn put_delays(&self, data: &DelayData) -> bool
pub fn put_delays(&self, data: &DelayData) -> bool
Writes delay values to an object using vpi_put_delays.
Returns false for null handles or when the delay count does not fit in
the VPI ABI integer type.
Source§impl Handle
impl Handle
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Replaces the current handle with null.
This is used when ownership of the raw handle is not held by this type.
Sourcepub fn handle_by_name(name: &str) -> Self
pub fn handle_by_name(name: &str) -> Self
Looks up a handle by hierarchical name.
Wraps vpi_handle_by_name. Pass a null handle as scope to resolve
against the root (absolute hierarchical names). Returns a null handle
when the name cannot be resolved.
Sourcepub fn handle_by_name_and_scope(name: &str, scope: &Handle) -> Self
pub fn handle_by_name_and_scope(name: &str, scope: &Handle) -> Self
Returns a handle located by name within a scope.
Passing Handle::null() as the scope will resolve the name against the root of the hierarchy.
Returns a null handle when the object is not found.
Sourcepub fn iterator(&self, typ: ObjectType) -> HandleIterator ⓘ
pub fn iterator(&self, typ: ObjectType) -> HandleIterator ⓘ
Returns an iterator handle for objects of typ under this handle.
Sourcepub fn get(&self, typ: ObjectType) -> Self
pub fn get(&self, typ: ObjectType) -> Self
Returns a related object handle selected by typ.
Returns a null handle when the relation is unavailable.
Sourcepub fn handle_by_index(&self, index: i32) -> Self
pub fn handle_by_index(&self, index: i32) -> Self
Returns a child handle by index.
Returns a null handle when index is out of range.
Sourcepub fn iterators<'a>(
&'a self,
typ: &'a [ObjectType],
) -> impl Iterator<Item = Handle> + 'a
pub fn iterators<'a>( &'a self, typ: &'a [ObjectType], ) -> impl Iterator<Item = Handle> + 'a
Iterates across multiple object kinds and flattens all resulting handles.
Sourcepub fn get_multi(&self, typ: ObjectType, other: &Handle) -> Self
pub fn get_multi(&self, typ: ObjectType, other: &Handle) -> Self
Returns a related object handle selected by typ using two reference handles.
This wraps vpi_handle_multi for APIs that require two source handles.
Returns a null handle when this handle or other is null, or when the
relation is unavailable.
Sourcepub fn handle_by_multi_index(&self, indices: impl AsRef<[i32]>) -> Self
pub fn handle_by_multi_index(&self, indices: impl AsRef<[i32]>) -> Self
Returns a child handle by multiple indices.
This wraps vpi_handle_by_multi_index and is used for
multidimensional arrays. Returns a null handle when this handle is null,
when indices is empty, when the index count exceeds VPI limits, or
when no object exists at the requested index tuple.
Sourcepub fn multi_handle_traversal(
&self,
typ: ObjectType,
indices: impl AsRef<[i32]>,
) -> Self
pub fn multi_handle_traversal( &self, typ: ObjectType, indices: impl AsRef<[i32]>, ) -> Self
Convenience helper for multi-handle traversal.
First traverses to typ via vpi_handle, then resolves a
multidimensional element with vpi_handle_by_multi_index.
Source§impl Handle
impl Handle
Sourcepub fn get_i64(&self, property: Property) -> Option<i64>
pub fn get_i64(&self, property: Property) -> Option<i64>
Reads a numeric property using vpi_get64 and returns it as i64.
Returns None for null handles.
Sourcepub fn get_u64(&self, property: Property) -> Option<u64>
pub fn get_u64(&self, property: Property) -> Option<u64>
Reads a numeric property using vpi_get64 and returns it as u64.
Returns None for null handles or negative raw values.
Sourcepub fn get_u32(&self, property: Property) -> Option<u32>
pub fn get_u32(&self, property: Property) -> Option<u32>
Reads a numeric property and returns it as u32 when supported.
Returns None for null handles or unsupported properties.
Sourcepub fn get_str(&self, property: Property) -> Option<String>
pub fn get_str(&self, property: Property) -> Option<String>
Reads a string property when supported.
Returns None for null handles, unsupported properties, or invalid UTF-8.
Sourcepub fn get_bool(&self, property: Property) -> Option<bool>
pub fn get_bool(&self, property: Property) -> Option<bool>
Reads a boolean property when supported.
Returns None for null handles or unsupported properties.
Sourcepub fn get_direction(&self) -> Option<Direction>
pub fn get_direction(&self) -> Option<Direction>
Returns this object’s port direction, if available.
Sourcepub fn get_op_type(&self) -> Option<OpType>
pub fn get_op_type(&self) -> Option<OpType>
Returns this object’s operation subtype, if available.
Sourcepub fn get_prim_type(&self) -> Option<PrimType>
pub fn get_prim_type(&self) -> Option<PrimType>
Returns this object’s primitive subtype, if available.
Sourcepub fn get_tchk_type(&self) -> Option<TchkType>
pub fn get_tchk_type(&self) -> Option<TchkType>
Returns this object’s timing check subtype, if available.
Sourcepub fn get_const_type(&self) -> Option<ConstType>
pub fn get_const_type(&self) -> Option<ConstType>
Returns this object’s constant subtype, if available.
Sourcepub fn get_full_name(&self) -> Option<String>
pub fn get_full_name(&self) -> Option<String>
Returns this object’s full hierarchical name, if available.
Sourcepub fn get_func_type(&self) -> Option<FuncType>
pub fn get_func_type(&self) -> Option<FuncType>
Returns this object’s function type, if available.
Sourcepub fn get_sys_func_type(&self) -> Option<SysFuncType>
pub fn get_sys_func_type(&self) -> Option<SysFuncType>
Returns this object’s system function type, if available.
Sourcepub fn get_type(&self) -> Option<ObjectType>
pub fn get_type(&self) -> Option<ObjectType>
Returns this object’s VPI object type.
Sourcepub fn get_left_range(&self) -> Option<i32>
pub fn get_left_range(&self) -> Option<i32>
Returns this object’s left range value, if available.
Sourcepub fn get_right_range(&self) -> Option<i32>
pub fn get_right_range(&self) -> Option<i32>
Returns this object’s right range value, if available.
Sourcepub fn get_packages(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_packages(&self) -> Vec<Handle>
sv only.Iterates packages visible from this scope/root.
Sourcepub fn get_interfaces(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_interfaces(&self) -> Vec<Handle>
sv only.Iterates interface instances visible from this scope/root.
Sourcepub fn get_programs(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_programs(&self) -> Vec<Handle>
sv only.Iterates program instances visible from this scope/root.
Sourcepub fn get_virtual_interfaces(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_virtual_interfaces(&self) -> Vec<Handle>
sv only.Iterates virtual interface variables visible from this scope/root.
Sourcepub fn is_randomized(&self) -> Option<bool>
Available on crate feature sv only.
pub fn is_randomized(&self) -> Option<bool>
sv only.Returns whether this object participates in randomization.
Sourcepub fn get_rand_type(&self) -> Option<RandType>
Available on crate feature sv only.
pub fn get_rand_type(&self) -> Option<RandType>
sv only.Returns the SystemVerilog randomization qualifier (rand, randc, etc.).
Sourcepub fn is_constraint_enabled(&self) -> Option<bool>
Available on crate feature sv only.
pub fn is_constraint_enabled(&self) -> Option<bool>
sv only.Returns whether this constraint object is enabled.
Sourcepub fn is_constraint_soft(&self) -> Option<bool>
Available on crate feature sv only.
pub fn is_constraint_soft(&self) -> Option<bool>
sv only.Returns whether this constraint object is declared soft.
Sourcepub fn get_dist_type(&self) -> Option<DistType>
Available on crate feature sv only.
pub fn get_dist_type(&self) -> Option<DistType>
sv only.Returns distribution style metadata for distribution constraints.
Sourcepub fn get_constraints(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_constraints(&self) -> Vec<Handle>
sv only.Iterates class constraints reachable from this object.
Sourcepub fn get_constraint_ordering(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_constraint_ordering(&self) -> Vec<Handle>
sv only.Iterates constraint-ordering nodes (solve ... before ...) on this object.
Sourcepub fn get_constraint_items(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_constraint_items(&self) -> Vec<Handle>
sv only.Iterates constraint items for this constraint object.
Sourcepub fn get_solve_before(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_solve_before(&self) -> Vec<Handle>
sv only.Iterates solve before edges under a constraint-ordering object.
Sourcepub fn get_solve_after(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_solve_after(&self) -> Vec<Handle>
sv only.Iterates solve after edges under a constraint-ordering object.
Sourcepub fn get_distribution_items(&self) -> Vec<Handle>
Available on crate feature sv only.
pub fn get_distribution_items(&self) -> Vec<Handle>
sv only.Iterates distribution-item nodes (dist list entries).
Sourcepub fn get_typespec(&self) -> Option<Typespec>
Available on crate feature sv only.
pub fn get_typespec(&self) -> Option<Typespec>
sv only.Returns the typespec kind associated with this object, if any.
Calls vpi_handle(vpiTypespec, h) to obtain the typespec object and
then reads its vpiType property to determine the concrete typespec
variant.
Sourcepub fn member_iterator(&self) -> HandleIterator ⓘ
Available on crate feature sv only.
pub fn member_iterator(&self) -> HandleIterator ⓘ
sv only.Iterates class/struct members reachable from this object.
Sourcepub fn get_type_name(&self) -> Option<String>
pub fn get_type_name(&self) -> Option<String>
Returns a human-readable type name for this object.
Resolution order:
- Port unwrapping — if the object is a
ObjectType::PortorObjectType::PortBit, followsvpiLowConn(the internal signal) to obtain the underlying net or variable, then applies the remaining steps to that handle. Falls back tovpiHighConnwhenvpiLowConnis absent. svfeature only — retrieves the associated typespec handle viavpi_handle(vpiTypespec, h)and returns itsDefName(user-defined types such as structs, enums, typedefs) orNameifDefNameis absent.- Attempts to classify the object as a known
VarTypeand returns itsDisplaystring (e.g."logic","int"). - Falls back to
vpi_get_str(vpiType, h)which returns the raw VPI object-type string (e.g."vpiNet","vpiReg").
Returns None for null handles or when none of the above produce a
valid string.
Sourcepub fn get_var_type(&self) -> Option<VarType>
pub fn get_var_type(&self) -> Option<VarType>
Returns this object’s variable kind, if the handle refers to a variable.
Reads vpiType and maps the result to a VarType variant.
Returns None for null handles or non-variable object types.
Sourcepub fn get_size(&self) -> Option<u32>
pub fn get_size(&self) -> Option<u32>
Returns this object’s size, i.e., number of elements, if available.
Sourcepub fn get_raw_property(&self, property: Property) -> Option<PLI_INT32>
pub fn get_raw_property(&self, property: Property) -> Option<PLI_INT32>
Reads a numeric property using vpi_get and returns it as PLI_INT32.
Returns None for null handles.
To obtain specific types like u32, u64, or i64, use the corresponding methods: get_u32, get_u64, or get_i64.
To obtain other types use the corresponding methods.
Source§impl Handle
impl Handle
Sourcepub fn put_value(&self, value: &Value) -> Handle
pub fn put_value(&self, value: &Value) -> Handle
Writes a value to this handle using vpi_put_value with no delay.
Returns a null handle when this handle is null. Otherwise returns the event handle returned by the simulator (which may also be null).
Sourcepub fn put_value_scheduled(
&self,
value: &Value,
time: Option<&Time>,
delay: PutValueDelay,
flags: &PutValueFlags,
) -> Handle
pub fn put_value_scheduled( &self, value: &Value, time: Option<&Time>, delay: PutValueDelay, flags: &PutValueFlags, ) -> Handle
Writes a value to this handle using vpi_put_value with optional scheduling.
time is ignored when delay is PutValueDelay::NoDelay.
Returns a null handle when this handle is null. Otherwise returns the
event handle returned by the simulator (which may also be null).
Sourcepub fn put_int_value(&self, value: i32) -> Handle
pub fn put_int_value(&self, value: i32) -> Handle
Writes an integer value to this handle using vpi_put_value with no delay.
Returns a null handle when this handle is null. Otherwise returns the event handle returned by the simulator (which may also be null).
Sourcepub fn put_value_array(&self, values: impl AsRef<[Value]>) -> bool
Available on crate feature value_array only.
pub fn put_value_array(&self, values: impl AsRef<[Value]>) -> bool
value_array only.Writes an array of values to this handle using vpi_put_value_array.
The input slice must be homogeneous and currently supports integer,
short integer, long integer, real, short real, and time values.
Returns false for null handles or unsupported/mixed value slices.
Sourcepub fn put_value_array_with_flags(
&self,
values: impl AsRef<[Value]>,
start_index: i32,
flags: PutValueArrayFlags,
) -> bool
Available on crate feature value_array only.
pub fn put_value_array_with_flags( &self, values: impl AsRef<[Value]>, start_index: i32, flags: PutValueArrayFlags, ) -> bool
value_array only.Writes an array of values to this handle using vpi_put_value_array.
start_index selects the first array element to update.
Returns false for null handles or unsupported/mixed value slices.
Sourcepub fn get_value(&self, format: ValueType) -> Option<Value>
pub fn get_value(&self, format: ValueType) -> Option<Value>
Reads a value from this handle in the requested format.
If format is ValueType::ObjType, the simulator may override the
requested format with the object’s native value format. In that case,
this method returns the matching concrete Value variant rather than
always returning Value::ObjType.
Returns None for null handles or unsupported formats.
Sourcepub fn get_value_array(&self, format: ValueType) -> Option<Vec<Value>>
Available on crate feature value_array only.
pub fn get_value_array(&self, format: ValueType) -> Option<Vec<Value>>
value_array only.Retrieve an array of values from a Verilog object (e.g., memory array, packet array).
This function calls vpi_get_value_array to fetch multiple values at once.
It handles various value formats and automatically allocates the necessary memory.
§Arguments
format- The format of values to retrieve (Int, Real, Time, etc.)
§Returns
Some(Vec<Value>)- A vector of retrieved valuesNone- If the handle is null or the operation fails
§Example
let mem = root.scan(vpi_sys::vpiMem)?;
if let Some(values) = mem.get_value_array(ValueType::Int) {
for (i, val) in values.iter().enumerate() {
println!("Memory[{}] = {}", i, val);
}
}