HDL Coder: Block RAM utilization for MATLAB Function block

조회 수: 9 (최근 30일)
Fabig
Fabig 2017년 4월 3일
편집: Stefanie Schwarz 2024년 5월 21일
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
Kiran Kintali
Kiran Kintali 2017년 4월 3일
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
Fabig 2017년 4월 3일
Thank you. That was it. I was first not able to find this configuration menu! With that configuration it works and I also get the desired Block RAM. Thanks!

댓글을 달려면 로그인하십시오.

채택된 답변

Fabig
Fabig 2017년 4월 3일
In case anybody else reads this the solution was quite simple and is as follows: As Kiran Kintali posted it is important to set the MapPersistentVarsToRAM to ON.
Right Click on the model -> HDL-Code -> HDL-Block Properties
The Resource Report then showed for me: 2048x14-bit RAM : 1
Thanks for the help!

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by