1. 3-variable
module top_module(
input a,
input b,
input c,
output out );
assign out = a||b||c;
endmodule
2. 4-variable
卡诺图化简:
module top_module(
input a,
input b,
input c,
input d,
output out );
assign out = ~a&~d | ~b&~c | ~a&b&c | a&c&d ;
endmodule
3. 4-variable
对于这个卡诺图,出现的d可以当作0,也可以当作1。
当做1化简比较简单,如下:
module top_module(
input a,
input b,
input c,
input d,
output out );
assign out = a | ~b&c ;
endmodule
4. 4-variable
module top_module(
input a,
input b,
input c,
input d,
output out );
assign out=~a&~b&~c&d|~a&~b&c&~d|~a&b&~c&~d|~a&b&c&d|a&b&~c&d|a&b&c&~d|a&~b&~c&~d|a&~b&c&d;
endmodule
5. Minimum SOP and POS
module top_module (
input a,
input b,
input c,
input d,
output out_sop,
output out_pos
);
assign out_sop=c&d||~b&c&~a;
assign out_pos=c&(~a|d)&(~b|~c|d);
endmodule
6. Karnaugh map
module top_module (
input [4:1] x,
output f );
assign f = ~x[1]&x[3] | x[1]&x[2]&~x[3];
endmodule
7. Karnaugh map
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
7. K-map implemented with a multiplexer
module top_module (
input c,
input d,
output [3:0] mux_in
);
// After splitting 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 mux: 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 : 0; // 1 mux: c&d
endmodule
小结:
卡诺图是逻辑函数的一种图形表示。卡诺图是一种平面方格图,每个小方格代表逻辑函数的一个最小项,故又称为最小项方格图。方格图中相邻两个方格的两组变量取值相比,只有一个变量的取值发生变化,按照这一原则得出的方格图(全部方格构成正方形或长方形)就称为卡诺方格图,简称卡诺图。