Low Level Systems Notes Software Design & Development: Low Level operations and computer...

64
Low Level Systems Notes Software Design & Development: Low Level operations and computer architecture

Transcript of Low Level Systems Notes Software Design & Development: Low Level operations and computer...

Computer Hardware

ContentsData Representation - IntegersQuestionsData Representation - Real NumbersQuestionsData Representation - TextQuestionsData Representation - GraphicsQuestionsData Representation - Sound & VideoQuestionsComputer ArchitectureQuestionsThe Fetch Execute Cycle & Architecture TrendsQuestions

Contents page with links to lesson topics2Data Representation - IntegersComputers can only use the numbers 1 and 0. Information in a computer is stored in groups of 1s and 0s called binary.

A single 1 or 0 in a computer is called a binary digit or bit.

As a single 1 or 0 by itself can only represent two states, bits are collected together into groups of eight. Eight bits make up a byte.

All information on a computer is stored as bytes or groups ofbytes

Memory locations on a computer store multiple bytes eachQuestions Data Representation - IntegersAnswer questions in full sentences!Why do computers use binary instead of decimalConvert the following numbers from unsigned binary to decimal0001 11010101 00111110 0110Convert the following numbers from decimal to unsigned binary3079234What disadvantage does unsigned representation haveWhy is using a signed bit an unsuitable method for representing negative numbers on a computerWhat isThe maximum value representable with twos complement using a byteThe minimum value representable with twos complement using two bytes11Why use binary?Representing information as binary on a computer holds a number of advantagesValue stored is unlikely to be affected by signal noise

Simpler rules for operations than decimalEasier to represent on physical storage surfaces

NotionalActualError MarginsUnsigned IntegersRecall:You can convert between binary and decimal numbers using conversion grids. In binary, the place numbers go up by a factor of 2 each time rather than by 10 in decimal

To convert binary to decimal:Write out the conversion gridAdd up all the place values with a one

128 64 32 16 8 4 2 1

0 0 1 0 1 1 0 1

32 + 8 + 4 + 1 = 45

To convert decimal to binaryWrite out the conversion gridFind the leftmost place value that is less than the number you are convertingWrite in a 1 and subtract the place value from the number you are convertingRepeat until you are left with zero

128 64 32 16 8 4 2 1

1 1 0 0 1 1

51 32 = 19 19 16 = 33 2 = 11 1 = 0

Range of valuesWe can store a range of numbers using unsigned binary. Using 1 byte:

We can store a total of 256 numbers ranging from 0 to 255. However, we could not store negative numbers using this methodIn BinaryIn DecimalMin number0000 00000Max number1111 1111255Signed Bit NotationSigned bit notation is a method of representing negative numbers in binary. The most significant bit is used to represent a plus or minus sign

+ / - 64 32 16 8 4 2 1

Using a signed bit results in having two values for zero: +0 and -0. This is inefficient, and can cause some problems when carrying out calculations.

In practice, signed bit notations are not used by computers

Questions GraphicsAnswer questions in full sentences!Describe how computers represent bitmap graphicsDescribe how computers represent vector graphicsWhich type of graphic would you use to store the following types of picture. Explain your answer:A crowd of peopleA flow chart diagramCompare bitmap and vector graphics for the following operations:RotationScalingCalculate the storage requirements of the following bitmaps:4096 by 3000 pixels 8 bit bitmap image2400 by 160 pixels 3 byte bitmap image500 by 700 pixels 256 colour image6 by 3 inches at 300 dpi true colour image

35Data Representation Sound & VideoSound is an example of analogue information a soundwave can have any frequency and amplitude

Representing analogue information presents a challenge for computers, as they store information digitally. They can only store discreet values, not any of the values between each discreet value.

To represent sound on a computer, a process called sampling is used. The computer records samples of a sound every so often, approximating the value sampled to something the computer can store.

Questions Sound and VideoAnswer questions in full sentences!When representing sound, what is meant by:The sample rateThe bit depthExplain how reducing the bit depth of a sound file would affect the accuracy with which the sound was represented.What would happen if a sample rate of significantly less than 44kHz was used to represent a sound?Calculate the storage requirements of the following uncompressed sounds. Assume a sample rate of 44kHz in all cases:20 seconds with a bit depth of 8 bits45 seconds with a bit depth of 16 bitsA minute and a half with a bit depth of 1 byteWhen representing video, what is meant by:The resolutionThe frame rate45Computer Architecture The ProcessorThe processor of a computer is the part of the computer that executes program instructions

