Skip to main content

VectorRegisters

Trait VectorRegisters 

Source
pub trait VectorRegisters<CustomError = CustomErrorPlaceholder>
where Self: VectorRegistersBase + SupportedElenVlen<{ Self::ELEN }, { Self::VLEN }>,
{ // Required methods fn read_vreg(&self) -> &VectorRegisterFile<{ _ }>; fn write_vreg(&mut self) -> &mut VectorRegisterFile<{ _ }>; fn vtype(&self) -> Option<Vtype<{ Self::ELEN }, { Self::VLEN }>>; fn set_vtype( &mut self, vtype: Option<Vtype<{ Self::ELEN }, { Self::VLEN }>>, ); fn vl(&self) -> u32; fn set_vl(&mut self, vl: u32); fn vector_instructions_allowed(&self) -> bool; fn mark_vs_dirty(&mut self); // Provided methods fn compute_vl(&self, avl: u32, vlmax: u32) -> u32 { ... } fn vlmax_for_vtype( &self, vtype: Vtype<{ Self::ELEN }, { Self::VLEN }>, ) -> u32 { ... } }
Expand description

Vector register state.

This trait contains only methods that implementations genuinely need to provide. Derived accessors for simpler CSRs are in VectorRegistersExt.

Note that due to Rust type system limitations, you should use VectorRegistersExt in trait bounds instead of this trait directly or else the solver will fail.

Methods for vtype and vl live here (not in the ext trait) because they have non-trivial update semantics: vtype must maintain a cached decoded form and handle the XLEN-dependent vill bit, and vl is read-only via CSR instructions but writable by vsetvl{i} and fault-only-first loads.

ELEN is the maximum element width in bits.

Required Methods§

Source

fn read_vreg(&self) -> &VectorRegisterFile<{ _ }>

Read the vector register file

Source

fn write_vreg(&mut self) -> &mut VectorRegisterFile<{ _ }>

Mutable access to the vector register file

Source

fn vtype(&self) -> Option<Vtype<{ Self::ELEN }, { Self::VLEN }>>

Get the current decoded vtype

Source

fn set_vtype(&mut self, vtype: Option<Vtype<{ Self::ELEN }, { Self::VLEN }>>)

Set the vtype register from a decoded Vtype.

The implementation must update both its internal decoded cache and the raw CSR value (for reads via Zicsr, writes via Zicsr are not allowed).

Source

fn vl(&self) -> u32

Get the current vl

Source

fn set_vl(&mut self, vl: u32)

Set vl.

The implementation must update both its internal decoded cache and the raw CSR value (for reads via Zicsr, writes via Zicsr are not allowed).

Source

fn vector_instructions_allowed(&self) -> bool

Check whether vector instructions are currently permitted.

Returns false when mstatus.VS == Off (or equivalent like sstatus/vstatus). In environments without these status registers, returns true always.

Source

fn mark_vs_dirty(&mut self)

Mark the vector state as dirty.

Must set VS to Dirty in mstatus (and sstatus/vsstatus shadows) when those registers exist. No-op otherwise.

Provided Methods§

Source

fn compute_vl(&self, avl: u32, vlmax: u32) -> u32

Compute vl from AVL and VLMAX per spec constraints.

The simplest compliant implementation (which is used by default) is min(AVL, VLMAX). More sophisticated implementations may return values in [ceil(AVL/2), VLMAX] for AVL < 2*VLMAX, but this simple strategy satisfies all three spec requirements.

Source

fn vlmax_for_vtype(&self, vtype: Vtype<{ Self::ELEN }, { Self::VLEN }>) -> u32

Compute VLMAX for a given vtype

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§