FIRディジタルフィルターの実験 / 移動平均
参考: FIR Filter (VHDL) - Logic - Engineering and Component Solution Forum - TechForum │ Digi-Key
上の記事にあるFIRフィルターモジュールを使う。オーバーフローしないようにビット拡張をしてから定義どおりに積和演算をしているだけである。ただし乗算器は下のように明示的にMAX10 FPGAのDSPブロックに置いた。
--productsに乗算結果を入れる。 signal products : product_array(0 to TAPS - 1)(DATA_WIDTH + COEFF_WIDTH - 1 downto 0); --array of coefficient*data products attribute multstyle : string; attribute multstyle of products : signal is "dsp";
すべてのタップを同じ係数で重み付けして移動平均をとってみる。一種のローパスフィルターである。周波数特性が見たいだけなので、係数は全部同じであればとりあえず何でもよい。タップ数は16、サンプリング周波数は40 kHzにした。
ファイル一式: https://github.com/ti-nspire/VHDL_for_Quartus_Prime/tree/main/fir_filter_moving_average
coefficients => ( (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000"), (8b"1000_0000") )