All processors have a clock speed, measured in gigahertz (gHz). The rate at which the processor executes instructions is related to the clock speed. A faster clock speed means instructions are executed faster.

One clock tick does not equal one instruction processed. A clock cycle will be needed for each part of the fetch-execute cycle.

Questions ArchitectureAnswer questions in full sentences!List the component parts of the CPU. Describe what they doWhy are memory addresses unique for each memory locationWhat type of memory is used for:The basic operating systemOther applicationsData used by both a) and b)Explain in detail what cache memory is and how it helps improve system performanceList and describe the buses in a computerCalculate the theoretical maximum memory of a computer withA 10 bit address bus and a 16 bit data busA 32 bit address bus and a 32 bit data busWhy do computers need interface to connect devices?List and describe the tasks carried out by an interface57The Fetch-Execute CycleComputer programs are a series of instructions. These instructions are stored in machine code.

Machine code instructions are encoded in binary. Each binary value in a machine code corresponds to something that the processor can do add numbers together or jump to another part of the program

Machine code instructions are much more limited than high level languages. It may take several machine code instructions to execute a single high level instruction

The procedure by which the processor works through machine code instructions and carries them out is called the fetch-execute cycleQuestions Fetch Execute Cycle & Architecture TrendsAnswer questions in full sentences!Describe how machine code is used to store computer instructionsDescribe the steps of the fetch execute cycleWhy do program instructions take multiple clock cycles to complete?Why is the improvement to the processing power of computers slowing down Describe an architectural refinement that can improve the speed with which programs are executedExplain why computers needed to move from 32 bit addressing to 64 bit addressingUse the internet to investigate quantum computing. Explain how it would revolutionise computer programs64AccuracyUsing 3 binary places, it is impossible to accurately represent 0.7.

In a computer, there will only be a limited number of bits to store each number. You cannot keep adding binary places till you have enough

Computers can not storefractions completely accurately.The more memory put aside to store a fraction, the more accurately it will be stored

Floating Point RepresentationThe binary fractions you have seen so far only store values between 0 and 1.

Floating point representation is a method of representing real numbers in a computer. It can store numbers in a great range by splitting them up into a mantissa and an exponent.

The mantissa is a value between 0 and 1 the most significant bit has a value of . The number of bits used in the mantissa affect how accurately the number is store more bits equals more accurate.

The mantissa is multiplied by 2 raised to the power of the exponent. This means that the floating point number can store values in a far greater range than the mantissa itself. The exponent affects the range of values that can be stored more bits equals a bigger range of numbers.

Twos complement can be used with both the mantissa and exponent, allowing negative values for each

.10110010 x 20101mantissaexponentConverting Floating Point to DecimalTo convert from floating point to decimal, take the following stepsConvert the exponent to decimal as normalUse the value in the exponent to adjust the binary point in the mantissa move it that many steps to the right

.10110010 x 2101

10110.010

Now convert the adjusted mantissa to decimal as normal

168421 1011001= 22.25

2101 = 5

Move the point five places to the rightConverting Decimal to Floating PointWhen converting decimal to floating point, you must know how many bits are available for the mantissa and exponent.

In this example we will be using an 8 bit mantissa and 4 bit exponent to convert 1045 to unsigned floating point

First create your conversion grid, using only the number of bits available in the mantissa. The leftmost place value should be the largest power of 2 less than the number you are converting

10245122561286432168

Use the grid to convert the number. If you have a remainder, round up in the same way as when converting fractions to binary

10245122561286432168 1 0 0 0 0 0 101 1 0 0 0 0 0 11

Now count the number of spaces the binary point would have to move to be at the very left of the number

10245122561286432168421 1 0 0 00 0 11000

Note this number as the exponent:

10000011 x 2 11

Convert the exponent to binary using the normal method:

10000011 x 2 1011

ASCIIThe American Standard Code for Information Interchange is a character set that represents all the letters, numeric characters and symbols used in English.

ASCII can be represented in seven bits. The last bit of the byte is left as 0 as a check bit. Later variants used the eighth bit to enable ASCII to represent all Latin characters

ASCII also includes a number of non-printable control character. These were originally intended to give the computer instructions, such as make a noise or move the cursor

CharacterBinaryDecimalSpace010 000032!010 000133010 0010340011 0001481011 0010492011 001150A100 000165B100 001066C100 001167a110 000197b110 001098c110 001199

UnicodeASCII only supports the characters used in English. It doesnt have encodings for the accents used some western European languages, and it doesnt support other alphabets such as Greek and Cyrillic, or eastern languages

