I want to generate HDL from a System Object that contains several dsp.FIRFilter objects, the number of which is determined by a Nontunable property

I'm trying to develop a generic System Object that utilizes dsp.FIRFilter objects. I want my class to determine and construct the number of dsp.FIRFilter objects required and compute their corresponding coefficient sets from a fixed, NonTunable property value.
My first thought was to allocate a cell array of dsp.FIRFIlter objects in setupImpl(), but this is not supported for HDL generation, as described in the documentation, here. The examples linked there all create properties for each individual object, which doesn't help for this use case, where the number is not known a priori, but is fixed during initiialization.
Is there a recommended way to accomplish what I'm trying to do without cell arrays?
Thanks!
Paul

 Accepted Answer

You are correct. HDL Coder (and hardware modeling in general) does not support dynamic behavior in MATLAB code. All structural aspects such as the number of filters must be determined at compile time using non-tunable constants. For example, define MAX_Filters and other parameters that cannot be dynamic (like sizes of the arrays etc.,) as compile-time constants so the hardware can be synthesized correctly.
You can use one of these two recommended patterns:
Pattern A – Parallel Filters with a Fixed Upper Bound
  • Think of this as a filter bank where all filters run simultaneously.
  • Decide on a maximum number of filters (e.g., 4) and create that many filter objects upfront.
  • Every input sample passes through all filters in parallel, producing a vector of outputs (one per filter).
  • Pros: Full throughput; all channels processed at once.
  • Cons: Higher hardware resource usage.
Pattern B – One Filter, Time-Multiplexed
  • Use a single filter object and store all coefficient sets.
  • Switch coefficients after each sample or frame, cycling through channels in a round-robin fashion.
  • Pros: Saves hardware resources (only one filter).
  • Cons: Lower throughput because channels share the same filter over time.
  • You also output a tag indicating which channel was processed.
Based on your input, where the number of filters is fixed after initialization but unknown beforehand, Pattern B might be your best choice. You can define a MAX_Filters constant and use up to that maximum based on an input variable. Additional control logic (e.g., valid and ready signals) can track which filter bank is being processed and manage data flow accordingly.
If you need help authoring this MATLAB code please do not hesitate to reach out to technical support team.

3 Comments

Thanks for your answer, Kiran. This is disappointing as it prevents me from using System Objects in this context. What I ultimately did was write mask initialization code to instantiate the FIR objects based on mask parameter computations and connect the inputs with Demux and Vector concatenation blocks. That works fine, but seems like a clumsier solution.
Can you please file a request to the technical suppot with your workaround and the necessary improvements?
Kiran, Thank you for following up. I will file a request.

Sign in to comment.

More Answers (0)

Products

Release

R2025b

Asked:

on 18 Dec 2025

Commented:

on 16 Jan 2026

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!