Jump to content

what are the fundamentals building blocks of computing?


ZeroZero

Recommended Posts

Hi all,

 

I am just revising my computer skills after a 30 year break. The question on my mind is what are the fundamentals building blocks of computing?

 

From my revision I have learnt that there are four basic logic gates AND OR XOR and NOT - from these all other logic gates can be built. Then of course there is binary.

 

 

the conditional statement IF - THEN is currently puzzling me

 

how is this constructed from the above operations?

 

It seems to me that it cannot be?

Link to comment
Share on other sites

Are you asking about the If-Then statement in computer programming?

 

If "CONDITION" is TRUE

Then "DO THIS"

 

 

Example:

 

x = 18

 

if x == 18

Display "X is equal to 18"

 

 

Once again I am not sure if you are talking about programming but if so in the example I assigned 18 to the variable "x" and then used the If-Then statement to check the variable. In the If-Then statement it checks the condition "x == 18" which is basically asking "Is x equal to 18?" if the condition is TRUE then it does the following 'Display "X is equal to 18" but if x is not equal to 18 then it is simply ignored.

 

 

All the following examples are TRUE so the If-Then statement will run the Display statement. I wrote how the conditions are read in the Display output.

Example with AND:

 

x = 18

y = 7

 

if x == 18 AND y == 7

Display "X is 18 and y is 7"

 

Example with OR:

 

x = 18

 

if x== 7 OR x == 18

Display "X is 7 or 18"

 

Example with NOT:

 

x = 18

 

if x != 18

Display "X is not equal to 18"

 

 

Link to comment
Share on other sites

IF - THEN is not constructed from basic logic gate.

Actually it could be. An AND gate is actually an IF-THEN device itself, If INPUT A=1 AND INPUT B=1 THEN OUTPUT=1 ELSE OUTPUT=0. Any number of simple logic gates could be configured to make specific binary functions like this. It is more efficient though to use the gates to build programmable processing units that can more readily adapt to a variety of uses as opposed to a single hardwired application.

Link to comment
Share on other sites

I think I have figured this one out. It is a logic gate but a rare one called a 'buffer'. This is a simple gate with one input and one output. If the input is 1 then the output is 1. If the input is 0 then the output is 0. This may seem a bit pointless for a logic gate and indeed it is a rare item. Its the opposite of a NOT gate.

 

Of course the first 1 may represent anything - say fish, the second 1 may also represent anything, say fishing.

 

 

IF fish THEN Fishing

 

Input fish, output fishing

 

 

 

The AND gate has two inputs therefore cannot be an if then statement.

Link to comment
Share on other sites

