entire comp sci flashcards
main job cpu
The Fetch-Decode-Execute cycle is the main job of the CPU.
instructions in fde cycle
In a program, each machine code instruction takes up a slot in the main memory. These memory locations each have a unique memory address. The program counter stores the address of each instruction and tells the CPU in what order they should be executed.
what does cpu do to execute program
To execute a program, the program code is copied from secondary storage into the main memory. The CPU’s program counter is set to the memory location where the first instruction in the program has been stored, and execution begins.
process of fde
The CPU checks the program counter to see the next instruction to execute.
The program counter gives a memory address to where the next instruction is
The CPU fetches the instruction from this memory address
The instruction is decoded and executed.
The program counter increments by 1
The cycle is repeated indefinitely
job alu
Arithmetic calculations
Logical operations
Comparisons between values
job cu
The control unit organises the fetch decode execute cycle, including managing the other components in the processor.
also controls flow of data inside and outside cpu
registers
Small amounts of high-speed memory in the CPU used to store small amounts of data needed for processing
Includes the address of the current instruction, the next instruction to be executed, and the results of calculations
job cache
A small amount of high-speed memory physically inside the CPU.
Temporarily holds small amounts of data which the CPU will reuse often.
Speeds up the system - does not have to wait for some data in memory to be fetched
Level 1, 2, 3 cache - 1 is the fastest, most expensive, and has the lowest amount of storage, likewise, 3 is the slowest, least expensive but contains the most amount of storage
what does von neumann arch state
Data and instructions are stored as binary
Data and instructions are both stored in primary storage
Instructions are fetched from memory one at a time and in order
The processor decodes and executes an instruction, and then does the same for the next instruction
This will continue until there are no more instructions
5 registers in von neumann arch
the program counter (PC)
the memory address register (MAR)
the memory data register (MDR)
the current instruction register (CIR)
the accumulator
program counter
the program counter (PC) holds the memory address of the next instruction to be fetched from primary storage
mar
the memory address register (MAR) holds memory address about to be used by CPU
cir
the current instruction register (CIR) holds the instruction that is currently being decoded and executed
mdr
the memory data register (MDR) holds data/instruction fetched from memory, or data about to be written to memory (primary)
accumulator
the accumulator (ACC) is a special purpose register and is used by the arithmetic logic unit (ALU) to hold the data being processed and the results of its calculations
clock spd
The clock speed is measured in gigahertz (GHz) and represents how many fetch-decode-execute cycles happen per second. 1 GHz = 1 billion cycles.
too highclock spd
However, a CPU which cannot keep up with its clock will corrupt its data. A very fast clock speed will cause the CPU to overheat and thermal throttle, reducing its performance to stop it from melting
why cache is there
Transferring data in and out of memory takes much longer than from cache. Therefore, placing frequently accessed data in the cache results in everything using that function being executed much faster. The more cache there is, the more data can be stored closer to the CPU.
l1 l2 l3 cache
L1 is usually part of the CPU chip and is both the smallest and the fastest to access. L2 and L3 caches are bigger than L1. They are extra caches built between the CPU and the RAM. Sometimes L2 is built into the CPU with L1.
L2 and L3 caches take slightly longer to access than L1.
cons of cache
However, cache is very expensive (L1 costs ~£1 per kilobyte), is limited by the space of the CPU, and is very small, so cannot be a full replacement for memory.
num cores
A CPU has multiple cores on it. CPUs with multiple cores have more power to run multiple programs at the same time.
However, doubling cores does not double clock speed. Some headroom is needed to communicate between each core.
embedded system
An embedded system is a small computer inside of a larger system.
Embedded systems have one specific function which they run.
prim storge
Primary storage consists of RAM (random access memory) and ROM (read-only memory).
general process comps
General process computers are designed to access the Internet, play games, play videos, and write programs. These all require applications to run. Tablets, phones and consoles are now increasingly classed as general process, as they now can run several applications.
avantage embd sys
Advantages of these systems include they require less power to run and are cheaper to make as their processors are not as powerful.
where can programming be done on embd system
They are not reprogrammable either - all the programming is done in manufacturing.
rom
ROM is non-volatile (retains its data after being powered off) and is usually often now only used to boot the computer, providing for the BIOS or UEFI.
exmpl embd system
Examples of embedded systems include GPS systems, digital watches, fitness trackers, washing machines, microwaves and more.
sec strgae
Secondary storage is non-volatile, meaning it retains the data written to it even when offline.
ram
RAM is smaller storage than 2ndry, but is much faster as it does not have moving parts or have to retain that information.
The more RAM a computer has, the more programs and instructions it can store simultaneously.
it is volatile
virt mem
Virtual memory is an area of secondary storage which is used as an overflow for when memory is filled up.
When RAM is full, data which would have gone to memory goes to an area of the disk drive. However, virtual memory is very slow.
hdd
An HDD (magnetic) has high capacity and involves flipping magnetic polarity to store bits. It is fairly fast to access.
usb
A USB drive (solid state) is tiny in comparison but very portable so is useful for transferring files between people and their computers.
ssd
An SSD (solid-state) has high capacity and involves trapping electrons to store bits. They are extremely fast to access
optical
Optical storage devices like CDs and DVDs use a laser to scan the tracks, and when light reflects back, it will either reflect from ‘lands’ - representing 1, or not reflect in ‘pits’ - representing 0
do embd sys have 2nd strg
Embedded systems may not need these as the instructions to run them are usually in ROM
formua 4sound file size
Sound file size = sample rate x duration (s) x bit depth
formula text file size
Text file size = bits per character x number of characters
formula image file size
Image file size = colour depth x image height (px) x image width (px)
hex to denary/binary
write down the hex digits, and convert them into nibbles which can then easily convert into denary.
F is 15 (1111 in binary)
0 is 0
denary/binary to hex
opposite of hex to binary/denary
adding binary digits
0 + 0 = 0
0 + 1 = 1
1 + 1 = 0, carry 1
1 + 1 + carried 1 = 1, carry 1
binary shift
A shift of 1 to the left means multiply by 2.
A shift of 3 to the left means multiply by 2^3 = 8
A shift of 1 to the right means divide by 2
A shift of 3 to the right means divide by 2^3 = 8
character set
character sets are collections of characters a computer recognises from their binary representation
ASCII
7bit binary code
reperesnts 128 total characters
extra bit added to start of binary code (0) so the character is 1 byte storage e.g
( (0 - extra bit) 1111111)
good for english lang
Xtended ascii
8 bit binary code
256 characters represnted
good for langs with slightly more letters like french which has é
unicode
16bit/32bit binary code
millions of represntable characters
e.g all langs, emojis
image
An image is represented as a series of pixels, again, represented as binary. Each pixel has a specific colour, represented by a specific code (can be a hex value).
img size+quality affected by
the image’s size and quality can be affected by the colour depth and resolution.
working out colour depth from bit depth
A black and white image has a bit depth of 1. This means it can only represent two colours - 2^1 = 2 colours.
An image which uses 10-bit depth can represent 2^10 = 1024 colours.
Colour depth = range of colours available.
size of img
Size, or dimensions, is how many pixels the image contains, in terms of height by width.
esimting size of file
The size of an image file can be estimated using:
the image height in pixels
the image width in pixels
the colour depth per pixel
resolution
Resolution is used to describe how densely packed the pixels are.
high resolution - lots of pixels, large file size
low res - little num of pixels, small file size
metadata
Files contain extra data called metadata. Metadata includes data about the file itself, such as file type, date created, author, geolocation and camera and image data itself, such as the height and width of the image, the resolution and the colour depth.
This allows for software to more easily interpret and decode the image file correctly, and output it to a monitor, for example.
what does metadata allow
This allows for software to more easily interpret and decode the image file correctly
sample rate
Sample rate is the number of samples recorded in a second. It is measured in hertz. The higher the sample rate, the closer the recorded digital signal is to the original, analogue sound.
Higher the sample rate, higher the file size
sound - bit depth
Bit depth is the number of bits used to record each sample. The higher the bit depth, the more accurately the sound can be recorded but the higher the file size.
sound - bit rate
Bit rate is the amount of data processed per second.
calculated by sample rate x bit depth, and is in bits per second.
Higher bit rate = higher quality sound, and also the file size.
recording sound
To record an audio file, analogue sound must first be captured by an input device, like a microphone, and then converted into a digital file to store on a computer.
first stage of rcording sound
Firstly, the microphone picks up sound and converts it into an electrical signal.
third stage recording sound
This is represented as a binary sequence called Pulse Code Modulation (PCM), and saved to a file. The raw data of the converted signal is uncompressed (using WAV/FLAC/AIFF formats).
second stgae recording sound
This is then used by the ADC (analogue-digital converter, typically located in a system’s sound card) and sampled at regular intervals which directly represent the sound wave’s traits, such as amplitude.
what happens when sound file read
When the file is read, the binary PCM sequence is passed through the DAC (digital-analogue converter) which uses the data to reconstruct an analogue waveform, as close to the original as possible, which is then played.
lossy
Lossy - some data is removed, reducing the overall data and quality and therefore size of the file.
Examples of lossy compression include JPEG, MPEG (or MP4) and MP3 files.
what gets compressed in image audio and video files
In an image, reducing colour depth, colour depth, resolution.
Bit depth can be reduced in audio files to reduce the file size.
Remember, in bit depth, it squares every time. A bit depth of 4 would mean 2^4 bits, or 16 potential colours or audio bits.
In video, frame rates and resolution.