CMSC 100 CMSC 100 From the Bottom Up: It's All Just Bits Professor Marie desJardins Tuesday, September 11, 2012 Tue 9/11/12 1CMSC 100 -- Just Bits.

Slides:



Advertisements
Similar presentations
The Binary Numbering Systems
Advertisements

Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 2 Number Systems.
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Computer Structures Lecture 2: Working with 0’s and 1’s.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 3 Dr. Shi Dept. of Electrical and Computer Engineering.
Assembly Language and Computer Architecture Using C++ and Java
Chapter 4 Operations on Bits
Level ISA3: Information Representation
Assembly Language and Computer Architecture Using C++ and Java
Storage of Bits Computers represent information as patterns of bits
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
The Binary Number System
Chapter 12 Digital Logic Circuit Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CISC1400: Binary Numbers & Computer Fall 2011, Dr. Zhang 1.
Mantıksal Tasarım – BBM231 M. Önder Efe
Topic 4 Computer Mathematics and Logic
Bits and Data Storage. Basic Hardware Units of a Computer.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Numbering systems.
Computers Organization & Assembly Language
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Binary Numbers.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Logic and Digital System Design - CS 303
IT253: Computer Organization
Pengantar Teknologi Informasi dan Ilmu Komputer Information Technology and Data Representation PTIIK- UB.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
1 DLD Lecture 18 Recap. 2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
Data Representation Bits, Bytes, Binary, Hexadecimal.
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
Data Representation (in computer system). Data Representation How do computers represent data? b The computers are digital Recognize.
Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Computer Organization and Assembly Languages 2007/11/10
CMSC 100 CMSC 100 From the Bottom Up: It's All Just Bits Professor Marie desJardins Thursday, September 10, 2009
Chapter 1: Binary Systems
Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Logic Design EE-2121 Manesh T. Digital Systems  Introduction  Binary Quantities and Variables  Logic Gates  Boolean Algebra  Combinational Logic.
Introduction to Computing Systems and Programming Digital Logic Structures.
Number Systems and Computer Arithmetic Winter 2014 COMP 1380 Discrete Structures I Computing Science Thompson Rivers University.
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
1 Binary Signals Logic gate circuits are designed to input and output only two types of signals: “high” (1) and “low” (0), as represented by a variable.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
3 – Boolean Logic and Logic Gates 4 – Binary Numbers
Invitation to Computer Science, C++ Version, Fourth Edition
Morgan Kaufmann Publishers
3.1 Denary, Binary and Hexadecimal Number Systems
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Invitation to Computer Science, Java Version, Third Edition
Chapter 1 Data Storage.
CMSC 100 From the Bottom Up: It's All Just Bits
Fundamentals of Data Representation
CMSC 100 From the Bottom Up: It's All Just Bits
Chapter Four Data Representation in Computers By Bezawit E.
CMSC250 Fall 2018 Circuits 1 1.
UNIT – 3 & 4. Data Representation and Internal
Presentation transcript:

CMSC 100 CMSC 100 From the Bottom Up: It's All Just Bits Professor Marie desJardins Tuesday, September 11, 2012 Tue 9/11/12 1CMSC Just Bits

Just Bits Inside the computer, all information is stored as bits A “bit” is a single unit of information Each “bit” is set to either zero or one How do we get complex systems like Google, Matlab, and our cell phone apps? Tue 9/11/12CMSC Just Bits 2

Today’s Topics Logic operations and truth tables Logic gates and simple circuits Memory storage Binary numbers Conversions Hexadecimal Representing other data Integers (including negative numbers) Floating point numbers Characters (ASCII) Tue 9/11/12CMSC Just Bits 3

Logic and Truth Tables Tue 9/11/12CMSC Just Bits 4

Manipulating Bits What does a bit value “mean”? 0 = FALSE[off, no] 1 = TRUE[on, yes] Just as in regular algebra, we can think of “variables” that represent a single bit If X is a Boolean variable, then the value of X is either: 0[FALSE, off, no] or 1[TRUE, on, yes] In algebra, we have operations that we can perform on numbers: Unary operations: Negate, square, square-root, … Binary operations: Add, subtract, multiply, divide, … What are the operations you can imagine performing on bits? Unary: ?? Binary: ?? Thought problem: How many unary operations are there? How many binary operations? Tue 9/11/12CMSC Just Bits 5

