多重Switchを使いif文の実装
Show older comments
Switchブロックを使いif文を実装していますが、
条件が同じ幅で増加する条件でSwitchブロックを何個も並列で繋げるのはさすがにきれいには見えない、
読みにくくなるため質問します。
下記のif文を例としたら簡単に実装する方法は何がありますか?
always@(posedge clk or negedge resetn)begin
if(~resetn)begin
x<=4'b0000;
end
if(a==1)
x<=4'b0001;
else if(a==2)
x<=4'b0001;
else if(a==3)
x<=4'b0010;
else if(a==4)
x<=4'b0100;
else if(a==5)
x<=4'b1000;
else if(a==6)
x<=4'b1001;
.....
end
このように同じ幅を持つ条件がある場合ただ単にSwitchブロックを並ばせるしかないのでしょうか?
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!