0% found this document useful (0 votes)
16 views

Computer Science Notes

The document provides revision notes on topics related to data representation and computer hardware. It covers converting between binary, decimal, and hexadecimal; character sets such as ASCII; data transmission methods; error checking techniques; computer hardware components including the CPU and encryption.

Uploaded by

nelsgeorgealt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Computer Science Notes

The document provides revision notes on topics related to data representation and computer hardware. It covers converting between binary, decimal, and hexadecimal; character sets such as ASCII; data transmission methods; error checking techniques; computer hardware components including the CPU and encryption.

Uploaded by

nelsgeorgealt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Monday, 3 October 2022

Data Representation Revision Notes


Converting Binary to Denary
• Use a conversion table to convert binary to denary
• Let’s take the binary number 00110101
128 64 32 16 8 4 2 1

0 0 1 1 0 1 0 1

• Add up the numbers which have 1 in their column


• (Calculators not allowed)
• 32+16+4+1=32+21=53 : 00110101=53

Converting Binary to Hexadecimal and vice


versa
• Binary to Hexadecimal:
- Split the binary number into nibbles (from right to left)
- If the number has extra bits, add 0s to the end, for
example 1111010001 becomes 0011.1101.0001
- Convert each nibble separately to denary (and as a result
hexadecimal) using a conversion table
- Convert any numbers higher than 10 to their letter
equivalent

8 4 2 1

0 0 1 1

1 1 0 1
0 0 0 1

- 0011=2+1=3
- 1101=8+4+1=13=D
- 0001=1
- 1111010001=3D1
• Hexadecimal to binary:
- Split each character of hexadecimal. If necessary, convert
letters to numbers
- Convert each number to binary using a conversion table.
- AE6:
- A=10 10=1010
- E=14 14=1110
- 6=0110
- AE6=101011100110
• To convert hexadecimal to denary, simply convert it to
binary and convert the binary number to denary.

Benefits of Hexadecimal Numbers in


Computer Science
• Compact
• Less likely to make an error
• Easy to convert to binary
• Can be used to display colours (RGB colour model)
• MAC address
• Error codes
• ASCII
Character Sets
• Character: A symbol present on a keyboard
• Has a speci c character code consisting of numbers
• Character set: A complete set of all the characters
• Different languages represented using character sets
• Some character sets are: ASCII, Extended ASCII and
Unicode

ASCII
• ASCII stands for American Standard Code for
Information Interchange
• ASCII is a 7-bit set of code which can represent 128
characters
• It can represent letters (both uppercase and lowercase),
digits, punctuation, special characters and control
characters
• Used for English only
Upper-case and lower-
52 characters
case letters
numbers (0-9) 10 characters
Punctuation, space
33 characters
and other symbols
Non-printable
32 characters
control codes
• Extended ASCII is an 8-bit character set, so it can encode
256 characters
• European languages can be represented in Extended
ASCII
fi
What is meant by a MAC Address?
• A MAC Address is a Media Access Control Address
• It refers to the number on the internet which uniquely
identi es a device on the internet
• It is made up of 48 bits, which is shown as a 6-group of
hexadecimal digits
• This address is written in the form NN-NN-NN-DD-DD-DD
where the N part is the identi cation number of the
manufacturer and the D part is the serial number of the
device

2s Complement
• Used to convert negative denary numbers
• Convert the number to binary
• Switch the 0s and 1s
• Add 1 at the end
• For example, -36
• 00100100
• 11011011
• 11011100=-36

Logical shifts
• Shifting Right: The Least Signi cant Bit (LSB) shifts to the
carry and the MSB is occupied by a zero.
• Shifting Left: The Most Signi cant Bit (MSB) shifts to the
carry and the LSB is occupied by a zero.
fi
fi
fi
fi
• Shifting to the right is equal to dividing a number by 2
• Shifting to the left is equal to multiplying a number by 2
Data Transmission Revision Notes
Methods of Transmission
• Serial:
- Data is sent one bit at a time along one channel.
- Slower than parallel
- Better over long distance
- Less interference and cheaper
- Asynchronous as only one channel is used
• Parallel:
- Data is sent multiple bits at a time over multiple channels
- Faster than serial
- Synchronous

