What is Computer Architecture
it includes anaysis, design and systhesis of computers and computer components. it describes essential hardware components, the flow of information and instruction set requirements in order to understand computers
What is a CPU?
it’s the heard of the computer
Central Processing Unit (i.e. the processor)
it’s the core of every computer and performs the concrete steps needed in order to process data and perfom computations
Example (Camera app) - CPU
SPU reads program from memory which takes a selfie
Program is loaded step by step (e. g. connect to camera, wait for shutter release, take picture)
Prepare CPU component to execute these steps in oder (E.g. locate camera device on mainboard, connect to device,..)
Write finished picture to memory or a file in gallery
what is a CPU tipically doing?
it reads the program which should be executed from memory
Divides the program into seperate steps (the instructions)
Prepares all CPU-internal components for further use or output
Writes processing result to some location for further use or Output
what is the unoversal computing machine?
Memory
Arithmetical Logical Unit (ALU)
Control Unit (CU)
Input and output (I/ O)
the universal computing machine - memory
it provides storage for programs and data. The memory is divided into memory cells, each having a word size of “w” bites (“w” is the word size of the computer, e.g. 8 - 16 - 32 - 64 bits)
the universal computing machine - ALU
Performs arithmetical (e. g. add, subtract) logic (e.g. bitwise OR) and bit - shift operations. It contains register, small but fast memory banks for reading input and writing output data (e. g. the accumulator)
the universal computing machine - CU
Fetches and prepares the program code being executed and prepares the ALU for the actual computation process
the universal computing machine - I/ O
manages data flow to/ from external devices, e. g. keyboard or network
What’s the Bus-system?
in addition to CPU, memory and I/ O, there are bus-systems
(or busses which allow all components inside a computer ti exchange data e.g. talk to each other)
Data bus
transfer data e.g for processing
Adress bus
specify adresses in main memory, where data should be read from or written to
Control bus
Controls the bus-systemm (e.g. which component can send data at what time?) and other parameters
What are CPU Architectures (Platforms) ?
there are many different CPU architectures, which are desiigned differently, operate differently are use differentlx. Every CPU architecture has a particular goal:
General prupose ( what we call PC, i.e. c86, x86 - 64/AMD64)
Low-power/mobile (ARM)
High perfomance (IA64 i.e. Intel Itanium)
SPecific purpose (graphics cards, i.e. NVidia Ampere)
Word-length
a CPU architecture as a defined word length, i.e. the maximum size of a chunk of data which can be processed/ adressed within one single execution cycle.
Early CPUs were 8-bit processors (Intel 8008 n 1972, GameBoy, NES)
16-bit CPUs dominated in the early 80s (IBM PC, Intel 80186, 286) originally used by MS Windows
32-bit SPUs were the de facto standard from mid 80s early 2000s
Since the most CPUs are 64-bit
what’s the CPU Instruction Set?
every CPU architecture understand a particulas instruction ser, which is the list of instructions the CPU is able to process (arithmetic addition with “add” , jump within code with “jmp”, copy data with “mov”
every CPU instruction is encoded with a well-defined bit vector. Often, concrete instructions aso include arguments (e.g. operands for addition instruction) - the “add” instruction could be encored with binary bit vector “1001”. However, an addition always needs operands to add, so a full instruction adding two numbers could be “1001100101”
instruction (so-called “op code”): 1001
Operand 1: 100 (4decimal)
Operand 2: 101 (5 in decimal)
what’ s a program?
a CPU can only execute list f instructions composed of the instruction set they are built for. A seqence of such instructions is called a program
What’s is the Instruction Cycle?
the instruction cycle or “fetch-execute cycle” represents the list of all steps necessary for every single instruction to become fully processed by the CPU
what does the instruction cycle typically includes?
Phase 0: Fetch next instruction from memory (using program counter PC)
Phase 1: Decode the instruction (using the instruction decoder)
Phase 2: Fetch operands of instruction (from main memory or register)
Phase 3: Execute instruction (e.g. by feeding instruction and operands to ALU)
Phase 4: Store result created by ALU (e.g. into a register) to be used by future insructions
Different CPUs have different phases. Multiple phases can be combined into one longer phase, or a single phase can be devided into more shorter phases - it depends on the CPU’s architecture.
What is a software?
a software is what actually runs on a CPU, a sequence of instructions from the instruction set of a particular CPU.
Software has to be developed (programmed, coded, somtimes “hacked”) using a programming language
machine language
The CPU only understands “machine language”, which is only zeroes and ones. coding that way is uncomfortable (but in the first days, there was no alternatives).
Every instruction from the CPU’s instruction set is assigned a specific bit-order. A machine language operation is only valid for a particular CPU architecture and cannot be run on any other.
What is Assembly?
its the frist machine language, people invented.
A direct 1- to- 1 human-readable representation for te machine language. he Assembler subsequently translates the assembly source to the binary machine language, which can be fed into the CPU for execution.
What are High-level Languages?
as programs became more complex, Assemlby became too complicadet - just compare the complexity of old/ classic games with current ones. Development of “high-level languages began, they added:
syntax (grammer)
control structures (e.g. structures loops)
statements/ eexpression (which can be evaluated ti be true or false
modularization (e.g. package, modules, software libraries)
new languages paradigms, e.g. object-orientation, functional programming - e.g. Fortan, COBOL, Pascal, C, C++
What is a Compiler?
A programming language is implemented by a compier
the compiler reads a text-file containing source-code in syntax of a programming language
it reads (parses) the file and creates allembly code, i.e. a list of instructions based on the instruction set of target CPU where the program should run
the compiler in most cases automatically runs the assembler which finally translates the assembly code to machine code
! Compilers which directly generate machine code are called native or unmanaged
Compilation / build process
What are “Native Languages”?
Traditionally, compilers produce native machine code, i.e. transform “source code” of a native language (e.g. C, C++) into a sequence of 0s and 1s which correspond to the instruction set of a physical CPU which can in turn run that program
Native code can only run on the architecture it was compiled for, e.g. an x86 program can’t be directly run on an ARM CPU and vice versa
What are CPU Emulators
Although native code for e.g. x86 can’t run on ARM, we can develop an ARM program which transcodes every x86 machine code instruction of to the corresponding ARM machine code instruction - these programs are called emulators. Typically emulators are much more inefficient than their original hardware CPU’s
Game emulators work that way (e.g. run PS2 or GameBoy games on PC)
Run Nintendo NES/SNES and Nintendo 64 games on Nintendo Switch
Virtual Machines work that way (e.g. they fully emulate an actual CPU, and can run entire Operating Systems in a virtualized enviroment on your computer)
What are Native & Managed Languages?
in addition to native languages (C, C++,..) there are managed languages (C#, Java,..), a younger class of languages which creates “byte code” rather than native code, which is then executed by a “virtual machine”
What is a byte code?
a Byte code is an intermediate representation of code, which dies not run in any actual hardware CPU it’s read by the coresponding virtual machine (a program which simulates what a CPU would do), which in turn translates it to machine code of the CPU it currently runs on
Managed Language exmpl. Java
a managed language uses a compiler, which creates code fr a CPU which does not exist in hardware, but only as program (the virtual machine, e.g. the Java virtual MAchine), which in turn executes the byte code program
Example Java:
Java byte-code can’t run on physical hardware, bt is created for the Java Virtual Machine (JVM)
target platform needsa JVM installed, in order to run Java programs
Java is hence said the platformindependet, i.e. a program dies not habe to be re-compiled to run on other platforms, but every platform must have a JVM available (i.e. JVM has to be compiled for every supported platform)
Non-Linear Growth
Non.Linear Growth 2
What does better performance mean?
there are no definitive answer . it depents on we look at.
What performance may mean:
High bandwidth
Short datta transmission time (latency)
Short response time (e.g. round-trip-time, RTT)
Low resource utilization (CPU, memory, etc.)
High throughput (rate of processing work)
High availability
Performance - Example
Performance Example 2
Adding numbers
A number is represented by adding muliple symbols of the available character set. A famous example includes the Roman numeral system:
Multiple symbol in succession are summed up (additon), exept when the succeeding character represents a higher value than the current one (then the value of the current character is subtraced from is succcessor)
What’s the positional system?
it’s a number system, in which the value of a digit depends on its position in the numerical sequence.
positional system - or p-ary system
e.g.:
how to develop the positional system?
in order to develop such a system, we use a non-negative integer p> 1 as base, and p symbols (called digit) in order to construct numerical sequences for natural numbers. Example:
Let the digits be bi, with i = 1 ..p - 1, and assign to every 1-digit number one of the first p integers (beginnning with zero)
Let n be the length of the number sequence (digit count, e.g. n (100) = 3, n (12345) =5)
Every non-zero integer number a has exactly one p-aryrepresentation
psitional system - Symbols
the number of distinct symbols (digits) equals the base of the p.ary system (humans usually use the decadic number system, i.e. p = 10, that’s why we have digits from 0 to 9)
the highest possible value of a digit is p - 1
positional system - values
the value of a digit b in a number sequence a at place i, is the ith power of the base p of the system, e.g. for p = 10: a = b3b2b1b0 = 1234 hence the valuea of b2 is not 2 but 2 x pi = 2 x 10^2 = 200
the actual value of a number follows from the sum of the products of digit value and its place in the number sequence
positional system - Carryovers
if the hihest possible digit value is incremented by 1, it results in a carryover and we need an additional digit place (with higher significance) to represent it, e.g. 99 + 1 = 100 (the result can’t be expressed with 2 digits only)
number systems - Example Decimal
Base (p) = 10 - i.e. the number of available symbols (digits) is also 10 (0-9) with 9 being the highest
Carryover after 0: 9+1
= 10 = 1 x 10 + 0 x 10^0
number systems - Example Binary
Base (p) = 2 - number of availabe symbols (digits) is 2 (0 and 1), 1 being the highest
Carryover after 1: 1 + 1 = 10 = 1 x 2^1 * 0 x 2^0
number systems - Example Octal
Base (p) = 8 - number of available symbols (digits) is 8 (0 - 7), 7 being the highest
Carryover after 7: 7 + 1 = 10 = 1 x 8^1 + 0 x 8^0
number systems - Example Hexadecimal
Base (p) = 16 - numbers ov available symbols (digits) is 16 (0 - 9 and A - F), F being the highest
Highest value of one digit: F(15base 10)
easy conversions of number systems
if we write a number in a p-ary system where p != 10, the base is usually subscripted, e.g.:
Easy conversion between Binary - octal - hexadecimal
Binary, octal and hexadecimal numbers can easily be converted to each other without much calculation, since octal numbers are always represented by 3 bits, and hexadecimal numbers by 8 bits
converting binary to decimal
Using these two calculation schemes, we can convert from every base to every base, not only limited to decimal and binary. Every number can be represented with every p-ary system and is easily converted
Why ise binary numbers?
Advantages:
We only need 2 symbols to represent all digits
two symbols are far easier to represent in terms of physical states
Either carrying electric current or not (1/ 0) (e.g. in transistors)
Ferrometallic material is either magnetized or not (e.g. in transistors)
Light is either reflected or not (e.g. fiber optics)
Easier to model in terms of electronic circuits
Simplicity of logic circuits allows higher computation speed
Disadvantages:
Binary numbers are approx. 3 times as long as decimal numbers
Therefore, harder to read
What are negative numbers?
Humans use a sign to determine negative numbers. Strictly speaking, this would count as additional symbol. However, computers only have 2 distinct.
how to turn positive numbers into negative ones
to represent a negative number, simply use the positive one and invert all bits. This way, the most significant bit (outer left) can be used as indicator of the number being treated as positive (0) or negative (1)
what is the Two’s Complement?
Problem statement: Using the One’s Complement, we lose one value froom the value domain because the value zero (0) has two district encoding: all zeroes and all ones, e.g. 000 and 111 (i.e. it encodes +0 and -0, which doesn’t make sense). The solution to this problem is called “Two’s Complement”
What are the ASCII symbols?
ASCII: American Standard Code for Information Interchange
published in 1963 (with major revisions 1967 and 1986), ASCII was a 7-bit code, i.e. every symbol was represented by 7 bits
Hence could define 2^7 = 128 symbols
the 8th bit of a byte was used as parity bit for error-checking to preventfaultly communication transfers
7-bit ASCII is also called US-ASCII
8-bit ASCII
over time, further characters were needed e.g. language-specific characters and more symbol (umlauts,..)
the parity bit was then neglected, allowing additional 128 charecters to be used (2^8 = 256)
the charecters of the second, additional array of 128 symbols had then to be interpreted according to a Character Map, which was usually specific to countries or country conglomerates
e.g. ISO-8859-1 (aka Latin1, used in Western European countries), added support for imlauts, more currently symbols, etc.
What are the two problems with ASCII?
problem 1 - incompatible mappings:
when using ASCII with character maps, a message would contain irregular/ wrong characters, if sender and reciever did not configure the same character map for a message, e.g.
sender uses US-ASCII
reciefer uses Central European ASCII
Problem 2 - Limited character set:
With a maximum of 256 characters, the total number of distinguishable characters was hardly applicable to fit the many languages of the world.
What is Unicode?
Unicode is an international industry standard streeded by the “unicode Consortim, and defines particulas codes fr a large number of characters and symbols, including almost all symbols of human languages along with other non-language symbols (emojis).
it emodies the ISO 10646 standard called “Universal Coded Character Set” (UCS) which currently defines approx. 145000 symbols.
Unicode & Encoding
Unicodde only defines the list of symbols and their name - not necessarily their representation (called encoding)
There are multiple encoding schemes to represent Unicode characters like UTF-8, UTF-16 and UTF-32.
The number declares the minimum number of bits to represent a single symbol. the most widely used encoding UF-8.
What is UTF-8 encoding?
if the the first bit of a byte is zero, the current characters occupies a single byte and the remaining 7 bits are simular to the 7-bit ASCII - 0xxxxxxx
if the first 3 bits of the byte are 110, the current characters occupies 2 bytes in total: 110xxxxx 10xxxxxx
if the first 4 bits of the byte are 1110, the characters occupies 3 bytes
if the first 5 bits of the byte are 11110, the characters occupies 4 bytes
Interpretation
Sequences of bits are always open for “interpretation”, e.g. a byte sequence 01010011 can mean many things:
the decimal number 83 in decimal
The ASCII character “S”
2 4-bit numbers, 5 and 3
…
i.e. its just a number, you need to know what to do with
Zuletzt geändertvor 2 Jahren