公司动态

verilog HDLBits刷题[Finding bugs in code]“Bugs mux2”---Mux

📅 2026/8/8 20:13:38
verilog HDLBits刷题[Finding bugs in code]“Bugs mux2”---Mux
1、题目2、分析sel为1bit位宽数据a和b作为输入都是8bit位宽故out作为输出根据sel选择输出a或者输出b应该也为8bit位宽1 位sel和8位的a进行位运算sel高位补 0 扩展成 8 位相当于sel8‘b0000_00013、改正代码module top_module ( input sel, input [7:0] a, input [7:0] b, output [7:0]out ); assign out sel?a:b; endmodule 或者 module top_module ( input sel, input [7:0] a, input [7:0] b, output [7:0]out ); assign out ({8{sel}} a) | (~{8{sel}} b); endmodule4、结果