David Kauchak CS 52 – Spring 2016

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall Hardware Basics: Inside The Box Chapter 2.
Advertisements

ENGR2216 FORTRAN PROGRAMMING FOR ENGINEERS. Chapter 1 The computer CPU MEMORY INPUT/OUTPUT DEVICES DATA REPRESENTATION BINARY SYSTEM OCTAL & HEXADECIMAL.
 The central processing unit (CPU) interprets and executes instructions.  The “brains” of the computer.  The speed of the processor is how fast it.
Chapter 2 Machine Language. Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Aug CMSC 104, LECT-021 Machine Architecture and Number Systems Some material in this presentation is borrowed form Adrian Ilie From The UNIVERSITY.
Number Representations and Computer Arithmetic. CS 21a 9/23/02 Odds and Ends Slide 2 © Luis F. G. Sarmenta and John Paul Vergara, Ateneo de Manila University.
1 Machine Architecture and Number Systems Topics Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting.
CS 111 – Aug – 1.3 –Information arranged in memory –Types of memory –Disk properties Commitment for next day: –Read pp , In other.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Lecture 2 “Structure of computer” Informatics. Computer is  general purpose device that can be programmed to carry out a set of arithmetic or logical.
Introduction to Computers
Copyright © 2003 by Prentice Hall Module 5 Central Processing Unit 1. Binary representation of data 2. The components of the CPU 3. CPU and Instruction.
Machine Architecture CMSC 104, Section 4 Richard Chang 1.
The Central Processing Unit: What Goes on Inside the Computer
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Midterm Thursday  Review question sessions tonight and Wednesday  Assignment 3?  Assignment.
Inside your computer. Hardware Review Motherboard Processor / CPU Bus Bios chip Memory Hard drive Video Card Sound Card Monitor/printer Ports.
Inside your computer. Hardware Motherboard Processor / CPU Bus Bios chip Memory Hard drive Video Card Sound Card Monitor/printer Ports.
Introduction to Computer Architecture. What is binary? We use the decimal (base 10) number system Binary is the base 2 number system Ten different numbers.
Computer Guts and Operating Systems CSCI 101 Week Two.
1 3 Computing System Fundamentals 3.2 Computer Architecture.
CSC 110 – Intro to Computing Lecture 8: Computing Components.
IT Groundwork ICS3UC - Unit 1 Hardware. Overview of Computer System.
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Assignment 3  due Monday at 11:59pm  one small error in 5b (fast division) that’s been fixed.
Bits and Bytes IGCSE. A binary number is either a 0 or a 1 and is known as a 'bit' or b inary dig it. However, the CPU cannot deal with just one bit at.
DIGITAL CIRCUITS David Kauchak CS52 – Fall 2015.
Introduction to Computer Architecture. What is binary? We use the decimal (base 10) number system Binary is the base 2 number system Ten different numbers.
Computer Science Binary. Binary Code Remember the power supply that is inside your computer and how it sends electricity to all of the components? That.
Computer Architecture Memory, Math and Logic. Basic Building Blocks Seen: – Memory – Logic & Math.
Data Representation Bits, Bytes, Binary, Hexadecimal.
How We Measure Memory. Learning Goal Today we are going to learn how the computer stores information.
COMPUTER MEMORY & DATA STORAGE. ROM ROM is short for Read Only Memory. –I–It is permanent, long-term memory which cannot be erased or changed in any way;
Computers - The Journey Inside continues…
Thursday 8 th October, 2015 Information Technology Fundamentals of Hardware & Software.
How We Measure Memory. At the Bottom of things A piece of digital information is always stored as a sequence of binary states. What’s that mean you ask???
The Computer System CS 103: Computers and Application Software.
CS 125 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk drive Software.
Memory The term memory is referred to computer’s main memory, or RAM (Random Access Memory). RAM is the location where data and programs are stored (temporarily),
Numerical Representation Intro to Computer Science CS1510 Dr. Sarah Diesburg 1.
Binary & Hex Review.
Basic Computer Fundamentals
Computer Architecture and Number Systems
Design of Digital Circuits Reading: Binary Numbers
David Kauchak CS 52 – Spring 2017
The Study of Computer Science Chapter 0
David Kauchak CS 52 – Spring 2017
Hardware specifications
How do Computers Work ?.
Assembly Language (CSW 353)
3.1 Denary, Binary and Hexadecimal Number Systems
Introduction to Computer Architecture
The Study of Computer Science Chapter 0
CS41B recursion David Kauchak CS 52 – Fall 2015.
Computer Architecture
COMPUTER MEMORY & DATA STORAGE
Machine Architecture and Number Systems
COMPUTER MEMORY & DATA STORAGE
PRIMARY STORAGE.
Data Representation Numbers
The Study of Computer Science
Numerical Representation
Chapter One: Introduction
Introduction to Programming Part 2
Computer Organization
The Study of Computer Science
Information Technology Department
Comp Org & Assembly Lang
Binary & Hex Review.
AS Level ICT Selection and use of storage requirements, media, and devices: storage and storage capacity Unit 1 Topic a - Selection and use of storage.
The Study of Computer Science Chapter 0
Presentation transcript:

