HDLBits 系列(41)根据仿真波形来设计电路之组合逻辑
【摘要】
文章目录
Sim/circuit1原题复现我的设计 Sim/circuit2原题复现题目分析我的设计 Sim/circuit3原题复现题目分析我的设计 Sim/circuit4原题复现题目分析 Sim/circuit5原题复现题目分析 Sim/circuit6原题复现题目分析
Sim/circuit1
这个题目让我想起了当时的华为面试题目,就是...
Sim/circuit1
这个题目让我想起了当时的华为面试题目,就是这类题目的变形,但是当时就是没有想起来怎么做?
还是太菜,见过的题目太少。后面经过面试官的提示才恍然大悟,这算是一次教训吧,我再也忘不了这种题目了。
原题链接
原题复现
This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.
两个输入一个输出,很明显是一个组合逻辑,如果给你一个输入,一个输出,情况也许就不一样了,你需要想到是不是时序逻辑来实现这个问题。
可以看出,当且仅当a和b都为1的时候,输出为1。
我的设计
module top_module ( input a, input b, output q );// assign q = (a&b)?1:0;
endmodule
Sim/circuit2
原题复现
This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.
题目分析
这个题目相对于上一题来说,不能说难,只是输入给的更多了,让你看的眼花缭乱的同时,也给心里增添了一份负担,但是如果我们有着清晰的思维,就会考虑这么多的输入,会不会具有某种逻辑?逻辑门可以实现吗?大脑自带的分组归纳能力体现的淋漓尽致。
通过对高电平数量和输出之间的关系判断出,这是一个同或逻辑。
我的设计
module top_module ( input a, input b, input c, input d, output q );// assign q = ~(a^b^c^d); // Fix me
endmodule
Sim/circuit3
原题复现
This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.
题目分析
这道题和上一题很相似,但是难度却大多了,我们仅仅考虑是否用了某种逻辑门,显然不够了,再向哪方面考虑呢?
通过尝试性的分析,如下,只分析d为1的情况的组合:
通过尝试性的分析,如下,只分析d为0的情况的组合:
显然,看出规律也能看出规律,但是实现起来太过于麻烦,不如使用卡诺图进行化简得出结论罢了。
ab\cd | 00 | 01 | 11 | 10 |
---|---|---|---|---|
00 | 0 | 0 | 0 | 0 |
01 | 0 | 1 | 1 | 1 |
11 | 0 | 1 | 1 | 1 |
10 | 0 | 1 | 1 | 1 |
好了,我们来画卡诺图:
直接写出输出逻辑:
q = b&d | b&c | a&d | a&c;
我的设计
module top_module ( input a, input b, input c, input d, output q );// assign q = b&d | b&c | a&d | a&c;
endmodule
Sim/circuit4
原题复现
This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.
题目分析
同样可以通过卡诺图分析来给出答案,我就不写了,因为懒着画图了。
太晚了,今晚就到这里吧,更复杂的组合逻辑情况以及时序逻辑情况,等下一篇博客分析吧。
Sim/circuit5
原题复现
This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.
题目分析
这题已经是多位的组合逻辑设计了,仅仅给出波形图,让你实现设计?
不知你会怎么样?反正我一眼是看不出来,我的思路也只能是把输入输出写成2进制变量,然后找出每一位的规律,或者通过卡诺图求出每一位的结果,最后汇总。但真的很麻烦?
期待你的答案。
Sim/circuit6
原题复现
This is a combinational circuit. Read the simulation waveforms to determine what the circuit does, then implement it.
题目分析
这题比上一题更加的难了,输入输出位数不一样了,使用卡诺图对每一位求解也用不成了?
留下来给大家思考?
文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。
原文链接:reborn.blog.csdn.net/article/details/103534423
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
保山公子2022/03/26 07:42:501楼编辑删除举报
module top_module (
input [3:0] a,
input [3:0] b,
input [3:0] c,
input [3:0] d,
input [3:0] e,
output [3:0] q );
always @(*) begin
case(c)
4'd0:q<=b;
4'd1:q<=e;
4'd2:q<=a;
4'd3:q<=d;
default:q<=4'hf;
endcase
end
Leon_yqy2022/09/24 04:50:522楼编辑删除举报
module top_module (
input [3:0] a,
input [3:0] b,
input [3:0] c,
input [3:0] d,
input [3:0] e,
output [3:0] q );
always @(*) begin
case(c)
4'd0: q = b;
4'd1: q = e;
4'd2: q = a;
4'd3: q = d;
default : q = 4'hf;
endcase
end
endmodule
Leon_yqy2022/09/24 05:08:543楼编辑删除举报
module top_module (
input [2:0] a,
output [15:0] q );
always@(*) begin
case(a)
3'd0:q=16'h1232;
3'd1:q=16'haee0;
3'd2:q=16'h27d4;
3'd3:q=16'h5a0e;
3'd4:q=16'h2066;
3'd5:q=16'h64ce;
3'd6:q=16'hc526;
3'd7:q=16'h2f19;
endcase
end
endmodule