Remember Function Tables? Tue 9/11/12CMSC Just Bits 6 XX2X …… XYX + Y ………

Boolean Operations: “Truth Tables” Negation (NOT):  Conjunction (AND):  Disjunction (OR):  Tue 9/11/12CMSC Just Bits 7 X XX XY X  Y XY X  Y X XX FT TF Or equivalently… XY X  Y FFF FTF TFF TTT XY X  Y FFF FTT TFT TTT

Boolean Expressions EXERCISE: What would a truth table look like for the expression: (A  B)  (  B  C) Tue 9/11/12CMSC Just Bits 8 ABC A  B BB  B  C(A  B)  (  B  C)

Boolean Expressions What would a truth table look like for the expression: (A  B)  (  B  C) Tue 9/11/12CMSC Just Bits 9 ABC A  B BB  B  C(A  B)  (  B  C)

Boolean Expressions What would a truth table look like for the expression: (A  B)  (  B  C) Tue 9/11/12CMSC Just Bits 10 ABC A  B BB  B  C(A  B)  (  B  C)

(Boolean) Algebraic Laws DeMorgan’s Theorem Analogous to the distributive law in regular algebra  (A  B) =  A   B  (A  B) =  A   B Tue 9/11/12CMSC Just Bits 11 AB A  B  (A  B) AA BB  A   B FFFTTTT FTFTTFT TFFTFTT TTTFFFF

Logic Gates, Circuits, and Memory Tue 9/11/12CMSC Just Bits 12

Storing Bits How are these “bits” stored in the computer? A bit is just an electrical signal or voltage (by convention: “low voltage” = 0; “high voltage” = 1) A circuit called a “flip-flop” can store a single bit A flip-flop can be “set” (using an electrical signal) to either 0 or 1 The flip-flop will hold that value until it receives a new signal telling it to change Bits can be operated on using gates (which “compute” a function of two or more bits) Tue 9/11/12CMSC Just Bits 13

Logic Gates In hardware, Boolean operations are implemented using circuits called logic gates Tue 9/11/12CMSC Just Bits 14 XOR: Exclusive or (one input is TRUE, but not both)

Logic Circuits We can implement any logical expression just by assembling the associated logical gates in the right order What would a logic circuit look like for the expression: (A  B)  (  B  C) Tue 9/11/12CMSC Just Bits 15

Storing Information One bit can’t tell you much… (just 2 possible values) Usually we group 8 bits together into one “byte” QUESTION:How many possible values (combinations) are there for one byte? A byte can just be thought of as an 8-digit binary (base 2) number Michael Littman's octupus counting video Low-order or least significant bit == ones place Next bit would be “10s place” in base what about base 2? High-order bit or most significant bite in a byte == ?? place Tue 9/11/12CMSC Just Bits 16

Orders of Magnitude One 0/1 (“no/yes”) “bit” is the basic unit of memory Eight (2 3 ) bits = one byte 1,024 (2 10 ) bytes = one kilobyte (1K) * 1,024K = 1,048,576 (2 20 bytes) = one megabyte (1M) 1,024K (2 30 bytes) = one gigabyte (1G) 1,024 (2 40 bytes) = one terabyte (1T) 1,024 (2 50 bytes) = one petabyte (1P) bytes = one yottabyte (1Y?) Tue 9/11/12CMSC Just Bits 17

Scaling Up Memory Computer chip: Many (millions) of circuits Etched onto a silicon wafer using VLSI (Very Large-Scale Integration) technology Lots of flip-flops or DRAM devices == memory chip Each byte has an address (and we use binary numbers to represent those addresses…) An address is represented using a word, which is typically either; 2 bytes (16 bits) -- earliest PCs Only 64K combinations  memory is limited to 64K (65,535) bytes! 4 bytes (32 bits) -- first Pentium chips This brings us up to 4G (4,294,967,295) bytes of memory! 8 bytes (64 bits) -- modern Pentium chips Up to 16.8 million terabytes (that’s 18,446,744,073,709,551,615 bytes!) Tue 9/11/12CMSC Just Bits 18

