题解 | #对信号按位操作#

对信号按位操作

https://www.nowcoder.com/practice/3694a687cd6c4198aa0eb5cd84ffa7df

`timescale 1ns/1ns

module top_module( 
    input [4:0] in,
    output out_and,
    output out_or,
    output out_xor
);
    assign out_and  = &in[4:0];
    assign out_or   = |in[4:0];
    assign out_xor  = ^in[4:0];
    //&in[4:0] 等同于 in[4]&in[3]&in[2]&in[1]&in[0]  |和^同理
endmodule

全部评论
assign out_and = &in[4:0]; assign out_or = |in[4:0]; assign out_xor = ^in[4:0]; 这几条是必须把位宽加上吗?我直接写成assign out_and = ∈这样行不行?
点赞 回复 分享
发布于 2023-08-22 10:30 江苏

相关推荐

不愿透露姓名的神秘牛友
昨天 14:22
点赞 评论 收藏
分享
码砖:求职岗位要突出,一眼就能看到,教育背景放到最后,学校经历没那么重要,项目要重点突出
点赞 评论 收藏
分享
评论
14
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务