A Computer is a device that performs a succession of operations on data. The operations form an addressable list called a "program" and the data also forms an addressable list ( the lists are technically known as "Turing Tapes"). The presence of the operations and data in addressable lists plus the ability to temporarily store the outputs and inputs in a buffer makes the device into a "Turing Machine" (See http://en.wikipedia..../Turing_machine ). All computers are Turing Machines.

 

The most basic operations are comparisons (><,==,!=) and logical operators (AND,OR,NOT etc) and GOTO instructions.

 

In the early days of computers the devices truly were plain Turing Machines in which, when the machine was turned on the first instruction in the program list, or "program" would be read, this would act on the data, the next instruction would be read and so on. This programming language was called "Machine Code". Very soon after this special circuits were made so that simple English instructions such as MOVE could be converted into machine code, this led to the program language(s) known as ASSEMBLER. Assembler was very long winded, for instance to print data from disk to printer would involve a program such as:

 

LABEL A

MOV disk buffer

IF buffer <= 0 GOTO C

MOV buffer printer

GOTO A

LABEL C

 

This is a highly simplified example - a real assembler program is always a nightmare of scores of instructions.

 

In the same way as machine code was replaced by assembler, assembler was replaced by "higher level" languages that were composed of commands that called assembler programs. The higher level language might have a command such as: PRINT diskfile, when this is read from the program it calls an assembler program like the one above

 

The logical operators AND, OR, NOT etc have a place within programs but are also used at the hardware level. It was recognised at an early stage in the history of computing that electronic devices were particularly good at handling ON/OFF signals so the early ANALOG COMPUTERS were rapidly replaced by DIGITAL COMPUTERS. Mathematicians immediately realised that binary, ON/OFF signals were like the TRUE/FALSE outcomes and inputs of BOOLEAN ALGEBRA (see http://en.wikipedia....Boolean_algebra ). Almost any mathematical operation or comparison can be performed using Boolean Algebra.

 

It then became possible to construct specialist hardware modules that did operations like addition so that when the program said 00000001 + 00000001 the plus sign was taken as an instruction to submit the two numbers to a dedicated Boolean FULL ADDER implemented in electronic components (see http://en.wikipedia....8electronics%29 ). The output from the full adder 00000010 would be transferred to the buffer. A modern computer has numerous dedicated units for adding, complementing, converting from binary to decimal etc.

 

Modern programs attempt to be like "pseudocode". Pseudocode is a language that deals with programming in a simple, intuitive way:

 

if a < 4 then do

...b = a + 1;

...print b

...a = a + 2

else

...b = 54

end

 

In particular "GOTO" and labels are almost banned.

 

Well, thats enough said.

Edited by mindless
Link to comment
Share on other sites

Pseudocode: [math]IF \;\; a \;\; THEN \;\; b \;\; ELSE \;\; c[/math]

 

Logic:

 

[math]a \rightarrow DO \; b[/math]

 

[math]NOT \; a \rightarrow DO \; c[/math]

 

a: condition

 

b, c: set of instructions

Edited by khaled
Link to comment
Share on other sites

The AND gate has two inputs therefore cannot be an if then statement.

If statements require at least 2 values to compare with each other. IF there is a match per the criteria THEN the output reflects it. With a 2 input AND gate the inputs are compared with each other and the output is adjusted accordingly. In this sense it does effectively function as an IF-THEN function.

Link to comment
Share on other sites

If statements require at least 2 values to compare with each other. IF there is a match per the criteria THEN the output reflects it. With a 2 input AND gate the inputs are compared with each other and the output is adjusted accordingly. In this sense it does effectively function as an IF-THEN function.

 

 

IF (A someone knocks on my door) THEN (B I go and answer it)

 

 

 

IF A THEN B

 

Its a long time since i programmed but in the sense above I cannot see what are 'the two values to compare'.

Link to comment
Share on other sites

IF (A someone knocks on my door) THEN (B I go and answer it)

 

 

 

IF A THEN B

 

Its a long time since i programmed but in the sense above I cannot see what are 'the two values to compare'.

Hmmm, did I miss something? I thought this thread was about computing.

Link to comment
Share on other sites

i too am unsure what exactly the question is asking.

logical implication, if a then b is however equivalent to

not a or b

 

ie. say i have the statement

if it rains then it's cloudy.

this is equiavent to

its not raining, or its cloudy.

the truth table is as follows.

A | B | A->B

0 0 1

0 1 1

1 0 0

1 1 1

Link to comment
Share on other sites

It seems to me that ... the conditional statement IF - THEN cannot be ... constructed from the ... four basic logic gates

Yes, because it produces a decision, not a quantity. The same could be said (that is, cannot be constructed from logic gates) for other program control statements (GOTO, STOP, HALT, END etc), or for that matter, other non-quantity-producing statements, such as interface statements (INPUT, PRINT, STORE, SOUND etc).

Link to comment
Share on other sites

Let me add to my previous post. If an IF/THEN statement results in a quantity, then it might be constructed from the basic logic gates. I do it all the time in Excel.

 

For example, IF B7 > 10 THEN C7 = B7–10 ELSE C7 = B7. To perform this, use:

 

C7 = B7–10*INT(SIGN(B7-10)+1)/2)

If all those functions can be constructed from the basic logic gates, then this IF/THEN statement can also.

Link to comment
Share on other sites

"

Yes, because it produces a decision, not a quantity"

 

 

 

In Bolean algebra a decision is a quantity. Everything is eith 0 or 1, which can represet FALSE or TRUE when a decision is made it is a switch being set to 0 or 1

 

The original question:

 

How can an IF THEN statement be made from bolean logic gates?

 

 

I am starting to think its an OR gate

 

 

There seems to be different views on this question, from posters

Link to comment
Share on other sites

In practice you have a set of gates in a comparator unit. Equals and not equals are AND, less than and more than involve inspecting the high and low bits in a binary string, logical operators just use the corresponding logic circuits.

Link to comment
Share on other sites

"Yes, because it produces a decision, not a quantity"

 

In Boolean algebra a decision is a quantity.

Sorry, I was thinking a program control decision such as IF X>0 THEN GOTO LINE 1500. The conditional jump is a critical software function.

Link to comment
Share on other sites

How can an IF THEN statement be made from bolean logic gates?

Actually the truth table for the various gates can be written as an If-Then statement, i.e.

 

2 Input AND gate:

If Input A=1 (true) AND Input B=1 (True) THEN Output=1 (True).

 

2 Input OR gate:

If Input A=1 (True) OR Input B=1 (True) Then Output=1 (True)

 

2 Input XOR Gate:

If Input A<>Input B Then Output=1.

 

This is obvious when you consider that any of these can be used as a bitwise comparison operator in a programming environment like BASIC or C where an If-Then statement is used, i.e.

 

If (X AND Y) Then Conditional Operation.

Link to comment
Share on other sites

http://www.simpledigitalcomputer.com/BuildingSimpleMachines.aspx

 

I am in agreement with this link

 

 

 

 

It's suprising how many answers you can get to this very simple question:

 

 

 

http://www.electro-tech-online.com/general-electronics-chat/86128-how-can-i-make-if-gates.html

 

 

 

I suppose technically this simple circuit is not a logic gate, I am told that logic gates have at least two inputs. If this is so we must also exclude NOT from the set of logic gates but many people fdo refer to NOT as a logic Gate and the simple switch 'buffer' is the complement of NOT.

 

Protist you stated above "IF statement requires two values". Well yes and no (forgive the pun). An if statement requires only 0 or 1 true or false. This is one value in a circuit its ewither the absence of a current or the presence of one. What I mean is that there is only one input for the decision, not two as in AND, OR, NOR, NAND, XOR.

 

 

 

Anyways thats my take on this :)

 

thanks for the discussion (or should I say input) :)

 

