how can i create a delay block(like in simulink) with matlab code

조회 수: 8 (최근 30일)
Tien Pham
Tien Pham 2017년 8월 14일
편집: Walter Roberson 2021년 5월 31일
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!

답변 (2개)

Kiran Kintali
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;
  댓글 수: 1
Conner Garcia
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.

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


Gareth Thomas
Gareth Thomas 2017년 8월 14일
Have you tried the pause command?
  댓글 수: 1
Tien Pham
Tien Pham 2017년 8월 14일
No, it is register when i generate HDL code. I do a FFT project, the data go in and delay for some clock to wait the next data and caculate butterfly. If i delay 8 clock then simulink generate 8 register and shift them every clock, and i want do that in matlab code to generate HDL code. Sorry my English is weak, thank you!

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

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by