Unicode is a character set that is designed to encode the text of most of the worlds languages. Unicode now has encodings for over 120,000 different characters

In Unicode, a variable amount of bytes is used to represent each character. UTF-16 uses up to two pairs of 16 bits, and can represent any Latin characters in only two bytesEditingBoth types of graphics usually have packages with a wide range of tools, but there are some effects on how images can be edited based on the type of graphics usedBitmap graphics allow the editing of individual pixels.

Bitmap graphics arent stored as objects and the attributes cant be changedIndividual pixels cant be changed in Vector graphics.

The attributes of an object, such as line thickness, can subsequently be changed at any timeTranslatingMoving objects about an image shows another difference between bitmap and vector graphicsWhen moving part of a bitmap image, a set of blank pixels is revealed beneath where the object used to be

Advanced bitmap graphics get around this by using layers of multiple bitmapsIn vector graphics, objects can be separated freely, and changed whether they appear in front of or behind other objects

RotatingTurning an image round shows another difference between bitmap and vector graphicsA rotated pixel can end up lying across the boundaries of more than one pixel. The resulting pixels have to be approximated

Advanced bitmap graphics use anti-aliasing to make rotated images appear smootherIn vector graphics, objects can be rotated freely. A mathematical formula is used to change the attributes of the new rotated shapeScalingResizing an image also shows a difference between bitmap and vector graphicsScaled bitmaps have to map existing pixels to new pixels. When increasing the size of an image, there is no way to create intermediate details, which can result in a blocky appearance

This is known as aliasing.In vector graphics, the lines stay smooth as the object is scaled. Again, a mathematical formula is used to work out the new attributed of the objectStorage RequirementsThe amount of storage required to save a bitmap image behaves differently from the amount required to store a vector imageThe storage requirements of a bitmap image relate to the number of pixels in the image, and how much space is required for each pixel

The storage requirements of a given sized bitmap are constant, regardless of the complexity of the image.

Bitmaps are good for storing photographs The storage requirements of a vector graphic relate to the number of objects in the image.

Each object and its attributes have to be stored. The more objects in the image, the larger the storage requirements will be

Vector graphics are good for storing diagrams and similar imagesCalculating the Storage Requirements of a bitmapThe formula for calculating the storage requirements of a bitmap is:

number of pixels x storage for one pixelorLength in pixels x height in pixels x storage for one pixel

You will be expected to give your answer in a reasonable unit, so be prepared to convert between the different units of storage

Example the storage requirements of a 600 x 400 bit map that uses 24 bit true colour

= 600 x 400 x 24 bits= 5,760,000 bits= 720,000 bytes= 703.125 kilobytes Divide by 8 to get the number of bytesDivide by 1024 to get the number of kilobytesAlways write down the unit of storage at each step!DisplayRegardless of the method used for storing an image, all images are displayed on the computer as a bitmap. Vector graphics are transformed to bitmaps by the computers graphics card.The number of pixels in an image may not be a good match for the resolution of the display. Such bitmaps have to be scaled, which can cause problems with the image

Bitmap images are said to be resolution dependant.Vector graphics can easily be scaled to an appropriate size for the resolution of the display before being turned into a bitmap image.

Vector graphics are said to be independent of resolution.

Sample rateThe sample rate of audio information is the frequency with which the audio is sampled. It is measured in hertz (Hz) and kilohertz

A sample rate of 1 Hz would be one sample of sound taken every second. In practice the actual sample rate for recording sound is typically 44 kHz or more. This allows sounds within the entire range of human hearing up to 20 kHz to be represented accurately

Each cross is a sound sample Note the scale at the top increasing approximately 2/10,000 of a second with each number labelBit depthThe bit depth of a sample is the accuracy with which each sample is recorded.

The bit depth defines how many values are potentially available to store a sample. If only two bits were used, then there would be only four potential values. These values would then be encoded to the binary values 00,01,10 and 11

In practice, whole bytes are used for encoding samples, with 8 bit, 16 bit and 24 bit depth all common

Any analogue value that falls between the potential values is approximated to the closest potential value11100100Storage Requirements of SoundThe formula for calculating the storage requirements of uncompressed sound is:

length (seconds) x sample rate (Hz) x bit depth (bits/bytes)

You will be expected to give your answer in a reasonable unit, so be prepared to convert between the different units of storage.

Example the storage requirements of 2:30 minutes of 44 kHz sound with a bit depth of 16 bits

= 150 x 44,000 x 16 bits= 105,600,000 bits= 13,200,000 bytes= 12,890.625 kilobytes= 12.59 megabytes (2 dp)

