请用Verilog HDL语言编写实现四位数据总线宽度的四选一数据选择器,并使输出有三态功能

如题所述

第1个回答  2019-05-20
你好,下面是对应的verilog

module test(out, sel,en)

input [1:0] sel;
output [4:0] out;
input en;

reg [3:0] output;
wire [1:0] sel;

always @*
begin
case (sel)
2'b00: output = in0;
2'b01: output = in1;
2'b10: output = in2;
2'b11: output = in3;
endcase
end

assign out[3:0] = en ? output : 4'bxxxx;

endmodule本回答被网友采纳
相似回答