逻辑电路和逻辑门 [英] Logical Circuit and logical gates

查看:80
本文介绍了逻辑电路和逻辑门的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提出了一个听起来像这样的项目。



考虑一组逻辑门,如AND,OR,XOR或NOT。允许通过连接这样的门来构建任何逻辑电路。

向多个门提供输入(0/1)并在某些门的输出处收集结果。

能够从文件中读取电路的描述。



我得到的其他信息:我必须构建一些类/接口,允许模拟这样的之后,你必须模拟输入信号到端节点的流动,最终在一些输出连接器上收集结果。这不是要编写一个程序来评估p&q | r&!p等逻辑命题或写入真相表。相反,你有一些信号流经连接器,并在每个逻辑门的水平处理。



我被建议像下面那样,对于一个AND门, 2个输入和一个输出。这是一个好方法吗?



01公共类LogicAnd扩展门

02 {

03 public LogicAnd( int a,int b,int q){

04 a_ = a; b_ = b; q_ = q;

05}

06

07 public void Evaluate(int [] signals){

08信号[q_] =信号[a _]和信号[b_];

09}

10}



有没有人做过这种事?你会做什么,你将如何开始/塑造这个问题?我正在寻找尽可能多的帮助,对提示和解决方案持开放态度,任何事情都有帮助。

解决方案

当我在1980年末回到大学时''我们有一个入门课程,我们被教授Scheme(一个LISP方言)。整个课程使用的书是计算机程序的结构和解释 [ ^ ]苏斯曼。

在我脑海中不可磨灭的一件事是一个完全用Scheme编写的表达式模拟器。用于解决此问题的原则之一称为传播约束 [ ^ ]关于模块化,对象和状态 [ ^ ]。

请阅读此内容!尽管你不会在Scheme中实现这一点,但仍然需要从该书中学到很多东西,尤其是signal•states如何通过网络传播。 Celsius-Fahrenheit计算器可以双向运行,无需重写任何内容。它仅取决于为哪个引脚分配值,将计算正确的对应物。那时我对这个原则感到非常惊讶。



这一章离你正在寻找的东西更接近了仍然认为上述原则对更一般的表达式评估者有帮助: 3.3.4数字电路模拟器 [ ^ ] [/编辑]



如果您有任何怀疑,给我留言。



干杯,



-Manfred

I was proposed a project that sounds like this.

Consider a set of logical gates like AND, OR, XOR or NOT. Allow for building any logical circuit by connecting such gates.
Provide input (0/1) to a number of gates and collect the results at the output of some of the gates.
Be able to read the description of the circuit from a file.

Additional information that I was given: I have to build some classes/interfaces allowing to model such circuits.After that, you have to simulate the flow of the input signals to the end nodes and eventually to collect the results on some output connectors.It is not about writing a program to evaluate logical propositions like p&q|r&!p or to write truth tables. Rather you have some signals flowing through connectors and processed at the level of each logical gate.

I was suggested an idea like the one below, for a single AND gate, 2 inputs and a single output. Is this a good approach?

01 public class LogicAnd extends Gate
02 {
03 public LogicAnd(int a, int b, int q) {
04 a_ = a; b_ =b; q_ = q;
05 }
06
07 public void Evaluate(int[] signals) {
08 signals[q_] = signals[a_]&signals[b_];
09 }
10 }

Has anyone done anything of this kind? What would you do, how would you start/shape this problem? I am looking for any help as much as possible, open to hints and solutions, anything is helpful.

解决方案

When I was at uni back in the late 1980''s we had an introductory course where we were taught Scheme (a LISP dialect). The book that was used throughout the course was Structure and Interpretation of Computer Programs[^] by H. Abelson and G.J. Sussman.
One of the things that was engraved indelibly in my mind was an expression simulator written completely in Scheme. One of the principles that was used to solve this was called Propagation of Constraints[^] in Chapter 3 about Modularity, Objects, and State[^].
Please read this! Even though you''ll not be implementing this in Scheme, there''s still a lot to be learned from that book, especially how signals\states propagate through the network. The Celsius-Fahrenheit calculator works both ways for instance without you having to rewrite anything. It merely depends which pin is assigned a value the correct counterpart will be calculated. Back then I was really amazed at this principle.

[Edit]This chapter is a bit closer to what you are looking for while I still think that above mentioned principle will be helpful in more general expression evaluators: 3.3.4 A Simulator for Digital Circuits[^][/Edit]

If you have any doubts, leave me a comment.

Cheers,

—Manfred


这篇关于逻辑电路和逻辑门的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