Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Representation and Gates These slides are taken from your textbook Dale & Lewis.

Similar presentations


Presentation on theme: "Data Representation and Gates These slides are taken from your textbook Dale & Lewis."— Presentation transcript:

1 Data Representation and Gates These slides are taken from your textbook Dale & Lewis

2 2 Data and Computers Computers store, present, and help us modify Numbers Text Audio Images and graphics Video

3 3 Data and Computers Data compression Reduction in the amount of space needed to store a piece of data Compression ratio The size of the compressed data divided by the size of the original data A data compression techniques can be lossless, which means the data can be retrieved without any loss of the original information lossy, which means some information may be lost in the process of compaction

4 4 Analog and Digital Information Information can be represented in one of two ways: analog or digital Analog data A continuous representation, analogous to the actual information it represents Digital data A discrete representation, breaking the information up into separate elements Analog and Digital Information

5 5 Computers cannot work well with analog data, so we digitize the data Digitize Breaking data into pieces and representing those pieces separately

6 6 Electronic Signals Important facts about electronic signals An analog signal continually fluctuates in voltage up and down A digital signal has only a high or low state, corresponding to the two binary digits

7 7 Electronic Signals (Cont’d) Figure 3.2 An analog and a digital signal Figure 3.3 Degradation of analog and digital signals

8 8 Binary Representations Counting with binary bits Figure 3.4

9 9 Representing Negative Values Signed-magnitude number representation The sign represents the ordering, and the digits represent the magnitude of the number

10 Signed binary signed-magnitude The most significant bit (MSB) is set aside to indicate the sign, zero for positive and 1 for negative. One’s-complement The MSB of a negative number will begin with a one and a positive number with a zero. 0011 will represent +3 and 1100 (complement of the positive 3) will represent -3. Two’s-complement. a negative number is represented by complementing the bits of the positive number and adding a 1. a –3 is represented as 1101 (complement of 0011 is 1100, and add a 1).

11 Two’s complement a binary number’s MSB is a zero then it is a positive and no further action is necessary. If the MSB is 1, it is a negative number. Suppose the number is 10000001, we know it is a negative number. Complement the bits and add a 1, we get 01111110 +1 = 01111111 which is 127. The sign is already determined to be negative it is –127.

12 12 Number Overflow What happen if the computed value won't fit? Overflow If each value is stored using eight bits, adding 127 to 3 overflows 1111111 + 0000011 10000010 Problems occur when mapping an infinite world onto a finite machine!

13 13 Representing Text What must be provided to represent text? There are finite number of characters to represent, so list them all and assign each a binary string Character set A list of characters and the codes used to represent each one Computer manufacturers agreed to standardize

14 14 The ASCII Character Set ASCII stands for American Standard Code for Information Interchange ASCII originally used seven bits to represent each character, allowing for 128 unique characters Later extended ASCII evolved so that all eight bits were used How many characters could be represented?

15 15 ASCII Character Set Mapping

16 16 The ASCII Character Set The first 32 characters in the ASCII character chart do not have a simple character representation to print to the screen What do you think they are used for?

17 17 The Unicode Character Set Extended ASCII is not enough for international use One Unicode mapping uses 16 bits per character How many characters can this mapping represent? Unicode is a superset of ASCII The first 256 characters correspond exactly to the extended ASCII character set

18 18 The Unicode Character Set Figure 3.6 A few characters in the Unicode character set

19 19 Text Compression Assigning 16 bits to each character in a document uses too much file space We need ways to store and transmit text efficiently Text compression techniques keyword encoding run-length encoding Huffman encoding

20 20 Keyword Encoding Replace frequently used words with a single character

21 21 Keyword Encoding Given the following paragraph, We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. ム That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, ム That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness.