Methods of synchronization
• Asynchronous:
- Data sent in groups with an agreed bit pattern
- Data combined with a start and stop bit
• Synchronous:
- Data sent as a stream of bits
- Synchronized by timing signals from an internal clock

Direction of Transmission
• Simplex:
- Data can be sent in one direction only
- Example: Radio
• Half-duplex:
- Data can be sent in both directions, but one at a time
- Example: Walkie-talkies
• Full-duplex:
- Data can be sent in both directions simultaneously
- Example: Mobile phone conversation

Image Compression
• Lossy Compression:
- A compression algorithm is used
- Permanently removes data from a le
- Tries to reconstruct the le without the missing data
- Each pixel has less bits
- Makes le smaller than lossless
- Drop in quality
• Lossless compression:
- Algorithms are used to spot patterns of similarly coloured
pixels
- Stores pattern as an instruction so image can be
reconstructed to its original quality

Sound Compression
• Lossy Compression:
- Permanently deletes sound from the le
- Only removes sound outside the human hearing range
fi
fi
fi
fi
- Not much of a drop in quality
- MP3 les are compressed using lossy and can be up to
90% smaller
• Lossless Compression:
- Compression algorithm is used to spot patches of similar
sound and state how many there are
- Stores it as an instruction so sound le can be
reconstructed to its original quality
- Uses MIDI (Musical Instrument Digital Interface) to store
pattern as an instruction
Bene ts of sending compressed les over the internet:
Faster
Takes up less storage space
Cheaper

Error Checking
• Parity Checking
- A parity bit is attached to the end of each block of data
- It can have even or odd parity
- The receiver performs a check to make sure it matches
the parity of the system
- If it does not, there has been an error in transmission
• Checksum
- A value called checksum is attached to the end of a block
of data
• The sender calculates the checksum
- The receiver then calculates the checksum
- If it matches, there is no transmission error
fi
fi
fi
fi
• ARQ
- ACKNOWLEDGEMENT and TIMEOUT are used
- ACKNOWLEDGEMENT is a message sent by the receiver
to the sender indicating that the data has been received
correctly.
- TIMEOUT is the time allowed to elapse before an
acknowledgement is received.
- If the ACKNOWLEDGEMENT is not received within the
TIMEOUT, the message is automatically resent.

Data Packets
• Data must be broken down into packets to be transmitted
• A packet contains:
- Packet header: This includes-
A. The sender and recipient’s IP address,
B. The packet number,
C. The total number of packets the message contains and
D. The details of any protocols used
- Payload: The actual message itself
- Trailer: Usually contains a couple of bits that will tell the
receiving device that it has reached the end of the packet
• Process of packet switching:
- Data is broken down into packets
- A router controls the route each packet takes
- Once the last packet has arrived, packets are reordered
USB
• USB: Universal serial bus
• It has 4 pins to connect wires, 2 which carry the power
and ground connection and 2 which transmit data
• Bene ts of using USBs:
- Industry standard
- Supports multiple transmission speeds
- Devices are automatically detected and con gured when
attached

Hardware Revision Notes


Encryption
• Encryption: The scrambling of data so that it is no longer
in a readable format
• Cipher text: The encrypted data/message
• Plain text: The data/message before it is encrypted
• Key: A sequence of numbers or characters used with the
algorithm to encrypt or decrypt data

