HDL Coder: Block RAM utilization for MATLAB Function block
Show older comments
Hello,
I am having trouble generating Block RAM from Simulink.
I followed this Block Ram Sobel example to create my own Block Ram using Matlab. This works fine using Matlab and the HDL Coder. I can see in the resource report that 2048x14-bit RAM : 1 has been selected as desired.
Now I included the same Matlab code (converted to fixed point) as a Matlab function block into a Simulink model. Using the HDL workflow advisor I can generate VHDL code. But in the resource report I can see that no RAM was used but instead 22425 1-Bit-Registers (1600 * 14 Bit):

In the example project they make sure to turn on "Map persistent array variables to RAM" in the Optimizations section of the Code generation. The closest I found in the HDL Workflow Advisor for Simulink was the "Map pipeline delays to RAM". Like shown here:

Why do I get Registers instead of Block RAM? There is obviously also no dual port RAM file that was created in the VHDL file directory. I added the matlab scripts to this post and this is how my Simulink model looks like (the HDL part only includes the simpleBlockRam_fixpt.m matlab function).
I am grateful for any hints. I also tried looking online first but without any luck. In case I missed something I am also happy about how somebody else solved this kind of problem.
Thanks!
2 Comments
Kiran Kintali
on 3 Apr 2017
With the MapPersistentVarsToRAM implementation parameter, you can use RAM-based mapping for persistent arrays of a MATLAB Function block instead of mapping to registers.
Please make sure this option is turned-on on the MATLAB function block.
Fabig
on 3 Apr 2017
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with HDL Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!