ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【HDLBits刷题日记】08 Karnaugh Map to Circuit [打印本页]

作者: 大号在练葵花宝典    时间: 2022-10-28 13:24
标题: 【HDLBits刷题日记】08 Karnaugh Map to Circuit
Kmap1

化简卡诺图即可。
  1. module top_module(
  2.     input a,
  3.     input b,
  4.     input c,
  5.     output out  );
  6.     assign out=b|c|a;
  7. endmodule
复制代码
Kmap2


我是这样化简的。
  1. module top_module(
  2.     input a,
  3.     input b,
  4.     input c,
  5.     input d,
  6.     output out  );
  7.     assign out=(~a&~d)|(~b&~c)|(a&~b&d)|(b&c&d);
  8. endmodule
复制代码
Kmap3

这里d代表的是无关项,要不要圈起来都可以。
  1. module top_module(
  2.     input a,
  3.     input b,
  4.     input c,
  5.     input d,
  6.     output out  );
  7.     assign out=(~b&c)|(a&c)|(a&~d);
  8. endmodule
复制代码
Kmap4

这道题一眼看过去根本没办法化简,但是根据提示,改变一个输入值总会使输出反转,所以可以推断出a、b、c、d应该进行的是异或运算。
  1. module top_module(
  2.     input a,
  3.     input b,
  4.     input c,
  5.     input d,
  6.     output out  );
  7.     assign out=a^b^c^d;
  8. endmodule
复制代码
Exams/ece241 2013 q2

 
 
 
 sop形式直接写就可以了,pos形式则需要sop形式使用摩根定理取反两次进行变换。
  1. module top_module (
  2.     input a,
  3.     input b,
  4.     input c,
  5.     input d,
  6.     output out_sop,
  7.     output out_pos
  8. );
  9.     assign out_sop=(c&d)|(~a&~b&c);
  10.     assign out_pos=c&(~a|d)&(~b|d);
  11. endmodule
复制代码
Exams/m2014 q3

也是直接化简就可以了。

 
 
 
  1. module top_module (
  2.     input [4:1] x,
  3.     output f );
  4.     assign f=(~x[1]&x[3])|(x[1]&x[2]&~x[3]);
  5. endmodule
复制代码
Exams/2012 q1g

化简的时候注意四个角。

 
 
 
  1. module top_module (
  2.     input [4:1] x,
  3.     output f
  4. );
  5.     assign f=(~x[2]&~x[4])|(~x[1]&x[3])|(x[2]&x[3]&x[4]);
  6. endmodule
复制代码
Exams/ece241 2014 q3


 
 
 
这里要使用一个4-to-1的数据选择器实现四输入的逻辑。
逻辑为:f=(~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为00时,选中mux_in[0],也就是说控制mux_in[0]就可以了。
  1. module top_module (
  2.     input c,
  3.     input d,
  4.     output [3:0] mux_in
  5. );
  6.     assign mux_in[0]=(~c&~d)?1'b0:1'b1;
  7.     assign mux_in[1]=1'b0;
  8.     assign mux_in[2]=(~d)?1'b1:1'b0;
  9.     assign mux_in[3]=(c&d)?1'b1:1'b0;
  10. endmodule
复制代码
我这里貌似还是用了逻辑门,不符合要求,答案的表达式更加简洁,可以参考一下。
  1. module top_module (
  2.     input c,
  3.     input d,
  4.     output [3:0] mux_in
  5. );
  6.    
  7.     // After splitting the truth table into four columns,
  8.     // the rest of this question involves implementing logic functions
  9.     // using only multiplexers (no other gates).
  10.     // I will use the conditional operator for each 2-to-1 mux: (s ? a : b)
  11.     assign mux_in[0] = c ? 1 : d;          // 1 mux:   c|d
  12.     assign mux_in[1] = 0;                  // No muxes:  0
  13.     assign mux_in[2] = d ? 0 : 1;          // 1 mux:    ~d
  14.     assign mux_in[3] = c ? d : 0;          // 1 mux:   c&d
  15.    
  16. endmodule
复制代码
 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4