Finding bugs in code_01_MUX
网站链接
题目描述-Bugs mux2
This 8-bit wide 2-to-1 multiplexer doesn’t work. Fix the bug(s).
写一个2选1多路器
即
sel=1 输出a,sel=0,输出b
Module Declaration
module top_module (
input sel,
input [7:0] a,
input [7:0] b,
output [7:0] out );
参考资料
代码部分
//2选1多路器
//sel=1 输出a,sel=0,输出b
module top_module (
input sel,
input [7:0] a,
input [7:0] b,
output [7:0]out );//8位输出,这里没有写位宽,补上
//原来错误语句,按位与,再按位或
//assign out = (~sel & a) | (sel & b);
//正确
assign out = sel?a:b;
endmodule