写在前面:为了解狄摩根定理和布尔函数的行为,我们使用 Verilog 实现狄摩根定律和布尔函数的行为。生成输入信号后,验证通过仿真实现的结果。
否定量词的狄摩根定律是:
由表中推理可知:
¬ ¬
¬ ¬
可以将 ¬ 想象成一只青蛙,而这就是个青蛙跳,每跳一级任意变存在,存在变任意。
狄摩根定律将 和 运算互换,取各变量的否定。
狄摩根第一定律:
狄摩根第二定律:
比较 的 Schematic ,完成 Verilog 编码,通过仿真比较输出结果。
Design source(A):
`timescale 1ns / 1ps
module Boolean_Function_1_a (
input a, b, c,
output d
);
assign d = (~a | ~b) & ~c;
endmodule
Testbench(A):
`timescale 1ns / 1ps
module Boolean_Function_1_a_tb;
reg aa, bb, cc;
wire d;
Boolean_Function_1_a u_Boolean_Function_1_a (
.a(aa),
.b(bb),
.c(cc),
.d(d)
);
initial aa = 1'b0;
initial bb = 1'b0;
initial cc = 1'b0;
always aa = #100 ~aa;
always bb = #200 ~bb;
always cc = #400 ~cc;
initial begin
#1000
$finish;
end
endmodule
运行结果如下:
Design source(B):
`timescale 1ns / 1ps
module Boolean_Function_1_b(
input a, b, c,
output d
);
assign d = ~((a & b) | c);
endmodule
Testbench(B):
`timescale 1ns / 1ps
module Boolean_Function_1_b_tb;
reg aa, bb, cc;
wire d;
Boolean_Function_1_b u_Boolean_Function_1_b(
.a(aa),
.b(bb),
.c(cc),
.d(d)
);
initial aa = 1'b0;
initial bb = 1'b0;
initial cc = 1'b0;
always aa = #100 ~aa;
always bb = #200 ~bb;
always cc = #400 ~cc;
initial begin
#1000
$finish;
end
endmodule
运行结果如下:
比较 的 Schematic ,完成 Verilog 编码,通过仿真比较输出结果。
Design source(A):
`timescale 1ns / 1ps
module Boolean_Function_2_a (
input a, b, c,
output d
);
assign d = (~a & ~b) | ~c;
endmodule
Testbench(A):
`timescale 1ns / 1ps
module One_Bit_tb;
reg aa, bb;
wire c, d, e, f;
One_Bit u_One_Bit (
.a(aa),
.b(bb),
.c(c),
.d(d),
.e(e),
.f(f)
);
initial aa = 1'b0;
initial bb = 1'b0;
always aa = #100 ~aa;
always bb = #200 ~bb;
initial begin
#2000
$finish;
end
endmodule
运行结果如下:
Design source(B):
`timescale 1ns / 1ps
module Boolean_Function_2_b (
input a, b, c,
output d
);
assign d = ~( (a | b) & c );
endmodule
Testbench(B):
`timescale 1ns / 1ps
module Boolean_Function_2_b_tb;
reg aa, bb, cc;
wire d;
Boolean_Function_2_b u_Boolean_Function_2_b(
.a(aa),
.b(bb),
.c(cc),
.d(d)
);
initial aa = 1'b0;
initial bb = 1'b0;
initial cc = 1'b0;
always aa = #100 ~aa;
always bb = #200 ~bb;
always cc = #400 ~cc;
initial begin
#1000
$finish;
end
endmodule
运行结果如下:
1bit 比较器的 Schematic ,完成 Verilog 编码,通过仿真比较输出结果。
Design source:
`timescale 1ns / 1ps
module One_Bit (
input a, b,
output c, d, e, f
);
assign c = ( a == b );
assign d = ( a != b );
assign e = ( a > b );
assign f = ( a < b );
endmodule
Testbench:
`timescale 1ns / 1ps
module One_Bit_tb;
reg aa, bb;
wire c, d, e, f;
One_Bit u_One_Bit (
.a(aa),
.b(bb),
.c(c),
.d(d),
.e(e),
.f(f)
);
initial aa = 1'b0;
initial bb = 1'b0;
always aa = #100 ~aa;
always bb = #200 ~bb;
initial begin
#2000
$finish;
end
endmodule
运行结果如下:
[ 笔者 ] 王亦优
[ 更新 ] 2023.1.20
❌ [ 勘误 ] /* 暂无 */
[ 声明 ] 由于作者水平有限,本文有错误和不准确之处在所难免,
本人也很想知道这些错误,恳望读者批评指正!
参考资料 Introduction to Logic and Computer Design, Alan Marcovitz, McGrawHill, 2008 Microsoft. MSDN(Microsoft Developer Network)[EB/OL]. []. . 百度百科[EB/OL]. []. https://baike.baidu.com/. |