David Kauchak CS 52 – Spring 2016 CS41B machine David Kauchak CS 52 – Spring 2016

Admin Assignment 3 due Monday at 11:59pm Academic honesty

Admin Midterm next Thursday in-class (2/18) Comprehensive  Closed books, notes, computers, etc. Except, may bring up to 2 pages of notes Practice problems posted Also some practice problems in the Intro SML reading Midterm review sessions (will announce on piazza soon)

Midterm topics SML recursion math

Midterm topics Basic syntax SML built-in types Defining function pattern matching Function type signatures Recursion! map exceptions Defining datatypes addition, subtraction, multiplication manually and on list digits Numbers in different bases Binary number representation (first part of today’s lecture) NOT CS41B material

Binary number revisited What number does 1001 represent in binary? Depends! Is it a signed number or unsigned? If signed, what convention are we using?

Twos complement For a number with n digits high order bit represents -2n-1 unsigned 23 22 21 20 signed (twos complement) -23 22 21 20

Twos complement 9 -7 What number is it? 1 1 1 1 unsigned 23 22 21 20 1 unsigned 9 23 22 21 20 1 1 signed (twos complement) -7 -23 22 21 20

Twos complement 15 -1 What number is it? 1 1 1 1 1 1 1 1 unsigned 23 22 21 20 1 1 1 1 signed (twos complement) -1 -23 22 21 20

Twos complement 12 -4 What number is it? 1 1 1 1 unsigned 23 22 21 20 unsigned 12 23 22 21 20 1 1 signed (twos complement) -4 -23 22 21 20

Twos complement How many numbers can we represent with each approach using 4 bits? 16 (24) numbers, 0000, 0001, …., 1111 Doesn’t matter the representation! unsigned 23 22 21 20 signed (twos complement) -23 22 21 20

Twos complement How many numbers can we represent with each approach using 32 bits? 232 ≈ 4 billion numbers unsigned 23 22 21 20 signed (twos complement) -23 22 21 20

Twos complement What is the range of numbers we can represent for each approach with 4 bits? unsigned: 0, 1, … 15 signed: -8, -7, …, 7 unsigned 23 22 21 20 signed (twos complement) -23 22 21 20

binary representation unsigned 0000 0001 1 0010 ? 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

binary representation unsigned twos complement 0000 ? 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 10 1011 11 1100 12 1101 13 1110 14 1111 15

binary representation unsigned twos complement 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 ? 1001 9 1010 10 1011 11 1100 12 1101 13 1110 14 1111 15

binary representation unsigned twos complement 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 -8 1001 9 ? 1010 10 1011 11 1100 12 1101 13 1110 14 1111 15

binary representation unsigned twos complement 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 -8 1001 9 -7 1010 10 -6 1011 11 -5 1100 12 -4 1101 13 -3 1110 14 -2 1111 15 -1

binary representation unsigned twos complement 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 -8 1001 9 -7 1010 10 -6 1011 11 -5 1100 12 -4 1101 13 -3 1110 14 -2 1111 15 -1 How can you tell if a number is negative?

binary representation unsigned twos complement 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 -8 1001 9 -7 1010 10 -6 1011 11 -5 1100 12 -4 1101 13 -3 1110 14 -2 1111 15 -1 High order bit!

A two’s complement trick You can also calculate the value of a negative number represented as twos complement as follows: Flip all of the bits (0  1 and 1 0) Add 1 Resulting number is the magnitude of the original negative number flip the bits add 1 1101 0010 0011 -3

A two’s complement trick You can also calculate the value of a negative number represented as twos complement as follows: Flip all of the bits (0  1 and 1 0) Add 1 Resulting number is the magnitude of the original negative number flip the bits add 1 1110 0001 0010 -2

Addition with twos complement numbers 0001 0101 + ?

Addition with twos complement numbers 1 0001 0101 + 0110

Addition with twos complement numbers 0110 0101 + ?

Addition with twos complement numbers 1 0110 0101 + 1011?

Addition with twos complement numbers 1 0110 0101 6 + 5 1011? 11 Overflow! We cannot represent this number (it’s too large)

Addition with twos complement numbers 0110 1101 + ?

Addition with twos complement numbers 1 1 0110 1101 + 0011

Addition with twos complement numbers 1 1 0110 1101 6 ignore the last carry + -3 0011 3

Subtraction Ideas?

