专栏前言
本专栏的内容主要是记录本人学习Verilog过程中的一些知识点,刷题网站用的是牛客网


分析
将变量A、B接入4选1数据选择器选择输入端S0 S1。将变量C分配在数据输入端。从表中可以看出输出L与变量C的关系。
当AB=00时选通D0而此时L=0,所以数据端D0接0:当AB=01时选通D1,由真值表得此时L=C,即D1应接C:当AB为10和11时,D2和D3分别接~C和1。
- `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 d(
- .S0(B ),
- .S1(A ),
- .D0(0 ),
- .D1(C ),
- .D2(~C ),
- .D3(1 ),
-
- .Y(L )
- );
-
- endmodule