HDLBits个人刷题详解合集9-Circuits-Combinational Logic-Karnaugh Map to Circuit-HDBits题目分析

卡诺图化简

卡诺图示例:

Kmap1

Try to simplify the k-map before coding it. Try both product-of-sums and sum-of-products forms. We can't check whether you have the optimal simplification of the k-map. But we can check if your reduction is equivalent, and we can check whether you can translate a k-map into a circuit.

卡诺图简化的结果为f=a+b+c

代码如下:

module(

    input a,

    input b,

    input c,

    output out  );

assign out = a | b | c;

endmodule

Kmap2

在编码之前,请尝试简化 k 映射。尝试总和积和形式。我们无法检查您是否具有 k 映射的最优简化。但是我们可以检查您的约简是否等效,我们可以检查您是否可以将k映射转换为电路。

卡诺图有多种分发:1、红色:f=a’c’d’+a’b’c’+ab’c’+a’cd’+a’bc+acd

2、紫色:f=a’d’+b’c’+acd+bcd

所有的’用非~表示,+用|或运算表示,乘为&与运算

代码如下:

module top_module(

    input a,

    input b,

    input c,

    input d,

    output out  );

//assign out = ~a&~d | ~b&~c | a&c&d | b&c&d;

    assign out = ~a&~c&~d | ~a&~b&~c | a&~b&~c | ~a&c&~d | ~a&b&c | a&c&d;

endmodule

Kmap3

d相当于无关项,既可以当做0也可以当做1

f=ac’+b’c+ac

代码如下:

module top_module(

    input a,

    input b,

    input c,

    input d,

    output out  );

assign out = a&~c | ~b&c | a&c;

endmodule

Kmap4

无法化简

f=a’bc’d’+ab’c’d’+a’b’c’d+abc’d+a’bcd+ab’cd+a’b’cd’+abcd’

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;

代码如下:

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

Exams/ece241 2013 q2

具有四个输入 (a,b,c,d) 的单输出数字系统在输入上出现 2、7 或 15 时生成逻辑 1,当输入上出现 0、1、4、5、6、9、10、13 或 14 时生成逻辑 0。此系统中永远不会出现数字 3、8、11 和 12 的输入条件。例如,7 分别对应于 a,b,c,d 被设置为 0,1,1,1。

以最小 SOP 形式确定输出out_sop,以最小 POS 形式确定输出out_pos。

根据题目要求画卡诺图如上:1、红色为SOP:f=cd+a’b’c’;

2、紫色为POS:f=a’c’+c’d+bd’+ab’;

代码如下:

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 = ~(~a&~c | ~c&d | b&~d | a&~b);

endmodule

Exams/m2014 q3

Implement this function. d is don't-care, which means you may choose to output whatever value is convenient.

由卡诺图得:f=x1’x3+x2x4

代码如下:

module top_module (

    input [4:1] x,

    output f );

    assign f = ~x[1]&x[3] | x[2]&x[4];

endmodule

Exams/2012 q1g

Consider the function f shown in the Karnaugh map below. Implement this function.

(The original exam question asked for simplified SOP and POS forms of the function.)

  

由卡诺图得:紫色最简:f=x1’x3+x2x3x4+ x2’x4’

代码如下:

module top_module (

    input [4:1] x,

    output f

);

    assign f = ~x[1]&x[3] | ~x[2]&~x[4] | x[2]&x[3]&x[4];

    //x1’x3+x2’x4’+x2x3x4

Endmodule

Exams/ece241 2014 q3

对于下面的 Karnaugh 图,根据需要使用一个 4 对 1 多路复用器和尽可能多的 2 对 1 多路复用器,但尽可能少地使用电路实现。您不得使用任何其他逻辑门,必须使用 a 和 b 作为多路复用器选择器输入,如下面的 4 对 1 多路复用器所示。

您只实现了标记为top_module的部分,使得整个电路(包括 4 对 1 多路复用器)实现 K 映射。

代码如下:

module top_module (

    input c,

    input d,

    output [3:0] mux_in

);

    assign mux_in[0] = c?1:(d?1:0);

    //由题得:只有当cd=00时,输出的mux_in[0]=0,其他情况都为1

    assign mux_in[1] = 0;

    //任何情况下输出ab为01都是不可能的

    assign mux_in[2] = d?0:1;

    //只要d=0,mux_in[2]的输出ab=10都应该为1

    assign mux_in[3] = c?(d?1:0):0;

    //只有当cd=11时,输出ab=11才会为真

endmodule

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值