Logic gates and boolean algebra

In summary, logic gates are components in a circuit that use voltage levels to represent binary states of 0 and 1. The specific voltage levels for these states may vary depending on the circuit, but there is usually a threshold that determines the state. Timing is important in these circuits, as the output will depend on the input at that moment. Information can be stored in various ways, such as using capacitors in RAM or flip-flop circuits in processors.
  • #1
jackson6612
334
1
Hi

I'm not a science or physics student - quite a layman. Therefore, please keep your replies simple and explanatory so that your guidance and help can be fully appreciated. Thanks.

What are these logic gates - AND, NOR, NAND, etc? Are these some physical circuits?

In Boolean algebra '0' stands for absence of DC current and '1' for presence of the current. Right? Assuming I'm correct, when it's '0' there is no current, no question about it whatsoever. But when it's '1' that means there is current flowing because it could not be static. But how much current, 1A, 2A, or what? For how long does it flow? Bytes and bits are written as collections of '0's and '1's, does this mean bytes etc. are made up of surges of DC current?

Thanks a lot for all the help and your time.
 
Engineering news on Phys.org
  • #2
jackson6612 said:
What are these logic gates - AND, NOR, NAND, etc? Are these some physical circuits?

wiki boolean logic article that includes links for nand, nor, ...
http://en.wikipedia.org/wiki/Boolean_algebra_(logic)

wiki link on ttl logic:
http://en.wikipedia.org/wiki/Transistor-transistor_logic

bytes
Data is normally "held" by latches or flip flops, which can hold a state until a new state is triggered. These use self feed back in order to hold a state until triggered to change to a new state.

http://en.wikipedia.org/wiki/Latch_(electronics)

http://en.wikipedia.org/wiki/Flip-flop_(electronics)
 
  • #3
Thank you for your time, Rcgldr.

If you have noticed those Wikipedia articles are not aimed for people like me. Firstly, I'm not a science or math student. Secondly, English is not my first language. If Wikipedia had answers to everything, there won't be any need for the forums like PF.

Therefore, I'm humbly request you next you help me or someone else of my kind, then please try to use your own wording and knowledge rather than referring to Wiki entries.

Best wishes.
 
  • #5
jackson6612 said:
In Boolean algebra '0' stands for absence of DC current and '1' for presence of the current. Right? Assuming I'm correct, when it's '0' there is no current, no question about it whatsoever. But when it's '1' that means there is current flowing because it could not be static. But how much current, 1A, 2A, or what? For how long does it flow? Bytes and bits are written as collections of '0's and '1's, does this mean bytes etc. are made up of surges of DC current?
In modern computers, it's usually voltage, rather than current, that determines the state to be 0 or 1. To make it more specific that it's voltages, and that it's not a specific value, they are often called "Low" and "High" respectively.

The circuit containing logic gates, be it a CPU or some other device, is going to be powered. The voltage on the input is compared to the voltage supplied to the circuit, and that determines if the state is zero or one.

For example, let's say you feed 5V to a circuit containing some gates. And let's say that the threshold is right in the middle at 5V / 2 = 2.5V. Then any input from 0V to 2.5V is '0', and any input from 2.5V to 5V is '1'. The outputs will be very close to 0V and 5V for '0' and '1' respectively.

You have to keep in mind that the actual threshold does not have to be at half. It depends on the circuit. Some have it at 1/3, some at 2/3. This is just part of integrated circuit design.



As far as timing goes, the output of the logic gate depends on input at this moment. If input voltages change, so does the output voltage. There is usually a short delay, which limits how often you can switch inputs, and again, it's something to keep in mind when designing a circuit.



Information can be stored in a number of ways. Most modern RAM is dynamic, so there each bit is going to be stored on a capacitor. If capacitor is charged, it is a '1'. If it's not charged, it's a '0'. Connecting this capacitor to a gate would give you a high voltage, corresponding to '1', if it's charged, and low voltage if it's not. That let's you read the memory. In processor itself, storage is usually done with flip-flop circuits, which are collections of logic gates that keep each other at either high or low voltage until you change it by sending high voltage to either set or reset inputs.
 
  • #6