Divide by 8 to get the number of bytesDivide by 1024 to get the number of kilobytesAlways write down the unit of storage at each step!Divide by 1024 to get the number of megabytesRepresenting VideoIn a computer, video is represented as a number of still images. The images are displayed rapidly one after the other to give the illusion of a moving picture.

Recall that graphics can be represented in both bitmap and vector forms. Video can also be represented in bitmap and vector forms.

Bitmap video representation is used for almost all video in computers. It is the only type suitable for capturing video, and in most cases the only type suitable for playback of video. Bitmap video is represented by storing each frame of the video

Vector video is the animation of vector graphics. It is commonly used in the creation of computer animation in films. Vector video is represented as objects and descriptions of how they move. However, this video is impossible to produce at very high quality in real time, so it is usually rendered to bitmap video for playback.

ResolutionThe resolution of a bitmap video is a measure of how many pixels are used to create the images

Resolution is usually expressed in two numbers - the length and height of the video image in pixels. Television standards are expressed differently, in terms of the number of vertical lines in the video image the height of the image in pixels.

Increasing resolution increases the quality of the video image, but increases the file size as well. This is important for streaming video, though compression is usually used to reduce file size further

The resolution of various TV standardsFrame RateThe frame rate of a video is a measure of how many individual images are shown each second.

Increasing the frame rate of a video makes any motion in the video appear smoother. However, it also increases the file size of the video

As little as ten frames per second can be sufficient to give the appearance of motion. More frames are usually used so that very fast movement does not appear jerky. 24 frames per second is the standard in cinematography, and computer displays typically run at 60 frames per second

Storage Requirements of VideoThe formula for calculating the storage of uncompressed bitmap video is

storage for single image x frame rate x length of video (seconds)

The storage for a single image is calculated in the same way as for representing bitmap graphics.

You will be expected to give your answer in a reasonable unit, so be prepared to convert between the different units of storage.

Example calculate the storage requirements for 10 seconds of Full HD widescreen video, assuming a frame rate of 50 Hz and that true colour is used

1) Storage of a single frame

= 1080 x 1080 x 16/9 x 24= 49,766,400 bits= 6,220,800 bytes= 6075 kilobytesAlways write down the unit of storage at each step!Divide by 1024 to get the number of kilobytesDivide by 8 to get the number of bytesThe vertical resolution of 1080 is multiplied by the aspect ratio of 16:9 to get the horizontal resolution2) Storage of a whole video

= 6075 kilobytes x 50 x 10= 3,037,500 kilobytes= 2966.31 megabytes (2 dp) = 2.90 gigabytes (2 dp)

Uncompressed video is very large. Compression is usually used to keep file sizes much smallerAlways write down the unit of storage at each step!Divide by 1024 to get the number of megabytesDivide by 1024 to get the number of gigabytesGive one positive and one negative result of increasing the resolution of a videoCalculate the storage requirements of the following uncompressed videos:A 600 by 600 8 bit colour animation that runs for 10 seconds at 12 frames per secondA 1280 by 720 true colour video, 60 seconds long with 24 frames per secondA 50 Hz widescreen video with 24 bit colour and a vertical resolution of 1080. It is 45 seconds long

Processor StructureThe processor of a computer is made up of a number of sub units

The control unit of a processor directs the operation of the computer. It controls the flow of data between the other processor sub units and the rest of the computer

The arithmetic and logic unit of a processor performs calculations and comparisons.

The registers of a processor are short term memory locations with a very fast access speed.

Some registers have a dedicated purpose, such as the instruction register which holds the instruction currently being executed. Other registers are accessible to the program and can be used to store data for the ALUMemoryThe main memory of a computer is a series of addressable storage locations

Each memory location is uniform in size, holding the same amount of information as the computers data bus. The memory locations have a unique identifier their address

There are two types of computer memoryROM Read Only MemoryRAM Random Access Memory

ROM is used to store programs that the computer needs to run the basic operating system for the computer. RAM is used to store other programs, as well as any data used by the programs being executed.

Program instructions are loaded from memory to the registers on the processor when they are to be executed

Cache MemoryCache memory is a fast access area of memory used to speed up the execution of programs. Copies of the information in frequently accessed memory locations are held in the cache

If a memory location is accessed frequently, the cache will recognise this and load a copy of the contents of that location to one of the cache locations

Next time the process tries to access the memory location, it can get the contents from the cache instead. As the cache can be accessed faster than the main memory, the processor will not be delayed in executing the instruction while it waits for the information to be propagated from main memory

