题解 | #数据选择器实现逻辑电路#
数据选择器实现逻辑电路
https://www.nowcoder.com/practice/00b0d01b71234d0b97dd4ab64f522ed9
`timescale 1ns/1ns
module data_sel(
input S0 ,
input S1 ,
input D0 ,
input D1 ,
input D2 ,
input D3 ,
output wire Y
);
assign Y = ~S1 & (~S0&D0 | S0&D1) | S1&(~S0&D2 | S0&D3);
endmodule
module sel_exp(
input A ,
input B ,
input C ,
output wire L
);
/*
data_sel U0(
.S0(B),
.S1(A),
.D0(0),
.D1(C),
.D2(~C),
.D3(1),
.Y(L)
);
*/
data_sel U0(
.S0(C),
.S1(A),
.D0(0),
.D1(B),
.D2(1),
.D3(B),
.Y(L)
);
endmodule
/*
A B C L S0 S1 D0 D1 D2 D3 Y
0 0 * 0 0 0 D0
0 1 C 1 0 D1
1 0 ~C 0 1 D2
1 1 1 1 1 D3
*/
/*
A C B L S1 S0 D0 D1 D2 D3 Y
0 0 * 0 0 0 D0
0 1 B 0 1 D1
1 0 1 1 0 D2
1 1 B 1 1 D3
*/
