Inferring RAM zero index issue

조회 수: 1 (최근 30일)
Robert Fifield
Robert Fifield 2021년 11월 12일
답변: Ion CASU 2023년 6월 9일
Hi,
I'm using Simulink with HDL coder and would like to create a resettable RAM using a Matlab Fnc. I can infer a RAM using the code below:
function rd_data = ram(wr_en, wr_addr, wr_data, rd_addr)
%% Define vars
persistent mem_data
%% Setup var types
if isempty(mem_data)
mem_data = zeros(1,2^wr_data.WordLength);
end
rd_data_int = mem_data(rd_addr+1);
rd_data = fi(rd_data_int,numerictype(wr_data));
if wr_en == 1
mem_data(wr_addr+1) = wr_data;
end
end
However I have to use the +1 for the array index to avoid zero indexing the matlab array and this +1 propagates into the HDL code.
I would be very grateful for some guidance as to how to avoid this issue and not have the +1 in my HDL code.
I don't want to use the system RAM as I would like to implement a resettable RAM which I don't this is supported.
Thank you

답변 (2개)

Kiran Kintali
Kiran Kintali 2021년 11월 12일
Can you MATLAB code (dut.m) and a Testbench (dut_tb.m) and the project file with MATLAB to HDL codegen settings?
This example shows a typical RAM setup.
>> mlhdlc_demo_setup('heq')

Ion CASU
Ion CASU 2023년 6월 9일
I am having the same issue. Could anyone explain how to avoid it, please?

카테고리

Help CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by