Binary and Hexadecimal Numbers Tue 9/11/12CMSC Just Bits 19

Binary Numbers A binary (base-two) number is just like a decimal (base-ten) number, except that instead of ten possible digits (0...9), we only have two (0...1) Tue 9/11/12CMSC Just Bits 20 tens place ones place tens place ones placehundreds place twos place ones placefours place QUESTION: What place value does this zero hold?

Conversions Binary  decimal: multiply each digit by its place value and add results Decimal  binary: Find the largest power of two that is less than or equal to the decimal number Put a one in that place column in the binary number Add spaces for the smaller binary digits E.g., if the largest multiple of two that fits is 256, you would write: 1 __ __ __ __ __ __ __ __ Find the next smallest multiple of two Put a one in that place column (and a zero in any columns you skipped) EXERCISE : You try it! Write in binary Write in decimal Tue 9/11/12CMSC Just Bits2 21

Hexadecimal It would be very inconvenient to write out a 64-bit address in binary: Instead, we group each set of 4 bits together into a hexadecimal (base 16) digit: The digits are 0, 1, 2, …, 9, A (10), B (11), …, E (14), F (15) D 6 F C D E 0 E 0 …which we write, by convention, with a “0x” preceding the number to indicate it’s a heXadecimal number: 0x29D6F89611CDE0E0 Tue 9/11/12CMSC Just Bits 22

Representing Information Positive integers: Just use the binary number system Negative integers, letters, images, … not so easy! There are many different ways to represent information Some are more efficient than others … but once we’ve solved the representation problem, we can use that information without considering how it’s represented… via Tue 9/11/12CMSC Just Bits 23

Representing Integers Simplest idea (“ones’ complement”): Use one bit for a “sign bit”: 1 means negative, 0 means positive The other bits are “complemented” (flipped) in a negative number So, for example, +23 (in a 16-bit word) is represented as: and -23 is represented as: But there are two different ways to say “zero” (0000… and 1111…) It’s tricky to do simple arithmetic operations like addition in the ones’ complement notation This is solved by the twos’ complement representation, but we won’t go over that Tue 9/11/12CMSC Just Bits 24

Floating Point Numbers Non-integers are a problem… Remember that any rational number can be represented as a fraction …but we probably don’t want to do this, since (a) we’d need to use two words for each number (i.e., the numerator and the denominator) (b) fractions are hard to manipulate (add, subtract, etc.) Irrational numbers can’t be written down at all, of course Notice that any representation we choose will by definition have limited precision, since we can only represent 2 32 different values in a 32-bit word 1/3 isn’t exactly 1/3 (let’s try it on a calculator!) In general, we also lose precision (introduce errors) when we operate on floating point numbers You don’t need to know the details of how “floating point” numbers are represented Tue 9/11/12CMSC Just Bits 25

Representing Characters ASCII representation: one byte [actually 7 bits…] == one letter == an integer from No specific reason for this assignment of letters to integers! UNICODE is a popular 16-bit representation that supports accented characters like é Tue 9/11/12CMSC Just Bits 26 [Chart borrowed from ha.ckers.org]

Summary: Main Ideas It’s all just bits Abstraction Boolean algebra TRUE/FALSE Truth tables Logic gates Representing numbers Hexadecimal representation Ones’ complement Floating point numbers (main issues) ASCII representation (main idea) Tue 9/11/12CMSC Just Bits 27

ACTIVITY (if time) Design a one-bit adder (i.e., a logic circuit that adds two 1-bit numbers together) X + Y  Z 2 Z 1 Z 2 is needed since the result may be two binary digits long First let’s figure out the Boolean expression for each output… Create the truth table Then we’ll draw the logic circuit Tue 9/11/12CMSC Just Bits 28