Subtraction Negate the 2nd number (flip the bits and add 1) Add them!

Hexadecimal numbers Hexadecimal = base 16 What will be the digits?

Hexadecimal numbers Hexadecimal = base 16 What number is 1ad? Digits 1 1 2 … 9 a (10) b (11) c (12) d (13) e (14) f (15) What number is 1ad?

Hexadecimal numbers a d = 256+10*16+13= = 429 Hexadecimal = base 16 Digits 1 2 … 9 a (10) b (11) c (12) d (13) e (14) f (15) a d = 256+10*16+13= = 429 162 161 160

Hexadecimal numbers Hexadecimal = base 16 Hexadecimal is common in CS. Digits 1 2 … 9 a (10) b (11) c (12) d (13) e (14) f (15) Hexadecimal is common in CS. Why?

Hexadecimal numbers Hexadecimal = base 16 Hexadecimal is common in CS. Digits 1 2 … 9 a (10) b (11) c (12) d (13) e (14) f (15) Hexadecimal is common in CS. 4 bits = 1 hexadecimal digit What is the following number in hex? 0110 1101 0101 0001

Hexadecimal numbers Hexadecimal = base 16 Hexadecimal is common in CS. Digits 1 2 … 9 a (10) b (11) c (12) d (13) e (14) f (15) Hexadecimal is common in CS. 4 bits = 1 hexadecimal digit What is the following number in hex? 0110 1101 0101 0001 6 d 5 1

Computer internals

Computer internals simplified CPU RAM What does it stand for? What does it do? What does it stand for? What does it do?

Computer internals simplified CPU RAM (Central Processing Unit, aka “the processor”) (Random Access Memory, aka “memory” or “main memory”) Does all the work! Temporary storage

Computer internals simplified “the computer” hard drive CPU RAM Why do we need a hard drive?

Computer internals simplified “the computer” hard drive CPU RAM Persistent memory RAM only stores data while it has power

Computer simplified CPU RAM “the computer” hard drive network media drive input devices display

Inside the CPU CPU processor: does the work registers: local, fast memory slots … registers Why all these levels of memory?

Memory speed operation access time times slower than register access for comparison… register 0.3 ns 1 1 s RAM 120 ns 400 6 min Hard disk 1ms ~million 1 month google.com 0.4s ~billion 30 years

Memory RAM 010101111000101000010010 … What is a byte? ?

Memory RAM 01010111 10001010 00010010 … byte = 8 bits byte is abbreviated as B My laptop has 16GB (gigabytes) of memory. How many bits is that?

Memory sizes bits byte 8 kilobyte (KB) 2^10 bytes = ~8,000 megabyte (MB) 2^20 =~ 8 million gigabyte (GB) 2^30 = ~8 billion My laptop has 16GB (gigabytes) of memory. How many bits is that?

Memory sizes ~128 billion bits! bits byte 8 kilobyte (KB) 2^10 bytes = ~8,000 megabyte (MB) 2^20 =~ 8 million gigabyte (GB) 2^30 = ~8 billion ~128 billion bits!

Memory RAM Memory is byte addressable 1 2 3 … 01010111 10001010 1 2 3 … 01010111 10001010 00010010 01011010 … RAM Memory is byte addressable

Memory address 1 2 3 … 01010111 10001010 00010010 01011010 … RAM Memory is organized into “words”, which is the most common functional unit

Memory address 32-bit words 4 8 ... 10101011 10001010 00010010 01011010 11001011 00001110 01010010 01010110 10111011 10010010 00000000 01110100 … RAM Most modern computers use 32-bit (4 byte) or 64-bit (8 byte) words

Memory in the CS41B Machine address 16-bit words 2 4 ... 10101011 10001010 00010010 01011010 11001011 00001110 … RAM We’ll use 16-bit words for our model (the CS41B machine)

CS41B machine CPU instruction counter (location in memory of the next instruction in memory) processor ic r0 holds the value 0 (read only) r1 general purpose read/write r2 registers r3

CS41B instructions CPU processor What types of operations might we want to do (think really basic)? registers

operation name (always three characters)

operation arguments R = register (e.g. r0) S = signed number (byte)

operation function dest = first register src0 = second register src1 = third register arg = number/argument

add r1 r2 r3 What does this do?

add r1 r2 r3 r1 = r2 + r3 Add contents of registers r2 and r3 and store the result in r1

adc r2 r1 10 What does this do?

adc r2 r1 10 r2 = r1 + 10 Add 10 to the contents of register r1 and store in r2

adc r1 r0 8 neg r2 r1 sub r2 r1 r2 What number is in r2?

adc r1 r0 8 neg r2 r1 sub r2 r1 r2 r1 = 8 r2 = -8, r1 = 8 r2 = 16