In order to code HDL, how to avoid using break statements in loops
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Life is Wonderful
am 11 Nov. 2022
Bearbeitet: Life is Wonderful
am 11 Nov. 2022
Since I'm seeking for HDL code that doesn't allow the break, continue statement, I need help with the following code logic to stop the break statement from being executed.
case 1:
clc;
eps = 5;
x = 1:5;
y = zeros(5,1);
fprintf('%10s|%10s|\n----------+----------+\n','n','y(n)');
for idx = 1:length(x)
y(idx) = x(idx) + 1;
if(y(idx) > eps)
break;
end
fprintf('%10d|%10d|\n',idx,y(idx));
end
case : 2
clc;
eps = 5;
x = 1:5;
y = zeros(5,1);
fprintf('%10s|%10s|\n----------+----------+\n','n','y(n)');
for idx = 1:length(x)
y(idx) = x(idx) + 1;
if(y(idx) > eps)
idx = 1;
end
fprintf('%10d|%10d|\n',idx,y(idx));
end
Because more iterations are being executed, case 2's results are incorrect.
Thank you!!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu HDL Coder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!