3变量卡诺图
实现下面卡诺图所描述的电路。
Module Declaration
module top_module(
input a,
input b,
input c,
output out );
答案:
module top_module(
input a,
input b,
input c,
output out );
assign out = ((!a & !b & !c )==1)? 0 : 1;
endmodule
4变量卡诺图1
实现下面卡诺图所描述的电路。
Module Declaration
module top_module(
input a,
input b,
input c,
input d,
output out );
答案:
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)|(!a&!b&c&!d)|(!a&b&c&!d);
//和之积
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);
endmodule
4变量卡诺图2
实现下面卡诺图所描述的电路。
Module Declaration
module top_module(
input a,
input b,
input c,
input d,
output out );
答案:
在实现之前,可以对卡诺图进行简化。将d的值带入,可以实现去除掉变量d变成全部是常数的卡诺图。然后化简可知
out = a |(!b&c);(积之和式子)
out = (a|!b) & (a|c);(和之积式子)
module top_module(
input a,
input b,
input c,
input d,
output out );
//积之和式子
assign out = a |(!b&c);
//和之积式子
//assign out = (a|!b) & (a|c);
endmodule
4变量卡诺图3
实现下面卡诺图所描述的电路。
Module Declaration
module top_module(
input a,
input b,
input c,
input d,
output out );
答案:
由卡诺图可以看出,都是在ab异或cd同或和cd异或ab同或进行取值。
module top_module(
input a,
input b,
input c,
input d,
output out );
assign out = ((a^b)&!(c^d))|(!(a^b)&(c^d));
endmodule
SOP和POS
具有四个输入 (a,b,c,d) 的单输出数字系统在输入出现 2、7 或 15 时产生逻辑 1,当输入出现 0、1、4、5、6、9、10、13 或 14 出现时产生逻辑 0 。数字 3、8、11 和 12 的输入条件从未出现在此系统中。例如,7 对应于分别设置为 0、1、1、1 的 a、b、c、d。
确定最小SOP形式的输出out_sop,以及最小POS形式的输出out_pos。
Module Declaration
module top_module (
input a,
input b,
input c,
input d,
output out_sop,
output out_pos
);
答案:
画出卡诺图进行化简,
此时out_sop = c&d + !a&!b&c;
out_pos = c & (!b|d) & (!a|d);
所以编写代码实现功能:
module top_module (
input a,
input b,
input c,
input d,
output out_sop,
output out_pos
);
//SOP
assign out_sop = (c&d) | (!a&!b&c);
//POS
assign out_pos = c & (!b|d) & (!a|d);
卡诺图练习1
考虑下面卡诺图中显示的函数f。
实现这个功能。d是不关心的,这意味着您可以选择输出任何方便的值。
Module Declaration
module top_module (
input [4:1] x,
output f );
答案:
画出卡诺图进行化简,
写出表达式进行编写代码:
module top_module (
input [4:1] x,
output f );
assign f = (x[3]&!x[1]) | (x[4]&x[2]);
卡诺图练习2
考虑下面卡诺图中显示的函数f。实现这个功能。
Module Declaration
module top_module (
input [4:1] x,
output f );
答案:
画出卡诺图进行化简,
写出表达式进行编写代码:
module top_module (
input [4:1] x,
output f
);
assign f = (x[3]&!x[1]) | (!x[4]&!x[2])|(x[2]&x[3]&x[4]);
使用数据选择器进行实现卡诺图
对于下面的卡诺图,给出使用一个 4 对 1 多路复用器和尽可能多的 2 对 1 多路复用器的电路实现,但使用尽可能少。不允许使用任何其他逻辑门,必须使用a和b作为多路复用器选择器输入,如下面的 4 对 1 多路复用器所示。
您只实现了标记为top_module的部分,以便整个电路(包括 4 对 1 多路复用器)实现 K-map。
答案:
module top_module (
input c,
input d,
output [3:0] mux_in
);
always@(*)begin
if({c,d}== 0)
mux_in = 4'b0100;
else if({c,d}== 1)
mux_in = 4'b0001;
else if({c,d}== 2)
mux_in = 4'b0101;
else
mux_in = 4'b1001;