Actually the truth table for the various gates can be written as an If-Then statement, i.e.

 

2 Input AND gate:

If Input A=1 (true) AND Input B=1 (True) THEN Output=1 (True).

 

2 Input OR gate:

If Input A=1 (True) OR Input B=1 (True) Then Output=1 (True)

 

2 Input XOR Gate:

If Input A<>Input B Then Output=1.

 

This is obvious when you consider that any of these can be used as a bitwise comparison operator in a programming environment like BASIC or C where an If-Then statement is used, i.e.

 

If (X AND Y) Then Conditional Operation.

 

 

I suppose I should have said economically without using additional operators

 

 

 

 

In an IF THEN statement there is not a need for two inputs nor does it imply the use of greater than or less than, yes you can add in these operators but they are not part of the IF THEN statement.

 

 

 

Maybe think of the question this way - if you were building a circuit and you were interested in using the least amount of parts what would in consist of?

 

Dont mean to be pedantic just interested in getting to the bottom of this.

 

 

My view is that a simple relay switch is an IF THEN statement, it's often called a 'buffer' in terms of logic gates it's the 'complement' or opposite of a NOT gate. IF (1: true) THEN (1:TRUE). IF (0: not true)NOT THEN (0:FALSE).

 

 

 

I am not sure about this though..

 

 

 

Zero

 

 

 

''a

Link to comment
Share on other sites

I'm not certain, but I think the fundamental difference between the ANDs and ORs one one hand and the IFs and THENs on the other is that computers have a "clock" that tells them what order to do things in, while the gates act (in theory) immediately.

Link to comment
Share on other sites

In an IF THEN statement there is not a need for two inputs nor does it imply the use of greater than or less than, yes you can add in these operators but they are not part of the IF THEN statement...

 

Maybe think of the question this way - if you were building a circuit and you were interested in using the least amount of parts what would in consist of?

Technically an If-Then statement is a high level programming language construct not implemented at the circuit level. It is basically just a conditional statement that has a conditioned output based on the input(s). To implement such a construct at the circuit level you could accomplish it with 1 or more logic gates depending on the exact conditions you are testing for and the output desired for each condition. It would effectively be a hardwired If-Then statement. It could be as simple as a single NOT gate or it could be an elaborate assembly of flip-flops.

Link to comment
Share on other sites

  • 1 month later...

This concept came from digital electronics..it is a very interesting things to do..the best way to get the solution of this is there are many electronics site available on internet..tje provide the best answer for ur every question..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.