What wrong with that counter ?
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
function [wr,count] = wr_blk(rst,clk,sig)
%#codegen
count = 0;
if (rst==0)
wr=0;
else
if((sig==1) && (clk==1))
count = count + 1;
else
count=0;
end
end
end
Thanks, Henry
9 件のコメント
Torsten
2015 年 12 月 9 日
You don't set return parameter "wr" in case that rst is not zero.
And - as far as I can see - there is one "end" too much.
Best wishes
Torsten.
Henry Buck
2015 年 12 月 9 日
Torsten
2015 年 12 月 9 日
The counter will never increment to 4 since you reset it to zero each time you call the function. Thus the maximum value count can be is one.
Best wishes
Torsten.
Henry Buck
2015 年 12 月 9 日
Henry Buck
2015 年 12 月 9 日
count = sum((sig==1) & (clk==1));
if sig and clk are arrays of the same size.
Best wishes
Torsten.
Henry Buck
2015 年 12 月 9 日
Torsten
2015 年 12 月 9 日
I guess that's what my suggested solution does.
My line of code outputs the number of ones in the array clk at the positions where sig = 1.
Best wishes
Torsten.
Henry Buck
2015 年 12 月 9 日
回答 (0 件)
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!