1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.
-
Upload
julius-parrish -
Category
Documents
-
view
221 -
download
0
Transcript of 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.
![Page 1: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/1.jpg)
1
COMP541 COMP541 Digital Logic and Digital Logic and Computer DesignComputer Design
Montek SinghMontek Singh
Jan 9, 2012Jan 9, 2012
![Page 2: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/2.jpg)
2
TodayToday’’s Topicss Topics Course descriptionCourse description
WhatWhat’’s it abouts it aboutMechanics: grading, etc.Mechanics: grading, etc.
Material from Chapter 1 (self-study Material from Chapter 1 (self-study review)review)What is digital logic?What is digital logic?Binary signalingBinary signalingNumber systemsNumber systemsCodesCodes
![Page 3: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/3.jpg)
3
WhatWhat’’s Course About?s Course About? DigitalDigital logic,logic, focusing on the design focusing on the design of computersof computers
Stay mostly at a high level (i.e., Stay mostly at a high level (i.e., above transistors)above transistors)
Each person designs a MIPS CPUEach person designs a MIPS CPUand peripheral logic (VGA, joystick)and peripheral logic (VGA, joystick)Project like an Atari 2600 gameProject like an Atari 2600 game
High-level language High-level language Modern design practicesModern design practices
![Page 4: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/4.jpg)
FocusFocus Stay above Stay above transistor leveltransistor levelAt most one class At most one class on transistors and on transistors and VLSIVLSI
Expect you to Expect you to know assembly know assembly language language programmingprogramming
4
Physics
Devices
AnalogCircuits
DigitalCircuits
Logic
Micro-architecture
Architecture
OperatingSystems
ApplicationSoftware
electrons
transistorsdiodes
amplifiersfilters
AND gatesNOT gates
addersmemories
datapathscontrollers
instructionsregisters
device drivers
programs
focu
s of
this
cou
rse
![Page 5: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/5.jpg)
More Than Just ArchitectureMore Than Just Architecture Designing and implementing a computer Designing and implementing a computer is also aboutis also aboutManaging complexity (hierarchy, modularity, Managing complexity (hierarchy, modularity, regularity).regularity).
DebuggingDebuggingTesting and verifyingTesting and verifying
5
![Page 6: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/6.jpg)
The Three -YThe Three -Y’’ss HierarchyHierarchy
A system divided into modules and submodulesA system divided into modules and submodules
ModularityModularityHaving well-defined functions and interfacesHaving well-defined functions and interfaces
RegularityRegularityEncouraging uniformity, so modules can be Encouraging uniformity, so modules can be easily reusedeasily reused
![Page 7: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/7.jpg)
7
How Can We Do This?How Can We Do This? Labs on FridaysLabs on Fridays
Use: Field Programmable Gate Arrays Use: Field Programmable Gate Arrays (FPGAs)(FPGAs)Chips with a lot of circuitsChips with a lot of circuits
Tens of thousands to millions of transistorsTens of thousands to millions of transistorsProgrammableProgrammable
We write descriptions of the designWe write descriptions of the design““programsprograms”” describing design describing design
Tools translate to gates/wiresTools translate to gates/wires Download pattern/interconnection to Download pattern/interconnection to chipchipSort of like burning music to a rewritable CDSort of like burning music to a rewritable CD
![Page 8: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/8.jpg)
8
We Will Use This BoardWe Will Use This Board
What’s on it?
![Page 9: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/9.jpg)
9
Schematic DiagramSchematic Diagram
• Old fashioned way to describe logic• Still useful for documentation
![Page 10: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/10.jpg)
10
VerilogVerilog/*/* * A 32-bit counter with only 4 bits of output. The idea is* A 32-bit counter with only 4 bits of output. The idea is * to select which of the counter stages you want to pass on.* to select which of the counter stages you want to pass on. ** * Anselmo Lastra, November 2002* Anselmo Lastra, November 2002 */*/ module cntr_32c(clk,res,out);module cntr_32c(clk,res,out); input clk;input clk; input res;input res; output [3:0] out;output [3:0] out;
reg [31:0] count;reg [31:0] count;
always @ (posedge res or posedge clk)always @ (posedge res or posedge clk) if(res)if(res)
count <= 0;count <= 0;elseelse
count <= count + 1;count <= count + 1; assign out[3] = count[28];assign out[3] = count[28]; assign out[2] = count[27];assign out[2] = count[27]; assign out[1] = count[26];assign out[1] = count[26]; assign out[0] = count[25];assign out[0] = count[25];
endmoduleendmodule
![Page 11: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/11.jpg)
11
Xilinx SoftwareXilinx Software Use design tools from chip makerUse design tools from chip maker Have full version on lab PCsHave full version on lab PCs Can install on your PCCan install on your PC
Download from webDownload from web
![Page 12: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/12.jpg)
12
Class Web PagesClass Web Pages Will be up by ThursdayWill be up by Thursday’’s classs class Linked from my home pageLinked from my home pagehttp://www.cs.unc.edu/~montek
All lecture slides posted thereAll lecture slides posted thereWill Will trytry to put them there before class to put them there before class
Schedule, homework, etc. posted thereSchedule, homework, etc. posted there Lab documents there alsoLab documents there also See Blackboard/Sakai for scores/gradesSee Blackboard/Sakai for scores/grades
![Page 13: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/13.jpg)
TextbookTextbook Harris and HarrisHarris and Harris Digital Design and Computer Digital Design and Computer ArchitectureArchitecture
Morgan Kaufmann, 2007Morgan Kaufmann, 2007 Amazon has for $70Amazon has for $70 Extra material onExtra material onhttp://www.elsevierdirect.com/companion.jsp?ISBN=9780123704979
13
![Page 14: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/14.jpg)
14
Overview of TextbookOverview of Textbook Chapters 1-5: Digital logicChapters 1-5: Digital logic
Combinational, sequential, basic circuits, Combinational, sequential, basic circuits, HDLHDL
Chapter 6: ArchitectureChapter 6: ArchitectureFast – review for those who took COMP 411Fast – review for those who took COMP 411
Chapter 7: MicroarchitecturesChapter 7: Microarchitectures Chapters 8: MemoriesChapters 8: Memories Appendix A: ImplementationAppendix A: Implementation
FPGAs, etc.FPGAs, etc.
![Page 15: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/15.jpg)
15
Order of TopicsOrder of Topics Will change order from that in bookWill change order from that in book
To try to get you working on interesting labs To try to get you working on interesting labs soonersooner
![Page 16: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/16.jpg)
16
May Also NeedMay Also Need COMP411 textbook (Patterson/Hennessy)COMP411 textbook (Patterson/Hennessy)
For MIPS referenceFor MIPS referenceHow many have one?How many have one?I can copy the few necessary pagesI can copy the few necessary pages
Verilog referenceVerilog referenceBook optionalBook optionalWeb pages – see course home pageWeb pages – see course home page
![Page 17: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/17.jpg)
17
GradingGrading Labs – 35%Labs – 35%
Easier at first; later ones will count moreEasier at first; later ones will count more
Lab final project – 15%Lab final project – 15% Homework – 25%Homework – 25% Two tests spaced evenly – 12.5% eachTwo tests spaced evenly – 12.5% each
![Page 18: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/18.jpg)
18
LabsLabs Paced slowly at firstPaced slowly at first
Familiarization with tools, simple Familiarization with tools, simple combinational design, design a digital lock combinational design, design a digital lock or similaror similar
Peripheral – VGA, opt. keyboard Peripheral – VGA, opt. keyboard interface or joystickinterface or joystick
Build up computer componentsBuild up computer componentsRegisters, ALU, decoderRegisters, ALU, decoder
Assemble a simple MIPSAssemble a simple MIPS Add more features, enough for simple Add more features, enough for simple computercomputer
Final demo – game or similarFinal demo – game or similar
![Page 19: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/19.jpg)
19
Lab SectionsLab Sections No lab this FridayNo lab this Friday
You need a little more info to beginYou need a little more info to beginBegin next weekBegin next week
Lab is in FB007Lab is in FB007
![Page 20: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/20.jpg)
20
Late PolicyLate Policy Homework assignments and lab reports Homework assignments and lab reports due by classdue by classLabs due on Monday after the lab periodLabs due on Monday after the lab period
One class late, 10 points offOne class late, 10 points off Two classes late, 25 points offTwo classes late, 25 points off Not accepted laterNot accepted later
![Page 21: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/21.jpg)
21
WhatWhat’’s Your Background?s Your Background? Course experienceCourse experience Work, etc.Work, etc. Which COMP411?Which COMP411? WhatWhat’’s your intent in taking class?s your intent in taking class?
Questions?Questions?
![Page 22: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/22.jpg)
22
Office HoursOffice Hours Would like to wait a week to setWould like to wait a week to set
Send email if you want to meet in the Send email if you want to meet in the mean timemean time
![Page 23: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/23.jpg)
23
Now Shift to TechnologyNow Shift to Technology
Should be review for all of youShould be review for all of you
![Page 24: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/24.jpg)
24
Digital vs. AnalogDigital vs. Analog Analog – infinite resolutionAnalog – infinite resolution
Like (old fashioned) radio dialLike (old fashioned) radio dialWeWe’’ll do very little with analogll do very little with analog
VGA, maybe soundVGA, maybe sound
Digital – a finite set of valuesDigital – a finite set of valuesLike moneyLike moneyCanCan’’t get smaller than centst get smaller than centsTypically also has maximum valueTypically also has maximum value
![Page 25: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/25.jpg)
25
Binary SignalingBinary Signaling Zero voltsZero volts
FALSE or 0FALSE or 0
5 or 3.3 (or 1.8 or 1.5) volts5 or 3.3 (or 1.8 or 1.5) voltsTRUE or 1TRUE or 1
Modern chips down to 1VModern chips down to 1V
Why not multilevel signaling?Why not multilevel signaling?
![Page 26: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/26.jpg)
26
Discrete DataDiscrete Data Some data inherently discreteSome data inherently discrete
Names (sets of letters)Names (sets of letters)
Some quantizedSome quantizedMusic recorded from microphoneMusic recorded from microphoneNote that other examples like music from CD Note that other examples like music from CD or electronic keyboard already quantizedor electronic keyboard already quantized
Mouse movement is quantizedMouse movement is quantizedWell, some miceWell, some mice
![Page 27: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/27.jpg)
27
Numbers and ArithmeticNumbers and Arithmetic I have put most of these slides at endI have put most of these slides at end
Backup in case youBackup in case you’’ve forgottenve forgotten Review of binary numbers, Review of binary numbers, Hexadecimal,Hexadecimal,ArithmeticArithmetic
LetLet’’s covers coverOther codes, parityOther codes, parity
![Page 28: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/28.jpg)
28
BCDBCD Binary Coded DecimalBinary Coded Decimal Decimal digits stored in binaryDecimal digits stored in binary
Four bits/digitFour bits/digit Like hex, except stops at 9Like hex, except stops at 9 ExampleExample
931 is coded as 1001 0011 0001931 is coded as 1001 0011 0001
Remember: these are just Remember: these are just encodingsencodings. Meanings . Meanings are assigned by us.are assigned by us.
![Page 29: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/29.jpg)
29
Other Codes ExistOther Codes Exist Non positionalNon positional Example: Gray CodeExample: Gray Code
Only one bit changes at a timeOnly one bit changes at a time000,001,011,010,110,111,101,100000,001,011,010,110,111,101,100Why is this useful?Why is this useful?
Actually thereActually there’’s a family of Gray codess a family of Gray codes
Ref: http://lib-www.lanl.gov/numerical/bookcpdf/c20-2.pdf
![Page 30: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/30.jpg)
30
Shaft EncoderShaft Encoder
![Page 31: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/31.jpg)
31
Character CodesCharacter Codes From numbers to lettersFrom numbers to letters ASCIIASCII
Stands for American Standard Code for Stands for American Standard Code for Information InterchangeInformation Interchange
Only 7 bits definedOnly 7 bits defined
UnicodeUnicode You may make up your own code for the You may make up your own code for the MIPS VGAMIPS VGA
![Page 32: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/32.jpg)
32
ASCII tableASCII table
![Page 33: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/33.jpg)
33
Even ParityEven Parity Sometimes high-order bit of ASCII coded Sometimes high-order bit of ASCII coded to enable detection of errorsto enable detection of errors
Even parity – set bit to make number of Even parity – set bit to make number of 11’’s evens even
ExamplesExamplesA (01000001) with even parity is 01000001A (01000001) with even parity is 01000001
C (01000011) with even parity is 11000011C (01000011) with even parity is 11000011
![Page 34: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/34.jpg)
34
Odd ParityOdd Parity Similar except make the number of 1Similar except make the number of 1’’s s oddodd
ExamplesExamplesA (01000001) with odd parity is 11000001A (01000001) with odd parity is 11000001
C (01000011) with odd parity is 01000011C (01000011) with odd parity is 01000011
![Page 35: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/35.jpg)
35
Error DetectionError Detection Note that parity detects only simple Note that parity detects only simple errorserrorsOne, three, etc. bitsOne, three, etc. bits
More complex methods existMore complex methods exist Some that enable Some that enable recoveryrecovery of original of original infoinfoCost is more redundant bitsCost is more redundant bits
![Page 36: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/36.jpg)
36
TodayToday’’s Topicss Topics IntroductionIntroduction Digital logicDigital logic Number systemsNumber systems ArithmeticArithmetic CodesCodes ParityParity The encoding is keyThe encoding is key
Standards are used to agree on encodingsStandards are used to agree on encodings Special purpose codes for particular usesSpecial purpose codes for particular uses
![Page 37: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/37.jpg)
37
HomeworkHomework None, but…None, but… I expect you to know number systems well and I expect you to know number systems well and be able to do conversions and arithmeticbe able to do conversions and arithmetic Decimal – BinaryDecimal – Binary Binary – DecimalBinary – Decimal Decimal – HexDecimal – Hex Hex – DecimalHex – Decimal
Can do some of the problems – 1.7 to 1.27 are Can do some of the problems – 1.7 to 1.27 are all about conversion – if you think you need a all about conversion – if you think you need a refresher. Answers to odd numbered on book refresher. Answers to odd numbered on book website.website.
![Page 38: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/38.jpg)
38
ReadingReading Read Chapter 1Read Chapter 1
![Page 39: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/39.jpg)
39
Next ClassNext Class Combinational Logic BasicsCombinational Logic Basics
Next Week: Lab previewNext Week: Lab previewI will demo tools in class, probably I will demo tools in class, probably WednesdayWednesday
![Page 40: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/40.jpg)
40
Backup SlidesBackup Slides
Should be all review materialShould be all review material
![Page 41: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/41.jpg)
41
Binary NumbersBinary Numbers Strings of binary digits (Strings of binary digits (““bitsbits””))
One bit can store a number from 0 to 1One bit can store a number from 0 to 1nn bits can store numbers from 0 to 2 bits can store numbers from 0 to 2nn
![Page 42: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/42.jpg)
42
Binary – Powers of 2Binary – Powers of 2 Positional representation Positional representation Each digit represents a power of 2Each digit represents a power of 2
So 101 binary isSo 101 binary is
1 1 •• 2 222 + 0 + 0 • • 2211 + 1 + 1 •• 2 200
oror
1 1 • 4 + • 4 + 0 0 • 2 + • 2 + 1 1 • 1 = 5• 1 = 5
![Page 43: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/43.jpg)
43
Converting Binary to DecimalConverting Binary to Decimal Easy, just multiply digit by power of 2Easy, just multiply digit by power of 2 Just like a decimal number is Just like a decimal number is representedrepresented
Example follows Example follows
![Page 44: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/44.jpg)
44
Binary Binary Decimal Example Decimal Example
77 66 55 44 33 22 11 00
2277 2266 2255 2244 2233 2222 2211 2200
128128 6464 3232 1616 88 44 22 11
11 00 00 11 11 11 00 00
128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156
What is 10011100 in decimal?What is 10011100 in decimal?
![Page 45: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/45.jpg)
45
Decimal to BinaryDecimal to Binary A little more work than binary to A little more work than binary to decimaldecimal
Some examplesSome examples3 = 2 + 1 = 3 = 2 + 1 = 1111 (that (that’’s 1s 1••2211 + 1 + 1••2200))5 = 4 + 1 = 5 = 4 + 1 = 101101 (that (that’’s 1s 1••2222 + 0 + 0••2211 + 1 + 1••2200))
![Page 46: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/46.jpg)
46
Algorithm – Decimal to Algorithm – Decimal to BinaryBinary Find largest power-of-two smaller than Find largest power-of-two smaller than decimal numberdecimal number
Make the appropriate binary digit a Make the appropriate binary digit a ‘‘11’’ Subtract the power of 2 from decimalSubtract the power of 2 from decimal Do the same thing againDo the same thing again
![Page 47: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/47.jpg)
47
Decimal Decimal Binary Example Binary Example Convert 28 decimal to binaryConvert 28 decimal to binary
77 66 55 44 33 22 11 00
2277 2266 2255 2244 2233 2222 2211 2200
128128 6464 3232 1616 88 44 22 11
32 is too large, so use 16Binary 10000 Decimal 28 – 16 = 12
Binary 11000 Decimal 12 – 8 = 4Next is 8
Binary 11100 Decimal 4 – 4 = 0Next is 4
![Page 48: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/48.jpg)
48
HexadecimalHexadecimal Strings of 0s and 1s too hard to writeStrings of 0s and 1s too hard to write Use base-16 or Use base-16 or hexadecimalhexadecimal – 4 bits – 4 bits
DecDec BinBin HexHex
00 00000000 00
11 00010001 11
22 00100010 22
33 00110011 33
44 01000100 44
55 01010101 55
66 01100110 66
77 01110111 77
DecDec BinBin HexHex
88 10001000 88
99 10011001 99
1010 10101010 ??
1111 10111011 ??
1212 11001100 ??
1313 11011101 ??
1414 11101110 ??
1515 11111111 ??
![Page 49: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/49.jpg)
49
HexadecimalHexadecimal Letters to represent 10-15Letters to represent 10-15
DecDec BinBin HexHex
00 00000000 00
11 00010001 11
22 00100010 22
33 00110011 33
44 01000100 44
55 01010101 55
66 01100110 66
77 01110111 77
DecDec BinBin HexHex
88 10001000 88
99 10011001 99
1010 10101010 aa
1111 10111011 bb
1212 11001100 cc
1313 11011101 dd
1414 11101110 ee
1515 11111111 ff
•Power of 2Power of 2
•Size of byteSize of byte
Why useWhy usebase 16?base 16?
![Page 50: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/50.jpg)
50
Hex to BinaryHex to Binary
Convention – write 0x before numberConvention – write 0x before number Hex to Binary – just convert digitsHex to Binary – just convert digits
BinBin HexHex
00000000 00
00010001 11
00100010 22
00110011 33
01000100 44
01010101 55
01100110 66
01110111 77
10001000 88
10011001 99
10101010 aa
10111011 bb
11001100 cc
11011101 dd
11101110 ee
11111111 ff
0x2ac0x2ac
00100010 10101010 11001100
0x2ac = 0010101011000x2ac = 001010101100
No magic – remember hex digit = 4 bitsNo magic – remember hex digit = 4 bits
![Page 51: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/51.jpg)
51
Binary to HexBinary to Hex
Just convert groups of 4 bitsJust convert groups of 4 bits
BinBin HexHex
00000000 00
00010001 11
00100010 22
00110011 33
01000100 44
01010101 55
01100110 66
01110111 77
10001000 88
10011001 99
10101010 aa
10111011 bb
11001100 cc
11011101 dd
11101110 ee
11111111 ff
101001101111011101001101111011
10111011
55 33 77 bb
101001101111011 = 0x537b101001101111011 = 0x537b
0101 0101 0111 0111 0011 0011
![Page 52: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/52.jpg)
52
Hex to DecimalHex to Decimal Just multiply each hex digit by Just multiply each hex digit by decimal value, and add the results.decimal value, and add the results.
161633 161622 161611 161600
40964096 256256 1616 11
0x2ac0x2ac
2 2 • 256• 256 + 10 + 10 • 16• 16 + 12 + 12 • 1• 1 = 684= 684
DecDec HexHex
00 00
11 11
22 22
33 33
44 44
55 55
66 66
77 77
88 88
99 99
1010 aa
1111 bb
1212 cc
1313 dd
1414 ee
1515 ff
![Page 53: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/53.jpg)
53
Decimal to HexDecimal to HexAnalogous to decimal Analogous to decimal binary. binary.
1.1. Find largest power-of-16 smaller Find largest power-of-16 smaller than decimal numberthan decimal number
2.2. Divide by power-of-16. The integer Divide by power-of-16. The integer result is hex digit.result is hex digit.
3.3. The remainder is new decimal The remainder is new decimal number.number.
4.4. Do the same thing againDo the same thing again
![Page 54: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/54.jpg)
54
Decimal to HexDecimal to Hex
161633 161622 161611 161600
40964096 256256 1616 11
DecDec HexHex
00 00
11 11
22 22
33 33
44 44
55 55
66 66
77 77
88 88
99 99
1010 aa
1111 bb
1212 cc
1313 dd
1414 ee
1515 ff
684684
684/256 = 2684/256 = 2 0x2__
684%256 = 172684%256 = 172
172/16 = 10 = a172/16 = 10 = a 0x2a_172%16 = 12 = c172%16 = 12 = c 0x2ac
![Page 55: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/55.jpg)
55
OctalOctal Octal is base 8Octal is base 8 Similar to hexadecimalSimilar to hexadecimal
ConversionsConversions
Less convenient for use with 8-bit Less convenient for use with 8-bit bytesbytes
![Page 56: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/56.jpg)
56
Arithmetic -- additionArithmetic -- addition Binary similar to decimal arithmeticBinary similar to decimal arithmetic
00 11 11 00 00
++ 11 00 00 00 11
11 11 11 00 11
No carries 11 00 11 11 00 00
11 00 11 11 00
++ 11 00 11 11 11
11 00 11 11 00 11
Carries
1+1 is 2 (or 102), which results in a carry
![Page 57: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/57.jpg)
57
Arithmetic -- subtractionArithmetic -- subtraction
11 00 11 11 00
-- 11 00 00 11 00
00 00 11 00 00
No borrows 00 00 11 11 00
11 11 11 11 00
-- 11 00 00 11 11
00 11 00 11 11
Borrows
0 - 1 results in a borrow
![Page 58: 1 COMP541 Digital Logic and Computer Design Montek Singh Jan 9, 2012.](https://reader036.fdocuments.net/reader036/viewer/2022062315/5697c0231a28abf838cd43aa/html5/thumbnails/58.jpg)
58
Arithmetic -- multiplicationArithmetic -- multiplication
11 00 11 11
00 00 00 00
11 00 11 11
11 11 00 11 11 11
Successive additions of multiplicand or zero,multiplied by 2 (102).
Note that multiplication by 102 just shifts bits left.
11 00 11 11
XX 11 00 11