1 摩根定律和卡诺图化简
卡诺图画圈应遵循以下原则:
1、取大不取小,圈越大,消去的变量越多,与项越简单,能画入大圈就不画入小圈;
2、圈数越少,化简后的与项就越少;
3、一个最小项可以重复使用,即只要需要,一个方格可以同时被多圈所圈;
4、一个圈中的小方格至少有一个小方格不为其它圈所圈;
5、画圈必须覆盖完每一个填“1”方格为止。
练习
1,
因为只有一个0,可以选择零化简,得到反函数的最简公式的与或
则~(~a&~b&~c)
摩根定理得到out=a|b|c;
module top_module(
input a,
input b,
input c,
output out );
assign out=a|b|c;
endmodule
2 这次只有划圈,因为不熟练,所以就只两两划圈
~a~b~c + ~a~c~d +a~b~c+acd+~abc+~ac~d+~ac~d;
还是比较臃肿,观察之后化简,~b~c+~a~d+acd+~abc;
程序
module top_module(
input a,
input b,
input c,
input d,
output out );
assign out=(~b&~c)|(~a&~d)|(a&c&d)|(~a&b&c);
endmodule
3 不定态下的化简
比较简单,简化思路如下
程序
module top_module(
input a,
input b,
input c,
input d,
output out );
assign out=a|(~b&c);
endmodule
4 卡诺图化简
感觉无法化简,只能每个状态都写进去,写八个。不知道有没有大牛化简了的。该题跳过
5跳过
6
程序:
module top_module (
input [4:1] x,
output f );
assign f=~x[1]&x[3] |x[2]&x[4];
endmodule
7化简图
程序:
module top_module (
input [4:1] x,
output f
);
assign f=(~x[2]&~x[4]) | (~x[1]&x[3]) | (x[2]&x[3]&x[4]);
endmodule
8 用四选一选择器和多个二选一选择器实现卡诺图化简。找了下参考答案看看思路。
HDLBits(8)——Karnaugh Map to Circuit_Mount256的博客-CSDN博客
官网的参考答案如下:
module top_module (
input c,
input d,
output [3:0] mux_in
);
// After knowing how to split the truth table into four columns,
// the rest of this question involves implementing logic functions
// using only multiplexers (no other gates).
// I will use the conditional operator for each 2-to-1 mux: (s ? a : b)
assign mux_in[0] = (c ? 1 : (d ? 1 : 0)); // 2 muxes: c|d
assign mux_in[1] = 0; // No muxes: 0
assign mux_in[2] = d ? 0 : 1; // 1 mux: ~d
assign mux_in[3] = c ? (d ? 1 : 0) : 0; // 2 muxes: c&d
endmodule
用了三目运算符