0% found this document useful (0 votes)
13 views18 pages

CPU and Storage Types

The document provides an overview of CPU architecture, detailing the components of the CPU, including the ALU, control unit, and registers, as well as the various types of storage such as cache, main memory, and non-volatile storage. It explains the function of each component, the differences between machine and assembly languages, and the structure of programs in memory. Additionally, it compares different storage types in terms of speed, cost, size, and volatility.

Uploaded by

dfsadfsagf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views18 pages

CPU and Storage Types

The document provides an overview of CPU architecture, detailing the components of the CPU, including the ALU, control unit, and registers, as well as the various types of storage such as cache, main memory, and non-volatile storage. It explains the function of each component, the differences between machine and assembly languages, and the structure of programs in memory. Additionally, it compares different storage types in terms of speed, cost, size, and volatility.

Uploaded by

dfsadfsagf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

CPU and Storage Types

CSCI-274 Computer Architecture


The Central Processing Unit (CPU)
• Modern computers consist of CPU, volatile storage, non-volatile storage,
interconnection mechanism, control unit and a clock signal system
• The CPU is a chip that is the computational brain of the computer.
• It takes instructions and associated data, and executes the instructions.
• The CPU consists of the arithmetic and logical unit (ALU), control unit, CPU
registers, and the clock signal system.
• An interconnection mechanism called “bus” connects CPU with other components
• There is the address bus to transport address information, data bus to communicate data and
control bus to communicate control signals between the ALU and other components
• ALU gets information from the CPU registers gives results to CPU registers
CPU – Various depictions
CPU
• ALU = Arithmetic and Logical Unit
• ALU has the combinational logic to perform arithmetic and logical operations
• Plus, minus, times, divided by are arithmetic operations
• Less than, smaller than, equal to are logical operations
• Combinational logic is a mass of electronic circuitry that implements the propositional logic that
ultimately translates into various operations and algorithms
• Control Unit activates the relevant parts and circuits of the ALU
• It uses a pulsating signal with alternating high and low (binary signal) to for the right
combinational logic algorithm at the right time
• This signal is called system clock. Its frequency has the unit of Hertz or Hz.
• One Hz is the frequency of a signal that sends one cycle of pulse per second.
• Ten pulses per sec = 10 Hz, 1000 cycles/sec = 1000 Hz = 1 kHz = one kilo Hertz
• Million cycles per sec (cps) = 106 Hz = 1 MHz = one mega hertz
• A clock signal of one Hz sends one pulse per sec, a clock signal of 10 Hz sends one pulse every
1/10 sec, a clock speed of 1 kHz = one signal in1/1000 = 1 ms sec, a clock signal of 1 MHz =
pulse every 10-6 sec = microsec, and a clock with speed 1 GHz = pulse every nanosec.
CPU Registers
• CPU registers are inside the CPU. They store instructions and data.
• When we say a CPU is 32-bit we mean the registers are 32-bit size
• Some processors manufacturers say the size of register is one word.
• For example, MIPS-32 processor word size is 32 bits
• Intel calls 16 bit as the word. 32-bit = double word, 64-bits quad word
• There is also a half-word that is half the size of a word. Byte is 8 bits.
• 1024 Kilo Bytes = 210 kilo Bytes = 1024 kB = 1024 x 8 kilo bits = 8192 kb
• = 8.192 mega bytes = 8.192 Mb = 8 Mb = 1 M bytes = 1 MB
• Instructions and data are in the main memory.
• They are fetched to the CPU registers, executed by ALU and results are stored back in
the memory
• Typically, one instruction at a time. Or equivalent amount of data.
Main Memory
• Main memory is outside the CPU
• It is connected to CPU via the bus architecture
• A programming that is running is in the main memory
• It is executed by fetching a register full of (read one) instruction and/or data
at a time.
• Program is a simply a set of instructions with data if needed.
• Any part of the main memory can be used for program storing.
• That is why it is also called random access memory (RAM)
• Operating systems (OS) manage memory organizing it into various
parts
• For OS own use, for device drivers, for user programs, and so on
Cache
• Cache is a storage type that is inside the processor – just like the
registers.
• However, its function is different from that of registers.
• Cache is used to store instructions and data that may be used
frequently
• Thus, its purpose is purely performance related
• Cache affects the cost of the processor
• It is thus more expensive than main memory
• However, it is cheaper than register storage
Other storage media
• Recently, chip-based non-volatile storage is becoming more and more
affordable
• The economy of scale is the main driver for most computing and storage
technologies
• Flash drive is non-volatile plug and play type of storage available in the
form of thumb drives, various size cards.
• It is constantly dropping in price.
• Now, wireless USB drive of 200 GB is available for under $200.
• Optical and magnetic hard disk drives are non-volatile, very inexpensive
media
• DVD based storage, though still in use is getting less popular
• Cloud storage is becoming more affordable
• Amazon sells infinite storage capability for under $5 / month for personal use
Storage comparison
• Type Proximity to CPU Speed Cost Size Volatility
• CPU registers Inside the CPU Fastest most expensive Bytes volatile
• Cache Inside the CPU Faster expensive kB-GB volatile
• Main memory Outside the CPU Fast less expensive GBs volatile
• Solid state storage Outside CPU Fast less expensive 10s GB non~
• Hard drive Outside CPU not fast cheap 100s GB non~
• DVD/optical drive Outside CPU slow v. cheap GB non~
• Cloud Online slowest affordable TB non~
Program in main memory
• A computer program while running is in the main memory
• It consists of a sequence of machine instructions and data
• A machine instruction is in machine language.
• It consists of binary representation of op code and data
• Typically, a register can store one machine instructions.
• Every CPU comes with a set of machine instructions that can be used to
write a program for that chip
• This set of instructions is called Instruction Set Architecture (ISA).
• There are instruction sets for AMD, intel, Texas Instrument (TI) various
processor chips, such as MIPS chipset, intel’s Pentium, AMD64, etc.
• In latest processors, machine code in memory will be encrypted
• Such as in intel 6th generation processors using Software Guard Extensions (SGX)
Program outside main memory
• Inside the CPU, the program exists in one of the two forms
• An instruction, or data, or result of an operation in a CPU register
• A block of instructions in cache
• Outside the CPU and outside main memory, the program is typically in a
non-volatile state
• It is not in a running state.
• It will not be lost if processor power is switched off
• It could exist in many forms
• In machine language in binary or hexadecimal form
• In assembly language, which is a one-to-one mnemonic translation of machine
language
• In higher level language, which is a standardized natural language independent of
processor itself
Assembly language programming
• The assembly language is chip-specific.
• However, for 64-bit processors, AMD and intel have a common ISA.
• It’s called x86-64 instruction set. It is compatible with intel’s 32-bit
architecture termed as IA-32 (intel architecture 32).
• To program in assembly language one needs the following:
• A text editor, such as Windows notepad. Text editor is used to create a
program file with extension *.s or *.asm. One has to remove *.txt.
• The file thus created is called the source code.
• A program called assembler. The assembler converts source code into the
machine code that can be executed by the processor.
• There are many assemblers available for free and with money, such as NASM, MASM,
YASM, etc.
Assembly language programming - II
• Program written in assembly language has a structure just like higher level
language (HLL).
• However, the program structure depends on the assembler because even though
machine instruction set is specific, assembly code is not
• For example, following are some instruction in x64 assembly language and
what they do (Text to the right of semi-colon is treated as comments
• add_prgrm: ;This is a label. In HLL, it could be program or function name
• mov $0xc %esi ;Move the Hex value c (=12) to register esi. % is used in NASM
• mov $0x501208 %edi ;Move data from memory location Hex 501208
;to register edi.
• addq (%rdi), %rsi ;Add quad-word in memory location with address
;in register (%rdi) to the value in register %rsi
X64 Architecture – integer value registers
• The 64-bit processor x64 has 16 registers, each of size 64 bits
• The registers are for integer values and memory addresses
• They are names as RAX, RBX, RCX, RDI, RSI, RBP, RSP, R8, R9, R10, R11,
R12, R13, R14, R15
• Some are traditionally used for certain purpose, not required though.
• For example, RSP for stack pointer
• Stack is the memory area used for temporary function calls
• Heap is the memory area where main program data is stored
• If “R” in register name is replaced by “E”, it acts as a 32-bit register
• EAX, EBX, ESI, EDI, etc.
X64 Architecture – accessing register
• All the register excepts R8 through R15 can be accessed in whole or in
part
• R8, R9, R10, R11, R12, R13, R14, and R15 are new in x64 & can only be used as 64-bit register
• The rest can be used in 64-bit, 32-bit (lower), 16-bit (lower), each byte of 16-
bits format (lower byte and higher byte).
• Example: Register RAX can also be accessed as
• EAX (lower-32 bits act as register and higher 32-bits do not matter.
• AX (lower-16 bits act as register and higher 48-bits do not matter.
• AL (lower-8 bits act as register and higher 48-bits do not matter.
• AH (Higher byte of lower-16 bits act as register and higher 48-bits do not
matter.
CPU Questions
• Q1: Why R8…R15 can only be accessed as a whole but the other registers can be accessed in part as well as
in whole in x64 architecture?
• Ans: Because the other registers were present in previous processors with 32- 16- and 8-bit registers. This
access method makes it possible to run their programs on the new x64 processors. So, this makes the 64-bit
x64 processor backward compatible.
• Q2: What is the register RIP and what is its function?
• Ans: This register is not mentioned in slides. It has a 32-bit version EIP. This is the index pointer register. It
stores the address of the next instruction to be executed.
• Q3: What is the address of the next instruction to be executed?
• Ans: Usually, processors (not just intel but non-intel too) provide for accessing each byte of the main
memory where program is stored. Instructions are executed sequentially. This means that if instructions
number 101 is the current and the 102 is the next, then the RIP should have the memory address of the
instruction 102, except if execution of 101 causes a jump. Jump could occur due to iterative loop, recursive
function, conditional instruction, or simply a call for jump. The memory address of instruction 102 = memory
address of instruction 101 + processor bytes. For 64-bit processor is $x is the address of instruction 101 then
address of instruction 102 is $(x+8). This is because each instruction is 8-bytes apart and only bytes have
addresses and not memory cells or processor words.
CPU Questions - II
• Q4: What is the difference and what is the same about machine language and
assembly language?
• Ans: Difference: Machine language is in binary (or hexadecimal) form and
assembly language is in mnemonics. Same: There are the same number of
instructions in a program whether it is in assembly language or machine
language. This is because there is a one-to-one correspondence between the
instructions of the two language types.
• Q5: Is there a one-to-one correspondence between the (i) instructions of
machine language and HLL and (ii) instructions of assembly language and HLL?
• Ans: (i) No, (ii) No. The number of instructions in HLL is much less than either of
the other two languages.
• Q6: Which of the three types of languages is most and least abstract?
• Ans: HLL = most abstract (close to natural languages), machine language (least
abstract).
CPU Questions - III
• Q7: Rank the following storage types in terms of speed, proximity to the
processor, cost, size and volatility: register, cache, main memory, hard disk?
• Ans: See slide 9.
• Q8: What is the same and difference between a memory cell and memory word
(or CPU word)?
• Ans: Memory cell is the physical location for holding one CPU word, which is the
size of CPU register. So, word is a conceptual thing while cell is an actually existing
thing.
• Q9: Is the definition of ‘word’ for intel machine programming the same as the
register size?
• Ans: Not. Intel started the x64 architecture with originally with a 16-bit
architecture i386. So, in intel interpretation the word (‘w’) size is 16-bit. Then, 32-
bits are double word (‘d’), 64-bits are a quad-word (‘q’). You can also use byte
(‘b’) as a data type.

You might also like