Download presentation
Presentation is loading. Please wait.
1
Computer Systems Unit 2 v.2
In this unit you will learn about; Low-Level operations and computer architecture Translation of high level program to binary Interpreters and compilers Using binary to store integers, real numbers, instructions and graphics Basic computer architecture Media Types Standard file formats (text, audio, graphics, video, pdf) Factors affecting file size and quality: (resolution, colour depth, sampling rate) Calculation of file size for colour bitmap Need for compression Testing and Documenting solutions Syntax, execution and logic errors Version 2
2
Integers Binary is based around the number two and uses the number symbols 0 and 1. Version 2
3
Now Do pages 1 to 8 Version 2
4
Real Numbers For example:
Real numbers (numbers with a decimal point in them) are stored using floating point representation. This is like standard form/scientific notation used in decimal. For example: can be represented as x 103 ( is the mantissa) (3 is the exponent) Version 2
5
The binary point is moved to the far left.
Computers use a very similar method to store numbers with decimal points. This method is called floating point representation and the main difference here is that the point is moved back to the start of the number. = x 2100 The binary point is moved to the far left. The point has been moved 4 to the left so we need to multiply by 24. The power 4 = 100 in binary. The computer stores the mantissa and the exponent 100 Version 2
6
The number of bits in a Mantissa determines the Precision
Precision and Range The number of bits in a Mantissa determines the Precision of the numbers that can be represented. If you want to store a very precise number i.e. Lots of numbers after the decimal point then you need to have a large Mantissa. The number of bits in an Exponent determines the Range of the numbers that can be represented. If you want to store a very large number then you need to have a large Exponent. Version 2
7
Now do pages 9 to 12 Version 2
8
Computer Graphics – Bit Mapped
Bit-mapped – image made up of pixels. Each pixel stores a binary code. The number of pixels in an image is called resolution. The number of bits (0 or 1) allocated to each pixel is called bit depth or colour depth. The greater the bit depth, the greater number of colours that can be displayed but file size will increase. The number of colours = 2 bit depth Version 2
9
The number of colours = 2 bit depth
2-bit colour 00 White 01 Yellow 10 Red 11 Black 2-bit colour would allow us 4 different colours to choose from. 4-bit colour 0000 White Yellow Green Orange 0100 Red Blue Brown Purple 1000 Grey Silver Gold Pink 1100 Tan Copper 1110 Maroon 1111 Black 4-bit colour would allow us 16 different colours to choose from. Version 2
10
Some images use 8 bit depth which allows 256 colours.
The best digital cameras use 24 depth which allows for over 16 million colours. Bit-Mapped Graphics Advantages 1. Good for high quality freehand paintings or photos. Allow individual pixels to be edited e.g. remove red eye. Bit-Mapped Graphics Disadvantages File sizes tend to be large (every pixel is stored). 2. Difficult to edit individual objects. Version 2
11
Calculating the File Size of a Bit Mapped Graphic
We need to know; * How many pixels there are * What the bit depth is File Size = Resolution x Bit Depth Height x Width or Pixels Number of Bits Version 2
12
Find the file size of a graphic with a
16 x 16 resolution and 20 bit depth. File Size = Resolution x Bit Depth = 16 x 16 x 20 bits = bits /8 = 640 bytes Version 2
13
Calculate the file size of an image with a bit depth of 24, measuring 3 inches by 4 inches and 300 dpi. Pixels in 1 square inch = 300 x 300 = 90,000 pixels Size of image = 3 x 4 = 12 square inches Pixels in image = 12 x 90,000 = 1,080,000 pixels File Size = Resolution x Bit Depth = 1,080,000 x 24 bits = 25,920,000 bits /8 = 3,240,000 bytes /1024 = 3, KB /1024 = 3.09 MB Version 2
14
Now Do pages 13 to 18 Version 2
15
Computer Graphics – Vector
Vector drawn graphics works by creating objects (lines/shapes) and defining them mathematically. When that object is saved, all that is actually saved is a formula which describes that shape’s attributes. Common attributes of vector graphics objects; shape position size rotation line fill Link Version 2
16
Advantages of using Vector Drawn Graphics
Can be scaled to large sizes, keeping original quality and file size. (Resolution Independent) Relatively small file sizes Individual objects can be edited. Easily converted to bitmapped Version 2
17
Now Do pages 18 to 23 Version 2
18
Media Types Standard File Formats
A standard file format is a file type that is recognised and can be opened by lots of different types of program. Version 2
19
The file size will be very small.
Text Files Plain text file .txt txt is a plain text file. It only stores text and ignores any formatting of the text that you might have done. This means that you would lose any different fonts, sizes, justification, line spacing, margins etc. The file size will be very small. Rich Text Format .rtf rtf (Rich Text Format) stores both text and formatting information, such as font colour, font type and justification etc. File size will be larger than for a txt file Version 2
20
Now Do pages 24 and 25 Version 2
21
Compression Graphics, audio and video files can be very large as there is a lot of data to be stored. Large files mean that: fewer files can be stored on a backing storage device loading and saving times for files is long on the Internet it takes a long time to load pages Video streaming over the internet may be impossible if transfer speeds can’t keep up Ways have been found to reduce the amount of data that has to be stored. This is called compression. Version 2
22
Compression Lossy Compression
Sometimes some of the data is just removed and so the quality is affected. If done carefully, we may not even notice the difference. This is called lossy compression. Lossless Compression Other methods manage to reduce the amount of data by analysing it and storing it in a more efficient way. This does not lose any data and is called lossless compression. Version 2
23
Graphics files The size and quality of a graphic file depends on:
the resolution of the image. All standard file types can store images with different resolutions. the colour depth. (the number of bits used to represent the colour of a pixel) the compression used. Version 2
24
jpeg (Joint Photographic Experts Group)
jpeg files are very popular for photographic and real life images. The user can decide on the quality for compression, choosing high quality which will result in a larger file size or low quality which produces smaller file sizes. Colour depth: 24 bit (allows 16 million colours) Compression: Lossy file sizes are small they load more quickly than bmp take up less storage space user can balance quality with file size Lossy compression is used so some of the quality is lost Version 2
25
bmp (bitmap file format)
bmp files are also used for photographs and real life images. They store the colour of every pixel in the image. bmp files are generally not compressed so the quality is high but the file sizes are also high. Colour depth: up to 32 bit (allows 4,000 million colours) Compression: Usually none files sizes are very large take a long time to load take up a lot of storage space quality is very high as there is no compression can choose the bit depth up to 32 bit depth Version 2
26
gif (graphics interchange format)
gif files use 8 bit depth so can only have up to 256 colours. They are used for cartoons, logos, simple drawings and animations. As they only have 8 bit depth and use lossless compression, files sizes are very small. Quality is good as long as no more than 256 colours are needed. Colour depth: 8 bit (allows 256 colours) Compression: Lossless files sizes are very small files load very quickly take up a little storage space quality is high as long as only a maximum of 256 colours are needed. Version 2
27
png (portable network graphics)
png was invented to replace the gif file format and is the most used lossless image compression format on the Internet. It can use up to 32 bit colour which means that up to 4,000 million colours are available. It can be used for colour images of all types. Quality is good as lossless compression is used. File sizes are generally bigger than jpeg but are always smaller than bmp Colour depth: up to 32 bit (allows 4,000 million colours) Compression: Lossless file sizes are small they load more quickly than bmp take up less storage space Lossless compression is used so quality is good Version 2
28
Audio Files Audio files take sound and convert it into a sequence of binary numbers. You have probably seen a picture of a sound wave. Here is what it looks like. Sound Time To convert this into a binary number, think of it as a graph with an x and y axis. The x axis represents time and the y axis represents the sound at that moment in time. Version 2
29
For one second of audio on a CD there are 44,100 samples x 16 bits.
Sample Rate The more often we measure the sound each second, the more accurate our file will be. The number of times we measure the sound per second is called the sampling rate. On a CD the sound is sampled 44,100 times per second! Bit Depth Each time the wave is measured, a binary number is used for its value. How many numbers are there on the y axis? For CD quality the numbers go from 0 up to 65,535. In binary this means that 16 bit binary numbers like the one below are used to store the sound each time it is sampled. The size of binary code used to represent the sound is called the bit depth. For one second of audio on a CD there are 44,100 samples x 16 bits. = bits /8 = bytes /1024 = Kilobytes Version 2
30
wav (waveform audio file format)
wav files are generally stored in an uncompressed format so the file sizes are large. The standard was agreed by Microsoft and IBM and is a popular way of storing high quality audio. mp3 (MPEG-1 or MPEG-2 Audio Layer III) You will, of course, be very familiar with the idea of an mp3 file but you probably didn't know its full name or where the idea of an mp3 came from. mp3 was invented as a way of storing the audio part of a video. An organisation called the Moving Pictures Expert Group (MPEG) came up with the idea. Mp3 uses lossy compression to make the file size much smaller but try to remove only data that is not really heard by the listener. Files can be compressed to about 1/10 the size of an uncompressed file such as the wav file. This means that you can store many more mp3s on your phone, mp3 player , computer etc. Version 2
31
Now Do pages 26 to 30 Version 2
32
avi (audio video interleave)
Video Files Video files are the largest of all the files discussed here and so all use compression to reduce the file size. They are called container files as they have to store both the audio and the video and may also store the audio in several versions for different languages. Some types allow you to store subtitles too. mp4 (MPEG-4 Part 14) mp4 is a current video format for video and audio. It was developed by the Moving Picture Experts Group(MPEG) who also developed mp3 for audio. avi (audio video interleave) avi is a current video format for video and audio. It was developed by Microsoft. Version 2
33
Most modern documents have a mixture of text and graphics in them.
pdf Files The final file standard in the N5 course is a standard for documents rather than for a particular media type. Most modern documents have a mixture of text and graphics in them. pdf (portable document format) When you save a file as a pdf file, it saves all the text and all the font descriptions. It also includes all the graphics as part of the pdf file This means that you can view the document on any device which can read pdf files and it will display everything accurately. Remember when you saved your website as a pdf file? Version 2
34
Now Do pages 31 to 33 Version 2
35
High Level Languages The binary version of the program is called machine code. It is a string of 1’s and 0’s e.g Machine code is not very easy to program in. Can you think why? High level languages were developed to make it easier to write programs. Common features of a HLL Use English words so are easier to understand. They are not written for a particular processor. Have commands to allow you to repeat parts of the program. They need to be translated. Version 2
36
Errors in Programs Two types of errors occur in computer programs:
errors that prevent the program from being executed (syntax) errors that occur while the program is running (execution, logic))) Syntax Errors Syntax errors occur during the creation of a computer program when an instruction is incorrectly typed or formatted. A syntax error will prevent the program from running as the editor cannot translate an instruction it can’t understand. Misspelt Keywords Pront “This will not work” This should have said ‘Print’ rather than ‘Pront’. Formatting Errors Print “Missing something There should be another “ at the end of the message. Version 2
37
Execution Errors An execution error (often called a ‘runtime’ error) occurs while the program is running. Never Ending Loops If the conditions for a conditional loop are written in a way that they can never be true the program will enter the loop but have no way of leaving it. This will not crash the program but as the program cannot go any further the user will have to quit from it. Unexpected Input An example of unexpected input could be if the program is expecting the user to enter an Integer but they enter a string instead causing the computer program to crash. Version 2
38
Logic error are caused by poor design or poorly written code.
Logic Errors Logic error are caused by poor design or poorly written code. Arithmetic Logic Errors For example, imagine a program that calculates the area of a rectangle. area = length * breadth If the programmer enters this calculation as area = length + breadth The program would run without any problems. It just wouldn’t give the correct answer. Selection Logic Errors Mistakes in conditional statements (num<10 instead of num>10) may cause a program to execute the wrong instructions. Version 2
39
Systems Software Computers only understand machine code.
Programs written in a High Level Language need to be translated before they can be run. A piece of software called a translator program does this. Two types of translator programs are; 1. Interpreter 2. Compiler Interpreters & Compilers Version 2
40
Interpreter Advantage Disadvantages Useful For:
Translates each line of the high level language program into machine code and executes it before going on to translate the next line. Advantage Development time is fast as syntax errors are reported after each line is translated and can be fixed. Disadvantages Slow execution time as each line has to be translated every time the program is rum. The interpreter is always required in memory to run the program. Useful For: Learning new programming languages. Developing new software. Version 2
41
Compiler Advantages Disadvantage Useful For;
Translates the complete program into machine code, stores the machine code version and executes this. If errors are discovered and fixed, the program has to be re-compiled until it is free from errors. Advantages Fast execution time because the machine code version is run. When the program is working, there is no need to have the compiler in memory. Much more economic in memory usage than an interpreter. Disadvantage Slow development time as errors are not discovered line by line. Useful For; Games software where execution time is important. Many companies use an interpreter to develop the software then a compiler to run the finished version. Version 2
42
Now Do pages 34 to 42 Version 2
43
ALU Control Unit Computer Architecture
A diagram of a processor is shown below. It contains several parts. Control Unit Register ALU Version 2
44
Registerss Register Register The registers are small storage locations inside the processor which hold data, instructions or memory addresses. Register Register Register Register Version 2
45
ALU ALU Arithmetic & Logic Unit
The ALU (Arithmetic Logic Unit) carries out all the calculations and decision making. Version 2
46
Control Unit Control Unit
The Control Unit is responsible for decoding and executing instructions. It also controls the timing of everything which goes in the computer, making sure that the movement of data and instructions is synchronized. Version 2
47
Interfaces Computer peripherals such as disk drives, printers etc. work in different ways. They work at different speeds, use different codes, transfer different amounts of data at a time, and even work at different voltages. An interface is the hardware and software needed between a processor and a peripheral device in order to compensate for differences in their operating characteristics. The interface allows the two devices to communicate correctly. Software contains the instructions for the operating system on how to communicate with the peripheral. Hardware is the actual connection between the computer and peripheral. Version 2
48
Interfaces USB – Universal Serial Bus
Used for memory sticks, music players, printer, scanners, keyboards Very fast interface (recent version USB 3, data transfer rates of up to 5 Gigabytes per second). Widely used (device can be plugged into a PC, Mac, tablet etc.) Version 2
49
Buses For a computer to function the processor needs to be able to communicate with other devices. The processor is connected to main memory and other parts of a computer using electrical lines called buses. Three buses: Address Bus Data Bus Control Bus Version 2
50
The Address Bus – a series of lines used by the processor to indicate which memory location has to be accessed to send or receive data. The Data Bus – a series of lines used to transfer the actual data to and from the processor and other parts of the computer. The Control Bus is a collective name for a number of discrete lines each of which has a different function and operates at different times. e.g. Interrupt Line. Devices send a signal on this line to interrupt the processor when they need attention eg. printer out of paper. Version 2
51
Fetch-Execute Cycle Here is what happens when you are e.g. running a True Basic program on your computer. The program will be stored in RAM. Each instruction is stored at a different address. Address Bus Data Bus Processor RAM Data Bus Instruction Processor RAM Address Bus Address The processor puts the address of the first instruction on the address bus. RAM puts the instruction at that address onto the data bus and it is delivered to the processor where it is stored in a register. Version 2
52
Who does what? 5 1 2 3 4 5 6 7 8 9 10 Register Register Hello Register
Writing Processor Memory Address Bus 5 1 2 3 4 5 6 7 8 9 10 ALU Register Data Bus Register Hello Hello Register Control Unit Control Bus Register This animation outlines how the internal components are structured and demonstrates a Write operation. First off, explain the components of the processor: - Arithmetic and Logic Unit (ALU) : does the actual calculations - Control Unit : Controls everything that’s happening, decodes the instructions - Registers : Internal memory locations for holding things temporarily Now explain that we need communication lines between the memory and the CPU: The address bus The data bus Control bus The animation then demonstrates a write operation. Explain that the address we want to write to is placed on the address bus, the data to be written on the data bus and a write message is sent via the control bus. The animation then shows the values moving across and the value (“Hello”) appearing in memory at the specified position. Write Register
53
Who does what? 7 1 2 3 4 5 6 7 8 9 10 Register Register Register
Reading Processor Memory Address Bus 7 1 2 3 4 5 6 7 8 9 10 ALU Register Data Bus Register Goodbye Register Control Unit Control Bus Register The animation then demonstrates a read operation. Explain that the address we want to read from is placed on the address bus, and a read message is sent via the control bus. The animation then shows the values moving across and the value (“Goodbye”) being sent back towards the processor along the address bus. Goodbye Read Register
54
The control unit decodes and executes the instruction.
Executing the instruction might involve fetching a variable from the RAM 1. The processor puts the address of the variable on the address bus 2. RAM puts the variable at that address onto the data bus and it is delivered to the processor where it is stored in a register. 3. The ALU would then do the calculation on that variable. When Steps 1, 2, & 3 have been completed the whole process begins again fetching and executing until the whole program has been executed. Version 2
55
Now Do pages 43 to 50 Version 2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.