https://hdlbits.01xz.net/wiki答案/Circuits/karnaugh map to circuit
1.Kmap1
module top_module(
    input a,
    input b,
    input c,
    output out  ); 
    assign out = ~((~a)&(~b)&(~c));
endmodule
2.Kmap2
依然是卡诺图化简,观察零少还是一少去化简可能方便一些。
module top_module(
    input a,
    input b,
    input c,
    input d,
    output out  ); 
    assign out = ~((a&b&(~c)) | (b&(~c)&d) | (a&c&(~d)) | ((~a)&(~b)&c&d));
endmodule
3.Kmap3
d代表无关项,即don't care。
module top_module(
    input a,
    input b,
    input c,
    input d,
    output out  ); 
    assign out = (a) | ((~a)&(~b)&c);
endmodule
本题会报错警告与输入d无关,实际上结果是这样的。
4.Kmap4
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
学习过卡诺图都知道,四维以下,主副对角线的都是无法化简的,所以一个n输入的变量,最多输出只能是 2^(n-1)个,实际上就是真值表隔行取,建议复习这个结论;
5.Minimum SOP and POS
SOP是sum of product 即与项相或
POS是product of sum 即或项相与
  module top_module (
    input a,
    input b,
    input c,
    input d,
    output out_sop,
    output out_pos
); 
    assign out_sop = (c&d) | ((~a)&(~b)&c);
    assign out_pos = ~(((~c)|(~d)) & (a|b|(~c)));
endmodule
卡诺图的化简根本不唯一,答案只给了这种,所以不必太过纠结。
6.Karnough Map
module top_module (
    input [4:1] x, 
    output f );
    assign f = ((~x[1])&x[3]) | (x[1]&x[2]&(~x[3]));
endmodule
同样与x4的输入无关
7.Karnough Map
module top_module (
    input [4:1] x,
    output f
); 
    assign f = ((~x[1])&x[3]) | ((~x[1])&(~x[2])&(~x[3])&(~x[4])) | (x[1]&x[2]&x[3]&x[4]) | (x[1]&(~x[2])&(~x[4]));
endmodule
手癌总是从0开始写...
8.Karnough implemented with a MUX
module top_module (
    input c,
    input d,
    output [3:0] mux_in
); 
    assign mux_in[0] =  (c|d)? 1'b1: 1'b0;
    assign mux_in[1] = 1'b0;
    assign mux_in[2] =  (~d)? 1'b1: 1'b0;
    assign mux_in[3] = (c&d)? 1'b1: 1'b0;
endmodule
写位数是为了避免位数不匹配的警告。
如有错误欢迎讨论指正。
练习网址
                    
                
                
            
        
浙公网安备 33010602011771号