Matlab function block optimization (HDL Coder)

4 views (last 30 days)
I would like to know which would be the best way of optimizing (in terms of speed) a moving average filter written as a Matlab function with 8 parallel channels at the input and one output channel. Concretely my question targets pipelining, I/O pipeline registers, loop unrolling, etc.
Regards.

Answers (2)

Girish Venkataramani
Girish Venkataramani on 3 Mar 2014
Which version of MATLAB are you using? Assuming it is a fixed-point algorithm, you can right click on the MATLAB function block, and choose 'HDL Code -> HDL Block Properties'. In this dialog, you can set input/output pipelining. If you also set 'LoopOptimization' to 'Unroll Loops' and turn on 'Distributed Pipelining', then the output pipelines are retimed to inside the MATLAB algorithm. If you really want to control the placement of registers, you can call out the MATLAB variables in your code on which you want to place registers by typing them in to the 'VariablesToPipeline' field.
Some of these features may not be available to you depending on the release of MATLAB you are using. Hope this works.
  1 Comment
Jesus
Jesus on 3 Mar 2014
Thanks for the answer. My Matlab version is R2012a, so I guess I don't have the 'VariablesToPipeline' feature . My main concern is how to deal with a Matlab function which currently does not fulfill the required timing constraints. It is a moving average filter that accepts a sample-based input of 8 channels and a single sampled output channel.
The tuning parameters will be: distributed pipelining (on/off), input/output pipeline registers, constrainedOutputPipeline, loop unrolling, balance delays, and so on. As far as I understand distributed pipelining is not feasible inside Matlab functions, so which will be a good approach for speed optimization?

Sign in to comment.


Girish Venkataramani
Girish Venkataramani on 10 Mar 2014
Yes, with 12a, you will not have the 'VariablesToPipeline' feature. But still you can use the the parameters you have mentioned, i.e., input/output pipelining, loop unrolling and distributed pipelining (keep balance-delays = on for the whole model). You need to set DistrbutedPipelining on the MATLAB block (through the right-click menu I mentioned in my previous reply). If you set it on the subsystem containing the MATLAB block it won't work. As long as your code does not have too much control flow, this should help.

Products

Community Treasure Hunt

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

Start Hunting!