pub struct SynapseArray<const N: usize> {
pub count: usize,
pub source_neurons: [u32; N],
pub target_neurons: [u32; N],
pub weights: [u8; N],
pub postsynaptic_potentials: [u8; N],
pub types: [u8; N],
pub valid_mask: [bool; N],
}Expand description
Fixed-size synapse array for embedded systems
All data is stack-allocated with compile-time size limits.
No heap allocations, perfect for no_std environments.
Fields§
§count: usizeCurrent number of synapses
source_neurons: [u32; N]Source neuron IDs
target_neurons: [u32; N]Target neuron IDs
weights: [u8; N]Synaptic weights (0-255)
postsynaptic_potentials: [u8; N]Postsynaptic potentials (0-255)
types: [u8; N]Synapse types (0=excitatory, 1=inhibitory)
valid_mask: [bool; N]Valid synapse mask
Implementations§
Source§impl<const N: usize> SynapseArray<N>
impl<const N: usize> SynapseArray<N>
Sourcepub const fn new() -> SynapseArray<N>
pub const fn new() -> SynapseArray<N>
Create a new fixed-size synapse array
Source§impl<const N: usize> SynapseArray<N>
impl<const N: usize> SynapseArray<N>
Sourcepub fn add_synapse_simple(
&mut self,
source: u32,
target: u32,
weight: u8,
psp: u8,
synapse_type: SynapseType,
) -> bool
pub fn add_synapse_simple( &mut self, source: u32, target: u32, weight: u8, psp: u8, synapse_type: SynapseType, ) -> bool
Add a synapse (simplified for backward compatibility)
Returns true if successful, false if array is full.
Sourcepub fn propagate<const MAX_NEURONS: usize>(
&self,
fired_mask: &[bool; MAX_NEURONS],
contributions: &mut [f32; MAX_NEURONS],
)
pub fn propagate<const MAX_NEURONS: usize>( &self, fired_mask: &[bool; MAX_NEURONS], contributions: &mut [f32; MAX_NEURONS], )
Propagate activity from fired neurons (single-threaded)
Uses platform-agnostic core functions internally.
§Arguments
fired_mask- Which neurons fired (indexed by neuron ID)contributions- Output: accumulated contributions per target neuron (caller-allocated)
Sourcepub const fn memory_footprint() -> usize
pub const fn memory_footprint() -> usize
Get memory footprint in bytes
Trait Implementations§
Source§impl<const N: usize> Default for SynapseArray<N>
impl<const N: usize> Default for SynapseArray<N>
Source§fn default() -> SynapseArray<N>
fn default() -> SynapseArray<N>
Returns the “default value” for a type. Read more
Source§impl<const N: usize> SynapseStorage for SynapseArray<N>
impl<const N: usize> SynapseStorage for SynapseArray<N>
Source§fn source_neurons(&self) -> &[u32]
fn source_neurons(&self) -> &[u32]
Source neuron IDs slice
Source§fn target_neurons(&self) -> &[u32]
fn target_neurons(&self) -> &[u32]
Target neuron IDs slice
Source§fn postsynaptic_potentials(&self) -> &[u8] ⓘ
fn postsynaptic_potentials(&self) -> &[u8] ⓘ
Postsynaptic potentials slice (0-255)
Source§fn valid_mask(&self) -> &[bool]
fn valid_mask(&self) -> &[bool]
Valid synapse mask
Source§fn weights_mut(&mut self) -> &mut [u8] ⓘ
fn weights_mut(&mut self) -> &mut [u8] ⓘ
Mutable weights slice
Source§fn postsynaptic_potentials_mut(&mut self) -> &mut [u8] ⓘ
fn postsynaptic_potentials_mut(&mut self) -> &mut [u8] ⓘ
Mutable postsynaptic potentials slice
Source§fn valid_mask_mut(&mut self) -> &mut [bool]
fn valid_mask_mut(&mut self) -> &mut [bool]
Mutable valid mask
Source§fn add_synapse(
&mut self,
source: u32,
target: u32,
weight: u8,
psp: u8,
synapse_type: u8,
) -> Result<usize, RuntimeError>
fn add_synapse( &mut self, source: u32, target: u32, weight: u8, psp: u8, synapse_type: u8, ) -> Result<usize, RuntimeError>
Add a single synapse
Source§fn remove_synapse(&mut self, idx: usize) -> Result<(), RuntimeError>
fn remove_synapse(&mut self, idx: usize) -> Result<(), RuntimeError>
Remove a single synapse by index
Source§fn remove_synapses_from_sources(
&mut self,
source_neurons: &[u32],
) -> Result<usize, RuntimeError>
fn remove_synapses_from_sources( &mut self, source_neurons: &[u32], ) -> Result<usize, RuntimeError>
Remove all synapses from specific source neurons
Source§fn remove_synapses_between(
&mut self,
source: u32,
target: u32,
) -> Result<usize, RuntimeError>
fn remove_synapses_between( &mut self, source: u32, target: u32, ) -> Result<usize, RuntimeError>
Remove synapses between specific source and target
Source§fn update_weight(
&mut self,
idx: usize,
new_weight: u8,
) -> Result<(), RuntimeError>
fn update_weight( &mut self, idx: usize, new_weight: u8, ) -> Result<(), RuntimeError>
Update weight of a synapse
Source§fn valid_count(&self) -> usize
fn valid_count(&self) -> usize
Get count of valid (non-deleted) synapses
Auto Trait Implementations§
impl<const N: usize> Freeze for SynapseArray<N>
impl<const N: usize> RefUnwindSafe for SynapseArray<N>
impl<const N: usize> Send for SynapseArray<N>
impl<const N: usize> Sync for SynapseArray<N>
impl<const N: usize> Unpin for SynapseArray<N>
impl<const N: usize> UnwindSafe for SynapseArray<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more