Skip to main content

VectorRegistersExt

Trait VectorRegistersExt 

Source
pub trait VectorRegistersExt
where Self: VectorRegisters + Csrs<<<Self as VectorRegisters>::Hart as HartConfig>::Reg>,
{ // Provided methods fn initialize_vector_state(&mut self) { ... } fn vstart(&self) -> Vstart { ... } fn set_vstart(&mut self, vstart: Vstart) { ... } fn reset_vstart(&mut self) { ... } fn vxsat(&self) -> bool { ... } fn set_vxsat(&mut self, vxsat: bool) { ... } fn vxrm(&self) -> Vxrm { ... } fn set_vxrm(&mut self, vxrm: Vxrm) { ... } fn vector_config(&self) -> Option<VectorConfig<Self::Hart>> { ... } fn set_vector_config( &mut self, vector_config: Option<VectorConfig<Self::Hart>>, ) { ... } }
Expand description

Derived convenience accessors for vector CSRs that are simple read/write fields (vstart, vxrm, vxsat, vcsr).

Intended for types that implement both VectorRegisters and Csrs.

NOTE: While the default methods implemented via the Csrs trait are correct, custom higher-performance implementations are often possible by overriding them and, for example, caching various CSRs as separate pre-decoded values rather than going through a generic code path with XLEN-sized raw CSR values during reads.

Provided Methods§

Source

fn initialize_vector_state(&mut self)

Initialize the vector state to the recommended default configuration.

Per spec: vtype.vill = 1, remaining vtype bits = 0, vl = 0. vstart, vxrm, vxsat may have arbitrary values at reset but are zeroed here for deterministic behavior.

Source

fn vstart(&self) -> Vstart

Get current vstart

Source

fn set_vstart(&mut self, vstart: Vstart)

Set vstart.

The default implementation ignores writes to uninitialized CSR in release mode and panics in debug.

Source

fn reset_vstart(&mut self)

Reset vstart to zero.

Per spec, all vector instructions reset vstart to zero at the end of execution.

Source

fn vxsat(&self) -> bool

Get vxsat (single bit)

Source

fn set_vxsat(&mut self, vxsat: bool)

Set vxsat.

The default implementation ignores writes to uninitialized CSR in release mode and panics in debug.

Source

fn vxrm(&self) -> Vxrm

Get vxrm

Source

fn set_vxrm(&mut self, vxrm: Vxrm)

Set vxrm.

The default implementation ignores writes to uninitialized CSR in release mode and panics in debug.

Source

fn vector_config(&self) -> Option<VectorConfig<Self::Hart>>

Get the current vector configuration, None when vill is set.

This is the only source of vtype and vl for instructions. An instruction reads it once and derives everything from that single value, so even an implementation that returns different configurations from different calls can’t make it combine a vl with a vtype it does not belong to.

The default implementation decodes the raw vtype and vl CSRs and treats an inconsistent pair as vill.

Source

fn set_vector_config(&mut self, vector_config: Option<VectorConfig<Self::Hart>>)

Set the vector configuration, None sets vill (and vl to zero).

The implementation must also make the raw vtype and vl values available for reads via Zicsr (writes via Zicsr are not allowed).

The default implementation ignores writes to uninitialized CSR in release mode and panics in debug.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> VectorRegistersExt for &mut T

Source§

fn initialize_vector_state(&mut self)

Source§

fn vstart(&self) -> Vstart

Source§

fn set_vstart(&mut self, vstart: Vstart)

Source§

fn reset_vstart(&mut self)

Source§

fn vxsat(&self) -> bool

Source§

fn set_vxsat(&mut self, vxsat: bool)

Source§

fn vxrm(&self) -> Vxrm

Source§

fn set_vxrm(&mut self, vxrm: Vxrm)

Source§

fn vector_config(&self) -> Option<VectorConfig<Self::Hart>>

Source§

fn set_vector_config(&mut self, vector_config: Option<VectorConfig<Self::Hart>>)

Implementors§