The CPU
• The CPU carries out instructions using Fetch-Decode-
Execute
• Fetch: Next instruction and data are fetched from memory
fi
fi
• Decode: CPU translates the instructions into ones
understandable by it
• Execute: CPU executes the instructions in a logical
sequence, then repeats the process
• The CPU is made up of 4 main components:
- Control unit: Controls and coordinates which instructions
are executed and when. Contains Current Instruction
Register (CIR) which contains the instruction being
executed and the Program Counter (PC) which contains
the address of the next instruction.
- Arithmetic and Logical Unit (ALU): Responsible for all
mathematics and calculations performed by the CPU. Can
perform the following calculations:
A. Addition
B. Subtraction
C. Multiplication
D. Division
E. Logical comparisons (Is A=B, Is 3>5): The ALU can
increase the complexity of these logical comparisons by
adding boolean operators ‘And’, ‘Or’ and ‘Not’ (Is A<B Or
C<A).
- Program counter: Stores the address in memory of the
next instruction to be executed
- General Purpose Register (GPR): Notepad of the CPU. If
the ALU needs to temporarily store data as part of its
calculations, it is stored here.

Computer Architecture
• Buses: A bus is a set of parallel wires that connect two or
more components within a computer system
• Address bus:
- Carries signals that relate to addresses
- Between the processor and memory
- Uni-directional
• Control bus:
- Carries signals that relate to control
- For example, an instruction to read data
- Can be uni-directional or bi-directional
• Data bus:
- Carries actual data
- Between components and devices
- Bi-directional

Logic Gates
• NOT gate:
- Has only 1 input
- The output is the opposite of the input

• AND gate:
- If either of its inputs is 0, the output is 0
- It needs both inputs to be 1 for the output to be 1
• OR gate:
- If either of the inputs is 1, the output is 1
- Both of the inputs need to be 0 for the output to be 0

• NOR gate:
- If both of its inputs are 0, the output will be 1
- If either of its inputs are 1, the output will be 0

• NAND gate:
- If both of its inputs are 1, the output will be 0
- If either of its inputs are 0, the output will be 1

• XOR gate:
- If both of its inputs are different, the output will be 1
- If both of its inputs are the same, the output will be 0
Logic Circuits and Logic Statements
• Logic circuits are combinations of logic gates. Here is an
example.

• Because there are 3 inputs, there are 2^3 (8) possible


binary combinations
• Let’s look at how to draw a logic circuit from a logic
statement using an example question I did in class.
1. Read the logic statement. This one is X=1 if ((A is 1 AND
B is 1) OR (A is NOT 1 AND C is 1))
2. Split the statement into 3 blocks: (A is 1 AND B is 1), OR
& (A is NOT 1 AND C is 1)
3. Analyse each block separately. We can start with the OR
since it is the easiest to analyse: it simply means the
logic circuit will end with an OR gate.
4. Now we can analyse (A is 1 AND B is 1). This means A
and B are both connected by an AND gate.
5. (A is NOT 1 AND C is 1) is slightly more complicated. A
and C are both connected by an AND gate. However,
before reaching the AND gate, A goes through a NOT
gate.
6. Draw in all the circuits. They should look similar to mine
above.
7. A good way to check if your circuit works is to input the
values in the logic statement and see if they match.
• However, we can also write logic statements when given
a logic circuit. We will use another example.
1. Let’s split the circuit into blocks, similar to what we did
with the logic statement. Of course, the circuit will
always start X=1 if…
2. A and B are connected by an OR gate. Therefore one of
our blocks will be (A is 1 OR B is 1)
3. B and C are connected by another OR gate, but C rst
passes through a NOT gate. Our next block will then be
(B is 1 or C is NOT 1).
4. Both blocks seem to be connected by an AND gate at the
end. Therefore the nal statement should be X=1 if ((A is
1 OR B is 1) AND (B is 1 OR C is NOT 1)), or something
similar. As you can see, I did not write it exactly like this.
5. Like before, a great way to check your work is to input
the logic statement and see if it works.

Truth Tables
• Truth tables are tables which show all possible inputs and
outputs of a logic gate or circuit.
• They come in varying levels of complexity. For example,
here is a simple truth table for the OR gate.
fi
fi
• However, you may also be asked to write a truth table for
a logic circuit. Here is an example question and its
answer.

• Solving it is pretty simple. You just put the given inputs


through all the gates until you get the nal output. Do this
for each row to complete the truth table.
fi

You might also like