E40M. Binary Numbers, Codes. M. Horowitz, J. Plummer, R. Howe 1

Similar documents
E40M Useless Box, Boolean Logic. M. Horowitz, J. Plummer, R. Howe 1

E40M Useless Box, Boolean Logic. M. Horowitz, J. Plummer, R. Howe 1

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

E40M. MOS Transistors, CMOS Logic Circuits, and Cheap, Powerful Computers. M. Horowitz, J. Plummer, R. Howe 1

EE292: Fundamentals of ECE

Microcomputers. Outline. Number Systems and Digital Logic Review

Introduction to Computers and Programming. Numeric Values

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

M. Horowitz E40M Lecture 13

E40M. An Introduction to Making: What is EE?

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

E40M. Solving Circuits using Nodal Analysis and EveryCircuit TM. M. Horowitz, J. Plummer, R. Howe 1

How Do We Figure Out the Voltages and Currents?

Number System. Introduction. Decimal Numbers

COMP combinational logic 1 Jan. 18, 2016

Chapter 10 Binary Arithmetics

Chapter 2 Bits, Data Types, and Operations

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

Chapter 2 Bits, Data Types, and Operations

Software and Hardware

Chapter 2 Bits, Data Types, and Operations

World Inside a Computer is Binary

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

Variables and Data Representation

The type of all data used in a C++ program must be specified

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

D I G I T A L C I R C U I T S E E

EE 109L Review. Name: Solutions

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

The type of all data used in a C (or C++) program must be specified

Part 2,Number Systems Questions

Sense Amplifiers 6 T Cell. M PC is the precharge transistor whose purpose is to force the latch to operate at the unstable point.

Data III & Integers I

Logic, Words, and Integers

EE 109L Final Review

Inf2C - Computer Systems Lecture 2 Data Representation

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal.

COMP2611: Computer Organization. Data Representation

Binary Adders: Half Adders and Full Adders

CARLETON UNIVERSITY. Laboratory 2.0

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

CS/COE 0447 Example Problems for Exam 2 Spring 2011

THE LOGIC OF COMPOUND STATEMENTS

Chapter 4: Data Representations

The LC3's micro-coded controller ("useq") is nothing more than a finite-state machine (FSM). It has these inputs:

UNCA CSCI 255 Exam 1 Spring February, This is a closed book and closed notes exam. It is to be turned in by 1:45 PM.

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016

Chapter 3: part 3 Binary Subtraction

Data III & Integers I

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Fundamentals of Programming (C)

Systems Programming. Lecture 2 Review of Computer Architecture I

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Fundamentals of Programming

BINARY SYSTEM. Binary system is used in digital systems because it is:

LECTURE 4. Logic Design

More about Binary 9/6/2016

Chapter 2 Bits, Data Types, and Operations

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Arithmetic-logic units

Single-Strip Static CMOS Layout

Computer Organization and Levels of Abstraction

Learning the Binary System

211: Computer Architecture Summer 2016

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Chapter 4. Combinational Logic

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

Lecture 12. Building an LED Display

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Dynamic CMOS Logic Gate

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

Arithmetic Processing

1. Mark the correct statement(s)

DIGITAL ELECTRONICS. Vayu Education of India

Read-only memory Implementing logic with ROM Programmable logic devices Implementing logic with PLDs Static hazards

EE 109 Unit 6 Binary Arithmetic

Designing Information Devices and Systems II Spring 2018 J. Roychowdhury and M. Maharbiz Discussion 1A

Topic Notes: Bits and Bytes and Numbers

Recitation Session 6

Digital Fundamentals

Unit 2: Data Storage CS 101, Fall 2018

Transcription:

E40M Binary Numbers, Codes M. Horowitz, J. Plummer, R. Howe 1

Reading Chapter 5 in the reader A&L 5.6 M. Horowitz, J. Plummer, R. Howe 2

Useless Box Lab Project #2 Adding a computer to the Useless Box alows us to write a program to control the motor (and hence the box). To control the motor we need to study and use MOS transistors since our computer cannot drive the motor directly. The computer (Arduino) uses Boolean logic and CMOS logic gates to implement software we write for it. The MOS transistors amplify the Arduino output to control the motor. M. Horowitz, J. Plummer, R. Howe 3