K^2 said:
In modern computers, it's usually voltage, rather than current, that determines the state to be 0 or 1. To make it more specific that it's voltages, and that it's not a specific value, they are often called "Low" and "High" respectively.

The circuit containing logic gates, be it a CPU or some other device, is going to be powered. The voltage on the input is compared to the voltage supplied to the circuit, and that determines if the state is zero or one.

Wouldn't the voltage applied to the circuit be equal to the input voltage?

For example, let's say you feed 5V to a circuit containing some gates. And let's say that the threshold is right in the middle at 5V / 2 = 2.5V. Then any input from 0V to 2.5V is '0', and any input from 2.5V to 5V is '1'. The outputs will be very close to 0V and 5V for '0' and '1' respectively.

Here you're speaking DC voltage?

You have to keep in mind that the actual threshold does not have to be at half. It depends on the circuit. Some have it at 1/3, some at 2/3. This is just part of integrated circuit design.

As far as timing goes, the output of the logic gate depends on input at this moment. If input voltages change, so does the output voltage. There is usually a short delay, which limits how often you can switch inputs, and again, it's something to keep in mind when designing a circuit.

Information can be stored in a number of ways. Most modern RAM is dynamic, so there each bit is going to be stored on a capacitor. If capacitor is charged, it is a '1'. If it's not charged, it's a '0'. Connecting this capacitor to a gate would give you a high voltage, corresponding to '1', if it's charged, and low voltage if it's not. That let's you read the memory. In processor itself, storage is usually done with flip-flop circuits, which are collections of logic gates that keep each other at either high or low voltage until you change it by sending high voltage to either set or reset inputs.

Hi K2

Please remember that I'm a layman in science and math with some basic skills. Thanks.

Thanks a lot. You have answered some of my main questions. Let me first state what I've learned from your post, please correct me if I'm wrong:

Logic gates are 'physical' electrical circuits. They are operated on principle of high and low voltages where these voltages correspond to '1' or '0' respectively.

Some minor questions:
1: Why are they called 'logic gates'? Perhaps, as a result of their ability to stop or allow the flow of current under specific ranges of voltage. If that's correct, then wouldn't calling them simple 'gates' or 'electrical gates' be more correct, why 'logic'?

In the third paragraph you have mentioned that 'threshold' concept. What is it?

Please check my inline comments in bold.

Thank you very much for all the help and your time.
 
  • #7
They are called 'logic gates' because the output is a function of the inputs. You can also imagine then as a 'if - then' statement. So for a AND gate with 4 inputs, call them A, B, C and D, and an output E, "If A=1 and B=1 and C=1 and D=1, then E=1". Or, "if A=0 or B=0 or C=0 or D=0, then E=0". All the other 'logic gates' are similar to this.
 
  • #8
And, at this point in your understanding, ignore current completely. The gates are to be switched entirely by voltage. For example, early CMOS gates used 5V logic. Any voltage above 2.5V at an input was read as a '1' input. Any voltage below that was read as a '0' input. If the input lingered exactly at 2.5, the output could be unstable, which is why this should never happen. Outputs were either 0 volts (='0') or 5V (='1').
You can also assume (for now) the gates operate at infinite speed, though this is an approximation.
 
  • #9
Here is a circuit diagram to maybe help you understand things a little better.

NAND_gate_%28CMOS_circuit%29.PNG


The voltages at A and B are controlled externally. Voltage at Vdd is always +5V (Assuming this is for a 5V CMOS). The symbol at the bottom right corner is the ground. It's always at 0V.

