HDLBits刷题合集—8 Multiplexers
HDLBits-61 Mux2to1
Problem Statement
创建一个1位宽的2选1数据选择器。当sel=0时,选择a;当sel=1时,选择b。
代码如下:
module top_module(
input a, b, sel,
output out );
assign out = sel ? b : a;
//assign out = (sel & b) | (~sel & a);
endmodule
HDLBits-62 Mux2to1v
Problem Statement
创建一个100位宽的2选1数据选择器。当sel=0时,选择a;当sel=1时,选择b。
代码如下:
module top_module(
input [99:0] a, b,
input sel,
output [99:0] out );
assign out = sel ? b