LOGIC GATES - SARTHAK YADAV

Preview:

Citation preview

Logic GatesLogic Gates Made by- sarthak yadavMade by- sarthak yadav Roll no-39Roll no-39 Class 12 A2Class 12 A2

11

Review of Boolean Review of Boolean algebraalgebra

Just like Boolean logicJust like Boolean logic Variables can only be 1 or 0Variables can only be 1 or 0

Instead of true / falseInstead of true / false

22

Review of Boolean Review of Boolean algebraalgebra

Not is a horizontal bar above the numberNot is a horizontal bar above the number 0 = 10 = 1 1 = 01 = 0

Or is a plusOr is a plus 0+0 = 00+0 = 0 0+1 = 10+1 = 1 1+0 = 11+0 = 1 1+1 = 11+1 = 1

And is multiplicationAnd is multiplication 0*0 = 00*0 = 0 0*1 = 00*1 = 0 1*0 = 01*0 = 0 1*1 = 11*1 = 1

33

__

__

Review of Boolean Review of Boolean algebraalgebra

Example: translate (Example: translate (xx++yy++zz)()(xyzxyz) to a Boolean ) to a Boolean logic expressionlogic expression ((xxyyzz))((xxyyzz))

We can define a Boolean function:We can define a Boolean function: F(x,y) = (F(x,y) = (xxyy))((xxyy))

And then write a “truth table” for it:And then write a “truth table” for it:

44

__ __ __

x y F(x,y)1 1 01 0 00 1 00 0 0

Basic logic gatesBasic logic gates

NotNot

AndAnd

OrOr

NandNand

NorNor

XorXor55

x x

xy

xy xyxyz

zx+yx

yxy

x+y+zz

xy

xy

x+yxy

xÅyxy

Converting between circuits Converting between circuits and equationsand equations Find the output of the following circuitFind the output of the following circuit

Answer: (Answer: (x+yx+y)y)y Or (Or (xxyy))yy 66

xy

x+y

y

(x+y)y

____

xy

y

Converting between circuits Converting between circuits and equationsand equations Find the output of the following circuitFind the output of the following circuit

Answer: xyAnswer: xy Or Or ((xxyy) ≡ ) ≡ xxyy 77

x

y

x

yx y x y

_ __ _ ______

Converting between circuits Converting between circuits and equationsand equations

Write the circuits for the following Write the circuits for the following Boolean algebraic expressionsBoolean algebraic expressions

a)a) xx++yy

88

xyxyxy

____

x x+y

Converting between circuits Converting between circuits and equationsand equations

Write the circuits for the following Write the circuits for the following Boolean algebraic expressionsBoolean algebraic expressions

b)b) ((xx++yy))xx

99

xyxyxy

______________

xy

x+y x+y (x+y)x

Writing xor using Writing xor using and/or/notand/or/not

p p ÅÅ qq ( (pp qq) ) ¬( ¬(pp qq)) x x ÅÅ y y (x + y)( (x + y)(xyxy))

1010

x y xÅy1 1 01 0 10 1 10 0 0

xy

x+y

xy xy

(x+y)(xy)

________

Converting decimal Converting decimal numbers to binarynumbers to binary

53 53 = 32 + 16 + 4 + 1= 32 + 16 + 4 + 1= 2= 255 + 2 + 244 + 2 + 222 + 2 + 200

= 1*2= 1*255 + 1*2 + 1*244 + 0*2 + 0*233 + 1*2 + 1*222 + 0*2 + 0*211 + 1*2 + 1*200

= 110101 in binary= 110101 in binary= 00110101 as a full byte in binary= 00110101 as a full byte in binary

211= 128 + 64 + 16 + 2 + 1211= 128 + 64 + 16 + 2 + 1= 2= 277 + 2 + 266 + 2 + 244 + 2 + 211 + 2 + 200

= 1*2= 1*277 + 1*2 + 1*266 + 0*2 + 0*255 + 1*2 + 1*244 + 0*2 + 0*233 + 0*2 + 0*222 + + 1*21*211 + 1*2 + 1*200

= 11010011 in binary= 11010011 in binary

1111

Converting binary numbers Converting binary numbers to decimalto decimal

What is 10011010 in decimal?What is 10011010 in decimal?1001101010011010 = 1*2 = 1*277 + 0*2 + 0*266 + 0*2 + 0*255 + 1*2 + 1*244 + 1*2 + 1*233 + +

0*20*222 + 1*2 + 1*211 + 0*2 + 0*200

= 2= 277 + 2 + 244 + 2 + 233 + 2 + 211

= 128 + 16 + 8 + 2= 128 + 16 + 8 + 2 = 154= 154

What is 00101001 in decimal?What is 00101001 in decimal? 00101001 = 0*200101001 = 0*277 + 0*2 + 0*266 + 1*2 + 1*255 + 0*2 + 0*244 + 1*2 + 1*233 + +

0*20*222 + 0*2 + 0*211 + 1*2 + 1*200

= 2= 255 + 2 + 233 + 2 + 200

= 32 + 8 + 1= 32 + 8 + 1 = 41= 41

1212

A note on binary numbersA note on binary numbers In this slide set we are only dealing with In this slide set we are only dealing with

non-negative numbersnon-negative numbers The book (section 1.5) talks about two’s-The book (section 1.5) talks about two’s-

complement binary numberscomplement binary numbers Positive (and zero) two’s-complement binary Positive (and zero) two’s-complement binary

numbers is what was presented herenumbers is what was presented here We won’t be getting into negative two’s-We won’t be getting into negative two’s-

complmeent numberscomplmeent numbers

1313

How to add binary How to add binary numbersnumbers

