how can i create a delay block(like in simulink) with matlab code
8 次查看(过去 30 天)
显示 更早的评论
I do a FFT project, the data go in and delay for some clock to wait the next data and caculate butterfly. Example if i delay 8 clock then simulink generate 8 register(dff) and shift them every clock, and i want do that in matlab code to generate HDL code. Some one can help me? Thank you!
0 个评论
回答(2 个)
Kiran Kintali
2017-8-15
编辑:Walter Roberson
2021-5-31
delay in MATLAB can be modeled using persistent variable.
function y = fcn(u) % Unit delay implementation that maps to a register in hardware
persistent u_d;
if isempty(u_d)
% defines initial value driven by unit delay at time step 0
u_d = cast(0, 'like', u);
end
% return delayed input from last sample time hit
y = u_d;
% store the current input
u_d = u;
https://www.mathworks.com/matlabcentral/fileexchange/16100-modelling-registers-in-embedded-matlab you may want to check out the above post.
1 个评论
Conner Garcia
2021-5-31
this hasnt worked, the outputs are different. the link you sent i think there is an error when converting from Uint to a Fi object.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!