Last Lecture: MOSFETs nmos It is a switch which connects source to drain If the gate-to-source voltage is greater than V th (around 1 V) Positive gate-to-source voltages turn the device on. pmos It is a switch which connects source to drain If the gate-to-source voltage is less than V th (around -1 V) Negative gate-to-source voltages turn the device on and there s zero current into the gate! M. Horowitz, J. Plummer, R. Howe 4

Last Lecture: MOSFET models Are very interesting devices Come in two flavors pmos and nmos Symbols and equivalent circuits shown below Gate terminal takes no current (at least no DC current) The gate voltage * controls whether the switch is ON or OFF gate R on gate pmos nmos * actually, the gate to source voltage, V GS M. Horowitz, J. Plummer, R. Howe 5

Last Lecture: Logic Gates V DD V A V Out V DD V Out V A V B M. Horowitz, J. Plummer, R. Howe 6

Logic Gates Deal With Binary Signals Wires can have only two values Binary values, 0, 1; or True and False Generally transmitted as: Vdd = 1 V; Gnd = 0 Vdd is the power supply, 1V to 5 V Gnd is the reference level, about 0V A B AND 0 0 0 0 1 0 1 0 0 1 1 1 (A && B) <-> AND So how do we represent: Numbers, letters, colors, etc.? M. Horowitz, J. Plummer, R. Howe 7

Logic Gates Deal With Binary Signals Wires can have only two values Binary values, 0, 1; or True and False Generally transmitted as: Vdd = 1; Gnd = 0 Vdd is the power supply, 1V to 5 V Gnd is the reference level, about 0V A B OR 0 0 0 0 1 1 1 0 1 1 1 1 (A B) <-> OR So how do we represent: Numbers, letters, colors, etc.? M. Horowitz, J. Plummer, R. Howe 8

Binary Numbers To represent anything other than true and false You are going to need more then one bit Group bits together to form more complex objects 8 bits are a byte, and can represent a character (ASCII) 24 bits are grouped together to represent color 8 bits for R, G, B. 16 or 32 or 64 bits are grouped together and can represent an integer M. Horowitz, J. Plummer, R. Howe 9

Binary Numbers For decimal numbers Each place is 10 n 1, 10, 100, 1000 Since there are 10 possible values of digits 10 2 10 1 10 0 1 4 5 Decimal = 145 For binary numbers Each digit is only 0, 1 (only two possible digits) The place values are then 2 n 1, 2, 4, 8, 16, It is useful to remember that 2 10 = 1024 2 2 2 1 2 0 1 0 1 Decimal = 2 2 + 2 0 = 5 M. Horowitz, J. Plummer, R. Howe 10

Binary Numbers Operation Output Remainder 23/2 7 0 23 23/2 6 0 23 23/2 5 0 23 23/2 4 1 7 23/2 3 0 7 23/2 2 1 3 23/2 1 1 1 23/2 0 1 0 23 in binary is 00010111 Carry 1 1 11 1 0 1 1 3 0 0 1 1 Addition (14) 1 1 1 0 Add by carrying 1s Subtract by borrowing 2s. See class reader M. Horowitz, J. Plummer, R. Howe 11

Binary Numbers One can think of binary numbers as a kind of code: In communications and information processing, code is a system of rules to convert information such as a letter, word, sound, image, or gesture into another form or representation, sometimes shortened or secret, for communication through a channel or storage in a medium. https://en.wikipedia.org/wiki/code M. Horowitz, J. Plummer, R. Howe 12

Many Different Types of Codes Figuring out good codes is a big part of EE Security Error correction Compression.mp3,.mp4,.jpeg,.avi, etc. Are all a code of the source.zip Whole theory of information (Information theory) guides codes Sets what is possible and not possible (Claude Shannon) M. Horowitz, J. Plummer, R. Howe 13

Binary Code Advantages Uses a small number of bits, log2(n), to represent a number Easy to generate and decode Easy to do math on this representation Disadvantages The value is in the clear (the data is not encrypted) If any bit is in error, the number is lost If you use more bits, can recover from single bit error Can only represent one number per value Let s say we would like to drive a display with 64 lights M. Horowitz, J. Plummer, R. Howe 14