22 22 Keyword Encoding The encoded paragraph is We hold # truths to be self-evident, $ all men are created equal, $ ~y are endowed by ~ir Creator with certain unalienable Rights, $ among # are Life, Liberty + ~ pursuit of Happiness. — $ to secure # rights, Governments are instituted among Men, deriving ~ir just powers from ~ consent of ~ governed, — $ whenever any Form of Government becomes destructive of # ends, it is ~ Right of ~ People to alter or to abolish it, + to institute new Government, laying its foundation on such principles + organizing its powers in such form, ^ to ~m shall seem most likely to effect ~ir Safety + Happiness.

23 23 Keyword Encoding What did we save? Original paragraph 656 characters Encoded paragraph 596 characters Characters saved 60 characters Compression ratio 596/656 = 0.9085 Could we use this substitution chart for all text?

24 24 Run-Length Encoding A single character may be repeated over and over again in a long sequence Replace a repeated sequence with –a flag character –repeated character –number of repetitions *n8 –* is the flag character –n is the repeated character –8 is the number of times n is repeated

25 25 Run-Length Encoding Original text bbbbbbbbjjjkllqqqqqq+++++ Encoded text *b8jjjkll*q6*+5 (Why isn't l encoded? J?) The compression ratio is 15/25 or.6 Encoded text *x4*p4l*k7 Original text xxxxpppplkkkkkkk This type of repetition doesn’t occur in English text; can you think of a situation where it might occur?

26 26 Huffman Encoding Why should the character “X" and "z" take up the same number of bits as "e" or " "? Huffman codes use variable-length bit strings to represent each character More frequently used letters have shorter strings to represent them

27 27 Huffman Encoding ballboard would be 1010001001001010110001111011 compression ratio 28/56 Encode roadbed

28 28 Representing Audio Information We perceive sound when a series of air compressions vibrate a membrane in our ear, which sends signals to our brain

29 29 Representing Audio Information A stereo sends an electrical signal to a speaker to produce sound This signal is an analog representation of the sound wave The voltage in the signal varies in direct proportion to the sound wave

30 30 Representing Audio Information Digitize the signal by sampling –periodically measure the voltage –record the numeric value How often should we sample? A sampling rate of about 40,000 times per second is enough to create a reasonable sound reproduction

31 31 Representing Audio Information Figure 3.8 Sampling an audio signal Some data is lost, but a reasonable sound is reproduced

32 32 Representing Audio Information CDs store audio information digitally On the surface of the CD are microscopic pits that represent binary digits A low intensity laser is pointed as the disc The laser light reflects strongly if the surface is smooth and poorly if the surface is pitted

33 33 Representing Audio Information Figure 3.9 A CD player reading binary information

34 34 Audio Formats –WAV, AU, AIFF, VQF, and MP3 MP3 (MPEG-2, audio layer 3 file) is dominant –analyzes the frequency spread and discards information that can’t be heard by humans –bit stream is compressed using a form of Huffman encoding to achieve additional compression Is this a lossy or lossless compression (or both)?

35 35 Representing Images and Graphics Color Perception of the frequencies of light that reach the retinas of our eyes Retinas have three types of color photoreceptor cone cells that correspond to the colors of red, green, and blue

36 36 Representing Images and Graphics Color is expressed as an RGB (red-green- blue) value--three numbers that indicate the relative contribution of each of these three primary colors An RGB value of (255, 255, 0) maximizes the contribution of red and green, and minimizes the contribution of blue, which results in a bright yellow

37 37 Representing Images and Graphics Figure 3.10 Three-dimensional color space

38 38 Digitized Images and Graphics Digitizing a picture Representing it as a collection of individual dots called pixels Resolution The number of pixels used to represent a picture Raster Graphics Storage of data on a pixel-by-pixel basis Bitmap (BMP), GIF, JPEG, and PNG are raster- grahics formats

39 39 Digitized Images and Graphics Bitmap format Contains the pixel color values of the image from left to right and from top to bottom GIF format (indexed color) Each image is made up of only 256 colors JPEG format Averages color hues over short distances PNG format Like GIF but achieves greater compression with wider range of color depths Which is better for line drawings? Pictures?

40 40 Digitized Images and Graphics Figure 3.12 A digitized picture composed of many individual pixels Whole picture

41 41 Digitized Images and Graphics Figure 3.12 A digitized picture composed of many individual pixels Magnified portion of the picture See the pixels?

42 42 Representing Video Video codec COmpressor/DECompressor Methods used to shrink the size of a movie to allow it to be played on a computer or over a network Almost all video codecs use lossy compressions to minimize the huge amounts of data associated with video

43 43 Representing Video Temporal compression A technique based on differences between consecutive frames: If most of an image in two frames hasn’t changed, why should we waste space to duplicate all of the similar information? Spatial compression A technique based on removing redundant information within a frame: This problem is essentially the same as that faced when compressing still images

44 Computers and Electricity Gate A device that performs a basic operation on electrical signals Circuits Gates combined to perform more complicated tasks

45 Computers and Electricity How do we describe the behavior of gates and circuits? Boolean expressions Uses Boolean algebra, a mathematical notation for expressing two-valued logic Logic diagrams A graphical representation of a circuit; each gate has its own symbol Truth tables A table showing all possible input value and the associated output values

46 Gates Six types of gates –NOT –AND –OR –XOR –NAND –NOR Typically, logic diagrams are black and white with gates distinguished only by their shape We use color for emphasis (and fun)

47 NOT Gate A NOT gate accepts one input signal (0 or 1) and returns the opposite signal as output Figure 4.1 Various representations of a NOT gate

48 AND Gate An AND gate accepts two input signals If both are 1, the output is 1; otherwise, the output is 0 Figure 4.2 Various representations of an AND gate

49 OR Gate An OR gate accepts two input signals If both are 0, the output is 0; otherwise, the output is 1 Figure 4.3 Various representations of a OR gate

50 XOR Gate Figure 4.4 Various representations of an XOR gate An XOR gate accepts two input signals If both are the same, the output is 0; otherwise, the output is 1

51 XOR Gate Note the difference between the XOR gate and the OR gate; they differ only in one input situation When both input signals are 1, the OR gate produces a 1 and the XOR produces a 0 XOR is called the exclusive OR

52 NAND Gate The NAND gate accepts two input signals If both are 1, the output is 0; otherwise, the output is 1 Figure 4.5 Various representations of a NAND gate

53 NOR Gate Figure 4.6 Various representations of a NOR gate The NOR gate accepts two input signals If both are 0, the output is 1; otherwise, the output is 0

54 Review of Gate Processing A NOT gate inverts its single input An AND gate produces 1 if both input values are 1 An OR gate produces 0 if both input values are 0 An XOR gate produces 0 if input values are the same A NAND gate produces 0 if both inputs are 1 A NOR gate produces a 1 if both inputs are 0

55 Gates with More Inputs Gates can be designed to accept three or more input values A three-input AND gate, for example, produces an output of 1 only if all input values are 1 Figure 4.7 Various representations of a three-input AND gate

56 Constructing Gates Transistor A device that acts either as a wire that conducts electricity or as a resistor that blocks the flow of electricity, depending on the voltage level of an input signal A transistor has no moving parts, yet acts like a switch It is made of a semiconductor material, which is neither a particularly good conductor of electricity nor a particularly good insulator

57 Constructing Gates A transistor has three terminals –A source –A base –An emitter, typically connected to a ground wire If the electrical signal is grounded, it is allowed to flow through an alternative route to the ground (literally) where it can do no harm Figure 4.8 The connections of a transistor

58 Constructing Gates The easiest gates to create are the NOT, NAND, and NOR gates Figure 4.9 Constructing gates using transistors

59 Circuits Combinational circuit The input values explicitly determine the output Sequential circuit The output is a function of the input values and the existing state of the circuit We describe the circuit operations using Boolean expressions Logic diagrams Truth tables Are you surprised?

60 Combinational Circuits Gates are combined into circuits by using the output of one gate as the input for another

61 Combinational Circuits Three inputs require eight rows to describe all possible input combinations This same circuit using a Boolean expression is (AB + AC)

62 Combinational Circuits Consider the following Boolean expression A(B + C) Does this truth table look familiar? Compare it with previous table

63 Combinational Circuits Circuit equivalence Two circuits that produce the same output for identical input Boolean algebra allows us to apply provable mathematical principles to help design circuits A(B + C) = AB + BC (distributive law) so circuits must be equivalent

64 Properties of Boolean Algebra

65 Adders At the digital logic level, addition is performed in binary Addition operations are carried out by special circuits called, appropriately, adders

66 Adders The result of adding two binary digits could produce a carry value Recall that 1 + 1 = 10 in base two Half adder A circuit that computes the sum of two bits and produces the correct carry bit Truth table

67 Half Adder #include void main() { short x,y, sum, carry; bool a,b,c,d; cout > x>>y; a=x==1; b=y==1; //actually c++ assigns 0 for false and 1 for true, we could have read these directly; c=(a||b) && !(a&&b); d=(a&&b); 9 sum=c?1:0; //if c is true then sum gets 1 else sum gets 0 carry=d?1:0; cout <<x <<"+"<<y <<"="<<carry<<sum<<endl; if (a = true) cout <<"it is true"; if (a) cout << "it is ture"; }

68 Adders Circuit diagram representing a half adder Boolean expressions sum = A  B carry = AB

69 Adders Full adder A circuit that takes the carry-in value into account Figure 4.10 A full adder

70 Multiplexers Multiplexer A circuit that uses a few input control signals to determine which of several output data lines is routed to its output

71 Multiplexers The control lines S0, S1, and S2 determine which of eight other input lines (D0 … D7) are routed to the output (F) Figure 4.11 A block diagram of a multiplexer with three select control lines

72 Circuits as Memory Digital circuits can be used to store information These circuits form a sequential circuit, because the output of the circuit is also used as input to the circuit

73 Circuits as Memory An S-R latch stores a single binary digit (1 or 0) There are several ways an S-R latch circuit can be designed using various kinds of gates Figure 4.12 An S-R latch

74 Circuits as Memory The design of this circuit guarantees that the two outputs X and Y are always complements of each other The value of X at any point in time is considered to be the current state of the circuit Therefore, if X is 1, the circuit is storing a 1; if X is 0, the circuit is storing a 0 Figure 4.12 An S-R latch

75 Integrated Circuits Integrated circuit (also called a chip) A piece of silicon on which multiple gates have been embedded Silicon pieces are mounted on a plastic or ceramic package with pins along the edges that can be soldered onto circuit boards or inserted into appropriate sockets

76 Integrated Circuits Integrated circuits (IC) are classified by the number of gates contained in them

77 Integrated Circuits Figure 4.13 An SSI chip contains independent NAND gates

78 CPU Chips The most important integrated circuit in any computer is the Central Processing Unit, or CPU Each CPU chip has a large number of pins through which essentially all communication in a computer system occurs

79 University of Texas Pan Am Dr. John P. Abraham Computer Programming Languages Computers perform operations such as moving data and data manipulation by activating switches and gates. Instructions to do that also must be given in the form of 1s and 0s or on and off. When we program computers using just ones and zeros we are using the “machine language”. When a program is written using human readable code line for line of machine code, that language is called Assembly language. Human readable code is called Mnemonics. When a programmer can use mathematical symbols and familiar English words such as write (a+b) that language is called a High Level language. Each of the program line will be converted to several lines of assembly or machine code. More about it later


Download ppt "Data Representation and Gates These slides are taken from your textbook Dale & Lewis."

Similar presentations


Ads by Google