Kernel

Struct Kernel 

Source
pub struct Kernel { /* private fields */ }
Expand description

一张重采样系数表:64 个相位 × L 个抽头。

Implementations§

Source§

impl Kernel

Source

pub fn identity() -> Kernel

直通核:输出等于 CONV 时刻之前最近的一个抽取样点,不滤波、不插值(4 抽头,只有一个系数为 1)。

配合 r = 0 和整数周期的内部发生器,可以得到未经处理的 ADC 采样值。

Source

pub fn sinc(taps: usize, fc: f64, beta: f64) -> Result<Kernel>

Kaiser 窗 sinc 低通:截止频率 fc(以抽取后的采样率归一化,0 < fc < 0.5),窗参数 beta(常用 6)。

近似理想的带限插值;不补偿 CIC 下垂,适合 r = 0。

Source

pub fn average(taps: usize, width: f64) -> Result<Kernel>

滑动平均:以 CONV 时刻为中心、宽度为 width 个抽取样点的平均。降噪最多,带宽最窄。

Source

pub fn cubic() -> Kernel

Catmull–Rom 三次插值(4 抽头):延迟最小,几乎不降噪。

Source

pub fn least_squares(taps: usize, fp: f64, fs: f64, r: u8) -> Result<Kernel>

逐相位加权最小二乘设计:通带 [0, fp] 内的增益等于 CIC 响应的倒数(补偿 R = 2^r 的下垂), 阻带 [fs, 0.5] 内为 0(权重 10),直流增益约束为 1。频率以抽取后的采样率归一化。

推荐用于 r > 0。与仓库中 tools/dsp/coeffs.py ls 的设计相同。

Source

pub fn for_bandwidth(bandwidth_hz: f64) -> Result<(u8, Kernel)>

按信号带宽 bandwidth_hz 选抽取指数 r 和滤波核(设计规则见模块说明)。返回 (r, 核)。

带宽上限为 20 MHz(r = 0)。带宽低于 1.25 MHz 时仍用 r = 4,通带相应变窄。

Source

pub fn from_rows(rows: Vec<Vec<i32>>) -> Result<Kernel>

由现成的系数构造:64 行,每行 L 个 Q1.16 整数(L 为 4 的倍数,4..=32,绝对值 < 2^17)。

Source

pub fn from_text(text: &str) -> Result<Kernel>

解析文本格式:64 行,每行 L 个以空白分隔的十进制整数(s1m4_host.py coef=<文件> 使用的格式)。

Source

pub fn to_text(&self) -> String

输出为 Kernel::from_text 的文本格式。

Source

pub fn taps(&self) -> usize

抽头数 L。

Source

pub fn rows(&self) -> &[Vec<i32>]

系数表:rows()[相位][抽头],Q1.16。

Source

pub fn gain(&self, nu: f64) -> f64

滤波核在归一化频率 nu(周期 / 抽取后样点)处的幅度响应,对 64 个相位取平均。不含 CIC。

Source

pub fn chain_gain(&self, f_hz: f64, r: u8) -> f64

整条数字通路(R = 2^r 的 CIC 抽取 + 本滤波核)在信号频率 f_hz 处的幅度增益(标称采样率下)。

Source

pub fn noise_gain(&self, r: u8) -> f64

整条数字通路的噪声增益(输出噪声方差 / 输入白噪声方差),对相位取平均。

输出噪声 σ_y ≈ σ_x · √NG。实际板上的噪声不完全是白噪声,高增益量程下实测值高于此估计。

Source

pub fn max_event_rate(&self) -> f64

引擎用本核时能处理的最高 CONV 事件速率(事件/秒,每组):100 MHz ÷ (L/4 + 3)。

Trait Implementations§

Source§

impl Clone for Kernel

Source§

fn clone(&self) -> Kernel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Kernel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Kernel

Source§

fn eq(&self, other: &Kernel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Kernel

Source§

impl StructuralPartialEq for Kernel

Auto Trait Implementations§

§

impl Freeze for Kernel

§

impl RefUnwindSafe for Kernel

§

impl Send for Kernel

§

impl Sync for Kernel

§

impl Unpin for Kernel

§

impl UnwindSafe for Kernel

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.