真值表
选择输入 | 输出 |
---|---|
s1 s0 | z0 z1 z2 z3 |
0 0 | c 1 1 1 |
0 1 | 1 c 1 1 |
1 0 | 1 1 c 1 |
1 1 | 1 1 1 c |
代码
module de_selector14(iC,iS1,iS0,oZ0,oZ1,oZ2,oZ3);
input iC;
input iS1;
input iS0;
output oZ0;
output oZ1;
output oZ2;
output oZ3;
reg oZ0,oZ1,oZ2,oZ3;
initial
{oZ0,oZ1,oZ2,oZ3}=4'b1111;
always@(*)
case({iS1,iS0})
2'b00 : begin
oZ0=iC; oZ1=1'b1; oZ2=1'b1; oZ3=1'b1;
end
2'b01 : begin
oZ0=1'b1; oZ1=iC; oZ2=1'b1; oZ3=1'b1;
end
2'b10 : begin
oZ0=1'b1; oZ1=1'b1; oZ2=iC; oZ3=1'b1;
end
2'b11 : begin
oZ0=1'b1; oZ1=1'b1; oZ2=1'b1; oZ3=iC;
end
endcase
endmodule
真值表
选择输入 | 输出 |
---|---|
s1 s0 | z0 z1 z2 z3 |
0 0 | c 0 0 0 |
0 1 | 0 c 0 0 |
1 0 | 0 0 c 0 |
1 1 | 0 0 0 c |
代码
module de_selector14(iC,iS1,iS0,oZ0,oZ1,oZ2,oZ3);
input iC;
input iS1;
input iS0;
output oZ0;
output oZ1;
output oZ2;
output oZ3;
assign oZ0=~iS1 & ~iS0 & iC;
assign oZ1=~iS1 & iS0 & iC;
assign oZ2= iS1 & ~iS0 & iC;
assign oZ3= iS1 & iS0 & iC;
endmodule
真值表
选择输入 | 输出 |
---|---|
s1 s0 | z0 z1 z2 z3 |
0 0 | c x x x |
0 1 | x c x x |
1 0 | x x c x |
1 1 | x x x c |
代码
此处留白,作思考题。
反思
真值表的不同会影响verilog描述,因此需要认真考虑逻辑表达式,选择正确的结构,满足真值表的要求。