Now, Q1-Q4 are the Field Effect Transistors (FETs). Each FET has a line coming in from the left. That's the FET's gate. For the purpose of this discussion, think of each FET as a switch. Q1 and Q2 are normally open. You must apply high voltage (close to 5V) to the gate to close them. Q3 and Q4 are normally closed. High voltage on the gate opens them. (Keep in mind - closed switch conducts, opened switch doesn't. I know it might sound backwards.)

Now let's look at what happens when A and B are set to low/high voltages. If A is low, Q1 is open and Q3 is closed. So Y is connected to Vdd, and is therefore high. Similarly, if B is low, Q2 is open and Q4 is closed and Y is still connected to Vdd.

In order to disconnect Y from Vdd, you must apply high voltage to both A and B. That opens Q3 and Q4, also closing Q1 and Q2. So now, Y is connected to ground, and is low.In terms of logic operations, this is written as Y = A NAND B. It means that Y is true unless both A and B are true.

The interesting thing about NAND gates is that any other logic gate can be constructed out of combination of NAND gates, and that's actually what is done in modern CMOS chips.
 
  • #10
Thank you very much, RocketSci, K2. You have really helped me and I wish the so-called teachers out there were also that much helpful and kind. Thanks. Please don't forget I'm quite a layman.

I'm just trying to visualize how the circuit would look and how the battery connections would be made.

Is the ground connection (at 0 V) connected to the earth?

Please have a look on the attached diagram. I'm sure you could see what I'm trying to ask. How are battery terminals connected?

One little just out of curiosity (let's see if that curiosity kills the cat). When a logic gate (or a circuit which it represents) is applied with a voltage, and when the voltage is above certain value, let's say 2.5 V, the logic gate is '1' means current is going through it. As long as there is a constant voltage, the current would keep flowing. Right?

I have looked up CMOS as both of you have mentioned the term. It looks it is a kind of one-package circuit which is connected to others of its kind to get a bigger circuit such integrated circuit Please let me know.

Thank you for all the help and your time.
 

Attachments

  • logic gates.PNG
    logic gates.PNG
    13.1 KB · Views: 545
  • #11
Help, please!
 
  • #12
It's the weekend, some people have other things happening and don't have a chance to respond.

I personally don't feel confident in answering your questions.
 
  • #13
jarednjames said:
It's the weekend, some people have other things happening and don't have a chance to respond.

I personally don't feel confident in answering your questions.

It's okay, no problem.
 
  • #14
I would suggest taking a step back, and separating several ideas which are possibly confusing you.

first off, logic gates are an abstract idea. you should start by treating them as a black box whos output is a function of its input, and that function can be described using boolean algebra. a logic 1 is just a logic 1. it can be "5v" or "1.2v" or "true" or "yes" or "heads" or whatever. similarly, a logic 0 can be the opposite of all those things. "false" or "no" or "tails".

a logic gate is therefore just a process to identify a choice based on other things, and its used to build a complicated logical system from lots of simple logical choices.

-----

now, the CMOS series of chips are just electrical circuits which follow the CMOS rules for defining what a logic "0" or "1" is. at this stage you really don't need to know about how the circuits operate, just how "CMOS" defines a logic 0 or 1.

remember, they need power, but that powersupply can be ignored when you consider the function of the chip.
---

finally, when you want to think about current and voltage and Fets and Power connections, you need a knowledge of analogue electronics.
if the chip is trying to provide a logic 1 on a pin, that voltage could be anywhere between the voltages specified on the datasheet. if its a CMOS chip, its guaranteed to follow the same set of rules as other CMOS chips, but the actual voltage and current will depend on the internal impedance of the pin, and the input impedance of the other chip, or whatever its interfacing with.

this is really quite a complex subject for a beginner, and I would not suggest trying to grab it all in one go. start with basic resistor networks.

----
on that diagram, VDD is the power supply, (connect the posative terminal of your battery here),
the triangle of lines at the bottom is "common" or earth. connect all negative terminals here. A and B are inputs, so connect them to switches which provide either 0v (ground) or VDD volts,
and Y is your output. measure with voltmetre? connect L.e.d to ground(earth)?
 
  • #15
Earl: Thanks a lot.

I don't really get this part. It would be kind of you if you can explain it in a more clear way.

on that diagram, VDD is the power supply, (connect the posative terminal of your battery here),
the triangle of lines at the bottom is "common" or earth. connect all negative terminals here. A and B are inputs, so connect them to switches which provide either 0v (ground) or VDD volts,
and Y is your output. measure with voltmetre? connect L.e.d to ground(earth)?
 
  • #16
what don't you get about it? what are you trying to do with the diagram? the 1st battery and the bulb you have drawn on it are correct, connect the "?" marked ends to ground/earth/common.

the battery you have drawn connected to A and B is wrong. well, silly anyway.

you should connect a wire to each A and B, then touch those wires to either the +ve or the -ve terminal of the 1st battery. which connections make the bulb light up? there are four different connections you could make. have you seen the truth table for a nand gate?
 
Last edited:
  • #17
earlofwessex said:
what don't you get about it? what are you trying to do with the diagram?


the 1st battery and the bulb you have drawn on it are correct, connect the "?" marked ends to ground/earth/common.

the battery you have drawn connected to A and B is wrong. well, silly anyway.

you should connect a wire to each A and B, then touch those wires to either the +ve or the -ve terminal of the 1st battery. which connections make the bulb light up? there are four different connections you could make. have you seen the truth table for a nand gate?

I have redrawn the diagram. Here is the truth table for NAND gate:
http://www.diracdelta.co.uk/science/source/t/r/truth table/image003.gif

The bulb would not light up only when both wires from A and B are connected to +ive terminal of the battery. Right?

When a wire from either of A or B is connected to the +ive terminal it is said it is at high voltage and when connected to -ive terminal it is at low voltage or zero voltage. Right? What would that state be called when the wire is not making a connection with any of the battery terminals? Please guide. Thanks.
 

Attachments

  • logic gates2.PNG
    logic gates2.PNG
    18.1 KB · Views: 538
  • #18
thats right!

connecting a wire to the +ve terminal is applying a logic 1 to that input, and connecting it to ground you are applying a logic 0.

when two logic ones are applied to the input A and B, the output will be a logic 0, in this case 0v. since the bulb has 0v at both ends, no current flows through it and it does not light.
otherwise the output will be a logic 1, in this case, close to the voltage of your battery, and so the bulb lights as there is a potential across it.

when the wire is not connected to either terminal, its said to be floating or undefined. this is bad, since the actual voltage may vary depending on the environment or anything, and you cannot control the logic level on that input. the logic level could be labelled as Z, but that really doesn't apply here, since its only an input.

when you design circuits, you must take care that this doesn't happen. look into "pull-up" resistors, and "de-bounceing" of switches
 
  • #19
earlofwessex said:
thats right!

connecting a wire to the +ve terminal is applying a logic 1 to that input, and connecting it to ground you are applying a logic 0.

when two logic ones are applied to the input A and B, the output will be a logic 0, in this case 0v. since the bulb has 0v at both ends, no current flows through it and it does not light.
otherwise the output will be a logic 1, in this case, close to the voltage of your battery, and so the bulb lights as there is a potential across it.

when the wire is not connected to either terminal, its said to be floating or undefined. this is bad, since the actual voltage may vary depending on the environment or anything, and you cannot control the logic level on that input. the logic level could be labelled as Z, but that really doesn't apply here, since its only an input.

when you design circuits, you must take care that this doesn't happen. look into "pull-up" resistors, and "de-bounceing" of switches

Thanks a lot, Earl. This has really helped me. I have checked pull-up resistors they don't make sense to me. It's okay.

I would be highly grateful if you could explain the bold section section with focus on red part.

I thank you for your help and time.
 
  • #20
I'm probably not the right person to expand on the red part, as I don't really know, but i'll give it a shot. and this is really an analogue question, so a fundamental understanding of current voltage and resistance is needed.

when you ask the question "whats the voltage at this point?" you are ultimately implying a reference voltage. you are really asking "whats the voltage between these two points?" but since its useful to chose one of those points to be 0v every time, you don't really need to specify it.

for there to be a voltage between two points, there has to be some electrical connection between those points, some potential which is applying a force to electrons. in the ideal model, the wire connected to the gate has zero resistance, and so must have the same potential all the way along it. and the gate of the Fet, or the base of the transistor is the only connection to that wire, but it is switched off, so there is no conductivity there. if there were some initial conditions where the wire had a charge, the Fet would turn on briefly, connecting the wire to ground, and depleting that charge. it would then remain off.

in real life however, only a tiny current is required to turn the transistor on, and the atmosphere is filled with EM fields. these EM fields can induce small potentials on the wire, causing the Fet to turn on. they would i think drain the charge and turn off again, but them it might happen again. what you could get is a rapid switching, causing the input to fluctuate very quickly between "1" and "0" and causing hell in your circuit.

--please anybody correct what I've said here if its wrong--

i think really, if you want to understand this properly, forget logic and concentrate on learning the behaviour of transistors and fets, and other analogue devices. - start from the start

if you want to learn logic, just use a pull up resistor, then all that above doesn't matter cause it will never happen. and they are a lot simpler.
 
  • #21
Earl, thanks a lot. I don't know if you are completely correct but it it does make sense to me.

forget logic and concentrate on learning the behaviour of transistors and fets, and other analogue devices. - start from the start

By "logic", what are you referring to? Logic circuits?
FET is also a transistor, then what really distinguishes a FET from general purpose PNP or NPN transistor?

if you want to learn logic, just use a pull up resistor, then all that above doesn't matter cause it will never happen. and they are a lot simpler.

When the wire operating the gate is not connected to either terminal, I mean when it's floating or undefined. It is bad for proper functioning of a logic circuit. But when one used a pull-up resistor one can avoid this problem, then it wouldn't really affect the circuit even when the wire connected to the gate is floating. Is that what you mean?

Please remember that I'm new to this science world and only have understanding of some basics. So, please explain in as much detail as possible. Thank you.
 
  • #22
by "logic" I mean the branch of electronics which is concerned with digital logic, logic gates, CMOS, that stuff.
I mean, if you want to know how analogue theory applies to logic IC's, you first need to understand how it applies to simpler electrical circuits.

---

I mean, that if you use a pull up resistor, the input to the logic gate will never be floating or undefined, so you don't need to worry about what happens for the circuit to work as you expect. the wire connected to the gate will never be floating.
 
  • #23
Hi, again,

I need your guys' guidance and help again. Please help me.

When a computer is to produce "101010101", where '1' = 5v and '0' = 0v, how would it do it? This is how I think it would be done, though I know my understanding is wrong it would help you understand what I'm asking for. Perhaps, a computer would produce 5v for 1 sec, then there would be a pause for 1 sec, then again there would be 5v for 1 sec, and so on. Do you get my question? Please guide me on the correct path. Thank you.

Please keep in mind that I'm just a layman so please be specific and to the point in your reply. Thanks.
 
  • #24
If a computer has a serial output (one wire to simplify things), then your example works, though timing between bits for fast data-links (eg. SATA3) is below 1 nanosecond. In a parallel output mode, you would have, say 32 separate wires, and each would represent one bit of the word at any given time. Of course, in the next time step, another 32 bit word could appear on the 'bus'. The 'high' = '1' voltage can be any value of voltage, whereas the 'low'='0' is typically Ground (but not always)...
 
  • #25
jackson6612 said:
Hi, again,

I need your guys' guidance and help again. Please help me.

When a computer is to produce "101010101", where '1' = 5v and '0' = 0v, how would it do it? This is how I think it would be done, though I know my understanding is wrong it would help you understand what I'm asking for. Perhaps, a computer would produce 5v for 1 sec, then there would be a pause for 1 sec, then again there would be 5v for 1 sec, and so on. Do you get my question? Please guide me on the correct path. Thank you.

Please keep in mind that I'm just a layman so please be specific and to the point in your reply. Thanks.

If you wanted to be able to actually measure with a voltmeter, you'd need something like a http://www.doc.ic.ac.uk/~ih/doc/par/" which has a separate set of "parallel" wires sitting side-by-side that can be individually programmed by software or the operating system of the computer. Those data lines are the D0-D7 lines referenced to the green ground pins. The C0-C3 control lines are used to "handshake the byte" which tells the outside device when the data lines have the valid, intended byte ready for reading. The S3-S7 lines accept status information back from the device.

Most modern computers today don't have parallel ports anymore and use some form of serial communication instead where the bits are lined up in time (very fast time) instead. This includes things like SATA, USB, RS-232, etc.

If you have a parallel port (and one option on a "modern" computer is a USB-to-Parallel convertor), you would write a program to write the data to the port, delay for a while and then write some more. A Google search for "http://www.google.com/search?hl=en&...gramming&aq=9&aqi=g10&aql=&oq=parallel+port+"" gives some leads to how you could do this in various programming languages.

Typically you ask the operating system for a "handle" the connects the program to the parallel port. Then you start writing bytes or integers to that handle using a library call which causes the byte or low byte of the integer to "magically" appear on the parallel port and causes the control lines to toggle. Then your next line of code would be a delay of some sort and then you'd loop back for the next byte (maybe you put the bytes in an array first).

Hope this helps. Frankly most of the responses were obviously going to go over your head. Sometimes techie-types forget what they know and what it was like to not know.
 
Last edited by a moderator:
  • #26
You have probably seen circuits involving switches, light bulbs and batteries, like this:


[PLAIN]http://dl.dropbox.com/u/4222062/AND-OR%20with%20switches.PNG

These are logic circuits.

In the top one, if you turn on either switch, the light will turn on. This is an OR gate.

You could have one of these with the switches on either side of a double bed, so that either occupant could turn on a lamp or a TV set.

In the bottom one, BOTH switches have to be closed to turn on the lamp. This is an AND gate.

You could have one of these with the switches on either side of a double bed so that if both persons switch their switch, the TV set could come on, but either could switch it off.
 
Last edited by a moderator:

1. What are logic gates and how do they work?

Logic gates are electronic circuits that perform basic logical operations, such as AND, OR, and NOT. They take in one or more binary inputs and produce a single binary output based on the logic of the specific gate. For example, an AND gate will output a 1 only when both inputs are 1, otherwise it will output a 0.

2. What is boolean algebra and how is it related to logic gates?

Boolean algebra is a mathematical system that deals with logical expressions using two values, typically represented as 0 and 1. It uses operations such as AND, OR, and NOT to manipulate these values. Logic gates are physical implementations of these operations and can be combined to create complex boolean expressions.

3. What are the basic types of logic gates?

The basic types of logic gates are AND, OR, and NOT. There are also other types such as NAND, NOR, and XOR, which are combinations of these basic gates. Each type of gate has a specific truth table that determines its output based on the input values.

4. What is the purpose of using boolean algebra in computer science?

Boolean algebra is used in computer science for designing and analyzing digital circuits, which are the building blocks of computer hardware. It is also used in programming, particularly in the creation of conditional statements and logical operations.

5. What is the difference between a logic gate and a flip-flop?

A logic gate is a basic component that performs a specific logical operation, while a flip-flop is a more complex circuit that can store and manipulate data. Flip-flops are essential in building sequential logic circuits and are used for memory storage in computer systems.

Similar threads

  • Electrical Engineering
Replies
1
Views
1K
  • Electrical Engineering
Replies
3
Views
2K
  • Electrical Engineering
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
4K
Replies
13
Views
4K
Replies
5
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Replies
1
Views
937
  • Electrical Engineering
Replies
4
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
21
Views
3K
Back
Top