Consider adding two 1-bit binary numbers Consider adding two 1-bit binary numbers xx and and yy 0+0 = 00+0 = 0 0+1 = 10+1 = 1 1+0 = 11+0 = 1 1+1 = 101+1 = 10

Carry is Carry is xx AND AND yy Sum is Sum is xx XOR XOR yy The circuit to compute this is called a half-adderThe circuit to compute this is called a half-adder

1414

x y Carry Sum0 0 0 00 1 0 11 0 0 11 1 1 0

The half-adderThe half-adder Sum = Sum = xx XOR XOR yy Carry = Carry = xx AND AND yy

1515

xy Sum

Carry

xy Sum

Carry

x y Carry Sum0 0 0 00 1 0 11 0 0 11 1 1 0

Using half addersUsing half adders We can then use a half-adder to compute We can then use a half-adder to compute

the sum of two Boolean numbersthe sum of two Boolean numbers

1616

1 1 0 0+ 1 1 1 0

010?

001

How to fix thisHow to fix this We need to create an adder that can take a carry bit as We need to create an adder that can take a carry bit as

an additional inputan additional input Inputs: Inputs: xx, , yy, carry in, carry in Outputs: sum, carry outOutputs: sum, carry out

This is called a full adderThis is called a full adder Will add Will add xx and and yy with a half-adder with a half-adder Will add the sum of that to the Will add the sum of that to the

carry incarry in What about the carry out?What about the carry out?

It’s 1 if either (or both):It’s 1 if either (or both): xx++yy = 10 = 10 xx++yy = 01 and carry in = 1 = 01 and carry in = 1

1717

x y c carry sum1 1 1 1 11 1 0 1 01 0 1 1 01 0 0 0 10 1 1 1 00 1 0 0 10 0 1 0 10 0 0 0 0

The full adderThe full adder The “HA” boxes are The “HA” boxes are

half-addershalf-adders

1818

HAX

Y

S

C

HAX

Y

S

C

xy

c

c

sHAX

Y

S

C

HAX

Y

S

C

xy

c

x y c s1 c1 carry sum

1 1 1 0 1 1 11 1 0 0 1 1 01 0 1 1 0 1 01 0 0 1 0 0 10 1 1 1 0 1 00 1 0 1 0 0 10 0 1 0 0 0 10 0 0 0 0 0 0

s1

c1

The full adderThe full adder The full circuitry of the full adderThe full circuitry of the full adder

1919

xy

s

c

c

Adding bigger binary Adding bigger binary numbersnumbers

Just chain full adders togetherJust chain full adders together

2020

HAX

Y

S

C

FAC

Y

X

S

C

FAC

Y

X

S

C

FAC

Y

X

S

C

x1y1x2y2x3y3

x0y0

s0

s1

s2

s3c

. . .

Adding bigger binary Adding bigger binary numbersnumbers

A half adder has 4 logic gatesA half adder has 4 logic gates A full adder has two half adders plus a OR gateA full adder has two half adders plus a OR gate

Total of 9 logic gatesTotal of 9 logic gates To add To add nn bit binary numbers, you need 1 HA and bit binary numbers, you need 1 HA and nn-1 -1

FAsFAs To add 32 bit binary numbers, you need 1 HA and 31 To add 32 bit binary numbers, you need 1 HA and 31

FAsFAs Total of 4+9*31 = 283 logic gatesTotal of 4+9*31 = 283 logic gates

To add 64 bit binary numbers, you need 1 HA and 63 To add 64 bit binary numbers, you need 1 HA and 63 FAsFAs Total of 4+9*63 = 571 logic gatesTotal of 4+9*63 = 571 logic gates

2121

More about logic gatesMore about logic gates To implement a logic gate in hardware, To implement a logic gate in hardware,

you use a transistoryou use a transistor Transistors are all enclosed in an “IC”, or Transistors are all enclosed in an “IC”, or

integrated circuitintegrated circuit The current Intel Pentium IV processors The current Intel Pentium IV processors

have 55 million transistors!have 55 million transistors!

2222

Flip-flopsFlip-flops Consider the following circuit:Consider the following circuit:

What does it do?What does it do?2323

MemoryMemory A flip-flop holds a single bit of memoryA flip-flop holds a single bit of memory

The bit “flip-flops” between the two NAND The bit “flip-flops” between the two NAND gatesgates

In reality, flip-flops are a bit more In reality, flip-flops are a bit more complicatedcomplicated Have 5 (or so) logic gates (transistors) per flip-Have 5 (or so) logic gates (transistors) per flip-

flopflop Consider a 1 Gb memory chipConsider a 1 Gb memory chip

1 Gb = 8,589,934,592 bits of memory1 Gb = 8,589,934,592 bits of memory That’s about 43 million transistors!That’s about 43 million transistors!

In reality, those transistors are split into 9 In reality, those transistors are split into 9 ICs of about 5 million transistors eachICs of about 5 million transistors each

2424

HexadecimalHexadecimal A numerical range A numerical range

from 0-15from 0-15 Where A is 10, B is 11, Where A is 10, B is 11,

… and F is 15… and F is 15 Often written with a Often written with a

‘0x’ prefix‘0x’ prefix So 0x10 is 10 hex, or So 0x10 is 10 hex, or

1616 0x100 is 100 hex, or 0x100 is 100 hex, or

256256 Binary numbers easily Binary numbers easily

translate:translate: 2525

DEADBEEFDEADBEEF Many IBM machines would fill allocated Many IBM machines would fill allocated

(but uninitialized) memory with the hexa-(but uninitialized) memory with the hexa-decimal pattern 0xDEADBEEFdecimal pattern 0xDEADBEEF Decimal -21524111Decimal -21524111

Makes it easier to spot in a debuggerMakes it easier to spot in a debugger

2626

Recommended