How To Represent Negative Numbers? Could create sign / magnitude code Add one bit to be the sign bit 7 00000111-7 10000111 But that is not what works out best To add two numbers, you first need to look at the sign bits If they are the same, add If they are different, subtract M. Horowitz, J. Plummer, R. Howe 15

Two s Complement Numbers Positive numbers are normal binary Negative numbers are defined so when we add them to Num, a normal adder will give zero So -1 = 1111111111111111-2 = 1111111111111110 Carry 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1-3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 Addition 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 M. Horowitz, J. Plummer, R. Howe 16

Generating Two s Complement Numbers Take your number Invert all the bits of the number Make all 0 1 and all 1 0 And then add 1 to the result Lets look at an example: 42 0 0 1 0 1 0 1 0 Flip 1 and 0 1 1 0 1 0 1 0 1 Add 1 1 1 0 1 0 1 1 0 So -42 in two s complement is 11010110 M. Horowitz, J. Plummer, R. Howe 17

The Way This Works M. Horowitz, J. Plummer, R. Howe 18

Funny Things Happen With Finite Numbers Your homework looks at some problems with numbers That only have a finite number of bits Computers generally have two types of numbers Signed numbers, and unsigned numbers It interprets the MSB differently Can get interesting results if you mistake A signed number as unsigned and vice versa Also overflows have an interesting effect Can add two positive numbers and get a negative result! M. Horowitz, J. Plummer, R. Howe 19

Overflow Situations M. Horowitz, J. Plummer, R. Howe 20

ERASURE CODES M. Horowitz, J. Plummer, R. Howe 21

An Example of Other Types of EE Coding Problems You want to send data to someone But the communication link is not reliable It will sometimes drop packets But you will know which packets you got/lost Say that the link might lose up to K of N packets You have no control of which packets are lost Called erasure channels, since it erases information How much data can you communicate in N packets? How do you code the information to achieve that rate? M. Horowitz, J. Plummer, R. Howe 22

At First Life Seems Hard We need to communicate all the data reliably If we can lose any 3 packets Then if we transmit each value 3 times, we still might lose. Almost seems like we need to transmit each value 4 times Or for K erasures in N packets Can transmit < N/K pieces of information Can we do better? M. Horowitz, J. Plummer, R. Howe 23

Upper Bound I don t know how to solve this but I do know one thing Impossible to transmit more than N-K packets of information Since that is all the bits that you get at the receiver How close can we come to this upper bound? We can actually achieve it! M. Horowitz, J. Plummer, R. Howe 24

Getting Around the Problem The problem is we don t know what data will be lost To achieve the upper bound what data is lost can t matter Any (N-K) code outputs can give us our (N-K) packet values For this to be true Each packet value must be in at least K+1 code outputs But since there are much less than (K+1)(N-K) outputs Most code values must contain multiple packet values Huh? Linear algebra to the rescue! M. Horowitz, J. Plummer, R. Howe 25

Simple Example Assume we want to transmit 3 values X1, X2, X3 And the channel may drop two in 5 packets What happens if we transmit: X1 X2; X3; X1+X2+X3 X1+2*X2+3*X3 Can we solve for X1, X2, X3 with any 3 packets? M. Horowitz, J. Plummer, R. Howe 26

Linear Algebra Formulation To solve for M = N-K variables How many linear equations are needed? If we create N independent linear combinations of M values It doesn t matter which M equations we have We have enough information to solve for the variables! Generally written in matrix notation Y = A X, where A is a NxM matrix X = A* -1 Y*, where the * means the values you received M. Horowitz, J. Plummer, R. Howe 27

Time Multiplexing In the LED cube we will have 64 LEDs but they are wired so we can access rows and columns of the matrix. We ll explore a different type of coding later that will allow us to control each LED individually, even though we do not have a separate connection to each of them! M. Horowitz, J. Plummer, R. Howe 28

Learning Objectives Understand how binary numbers work And be able to convert from decimal to binary numbers Understand what Electrical Engineers mean by a code It is a set of rules to represent information How to use two s complement codes To represent positive and negative numbers And what happens when an overflow occurs Understand how erasure codes allow you to recover your message even when some packets are dropped M. Horowitz, J. Plummer, R. Howe 29