/例1
a = (b==c) ? 1 : 2;
//等价于if else 语句
if(b==c) begin
a = 1;
end
else begin
a = 2;
end
/例2
a = (b==1) ? 1 :
(b==2) ? 2 :
(c==3) ? 3 : 4;
//等价于if else 语句
if(b==1) begin
a = 1;
end
else if(b==2) begin
a = 2;
end
else if(b==3) begin
a = 3;
end
else begin
a = 4;
end
//等价于case语句
case(a)
1 : a =1;
2 : a =2;
3 : a =3;
default : 4;
endcase
12-13
7649
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-27
416
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-27
6162
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交