The cache can write updated cache locations back to main memory locations independently of the processor

The cache is usually fairly small a handful of megabytes is typicalBusesThe buses of a computer connect the various internal component and allow information to be passed between them

The data bus is used to read and write information from the registers to the main memory, and even permanent backing storage via an interface

Data buses are connected to all the memory locations of a computer. They have a size, which will be the same as the size of each memory location

The address bus is used to specify which memory location will be read or written to.

Address buses also have a size. The more bits that an address bus can transfer, the more memory locations a computer can haveThe control bus of computer is a collection of individual lines that allow the control unit to tell the rest of the computer what to do, as well as reporting the success of these operations

When executing a read instruction, the memory location will be placed in the address bus. The data bus will then transfer that information from the memory to one of the registers. The data bus will know to read, as it will be instructed to do so by the control bus

When executing a write instruction, the memory location will be placed in the address bus. The data bus will then transfer that information from one of the registers to the memory. The data bus will know to write, as it will be instructed to do so by the control bus

010110Addressability & Maximum MemoryRecall:Each memory location has an unique address to identify it. The address bus has a size in bits

The processor can only address memory locations with an identifier that would fit on the address bus.

The maximum possible memory of any computer can be worked out as follows

2 bits in address bus x size of each memory location

Increasing the size of the address bus has a big effect on the amount of memory a computer can have each extra bit doubles the maximum possible memory

Example a computer with a 16 bit address bus where each address stores 1 byte

= 216 x 1 bytes= 26 x 210 x 1 byte=26 kilobytes=64 kilobytesAlways write down the unit of storage at each step!210 = 1024

Each 210 in your address bus size can be set against dividing by 1024 to change the unit of memory

You can do this calculation without a calculator!

Address and data buses of this size were common in 1980s computersInterfacesRecall:The data bus transfers information between the processor and the memory

Information has to also be transferred from input devices, to output devices and back and forth from backing storage devices. These all represent information differently, and are designed to be used with different types of computer

An interface allows the transfer of information between the processor and memory and the input, output and backing storage parts of a computer

A SATA interface

Interfaces have a number of tasksData conversion The computer may represent information differently from the deviceSpeed conversion The computer may run at a different speed from the deviceBuffering As the computer and device may run at different speeds, the interface requires storage to temporarily hold information for the slower side of the interfaceStatus Information So the computer knows the status of the device: Is it working? Ready to accept more data?

To carry out a program instruction, the processor takes a number of steps

Fetch the instruction:A register called the program counter is used to store the location of the next instruction. This address is read and its contents are stored in the instruction registerDecode the instruction:The processor examines the contents of the instruction register and works out what it has to do in order to execute the instructionExecute the instruction:The processor carries out the instruction, depending on what it has decoded. The ALU is used to carry out calculations or comparisons if needed. Data can be read or written to and from registers and main memory.

Once completed, the processor moves on to the next instruction in the programArchitecture TrendsThroughout the development of computers processors have become increasingly powerful.

A common expression of the rate of improvement has been Moores Law, which observed that processing power doubled every two years or so. This rate has held true from between 1975 to 2012

More recently, the rate of improvement of processing power has slowed as chip manufacturers reach the limits of miniaturisation at the atomic level and how fast information can be propagated around computers

Modern processors are more or less the same size as their forbearersMost modern processor advances are incremental improvements based on architecture refinements rather than increasing raw speed

Pipelining is a method that improves processor performance by working on several instructions simultaneously

In a pipelining processor, whilst one instruction is being executed, the next one will be being decoded and the next is being fetched. This reduces the number of cycles required to complete an instruction.

However, if a jump instruction is encountered, it means all the subsequent instructions in the pipeline need to be thrown away as the program counter jumps to a completely different value

Another incremental architecture refinement is using multiple processors to allow programs to run in parallel.

A multicore processor contains two or more processors. Each processor can run different parts of the program at the same time, improving the speed at which it is executed

Programs must be multithreaded in order to take advantage of a multicore processor. A program written as one step after another cannot be split up and ran on different processor cores

Recall that the maximum amount of memory a computer can have is:

2 bits in address bus x size of each memory location

For a 32 bit computer, this maxes out at 16 gigabytes for computer with 32 bit address and data buses. This is very close to the amount of memory that modern computers typically have

64 bit processors first became available for home computers in 2003 and have become more common since. Most new computers are 64 bit.

The maximum available memory for 64 bit address bus and data bus could have 128 exabytes of memory. Clearly bus size wont have to change again for some time yet!