Intro To Computer Architecture

  • Uploaded by: scorpio_smiley
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Intro To Computer Architecture as PDF for free.

More details

  • Words: 1,649
  • Pages: 42
Computer Organization Intro to Computer Architecture

So what are we really learning? • How low-level software works • How hardware works – CPU in particular

• Where these 2 meet and work with each other

main: la $a0,str li $v0,4 Syscall li $v0, 10 Syscall

Why is this in any way necessary? • Primary reasons: – make you a better computer scientist – make you a better software engineer

• Additional reason: – make you a more interesting person in nerd circles

• Yes, people who don’t know this stuff are boring

$$$$$ Our Daily Reminder $$$$$ • You’re paying me to be here • This material cannot be learned in one night, or even in one week – please give me your brain

• This is your opportunity to learn this stuff – as Computer Scientists, you’ll have many opportunities to use it

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Learn Something Today • How many of these things can you define? – – – – – – – – –

CPU Register Cache Instruction Set ISA Assembly Language Assembler MIPS MARS

What is a CPU? • Central Processing Unit • The “brain” of the computer • What does it do? – Fetches, Decodes, AND Executes instructions

• What are Instructions? – commands to a computer

The Cell CPU Up Close

By the way • These days there’s a whole CPU Cooling market

A CPU has multiple regions • Control Unit – decodes instructions and relays orders to rest of CPU

• Arithmetic Logic Unit – performs basic mathematical operations

• CPU Memory – Registers – Cache

• We’ll see how these work in Part 3 of the semester

A CPU has memory? • Yes, a little • Far less than RAM • Let’s see who remembers the last slide: – What are the 2 types of CPU memory? • Registers • Cache

What are Registers? • Memory for executing binary instructions • All variables used to execute an instruction must be loaded into Registers • Accessing/Changing data in Registers is very fast – Why? • because it is very close to control unit & ALU

• CPUs have very small Register memory – MIPS uses 32 Registers

How much memory does a Register store? • One word • What’s a word? – well, first let’s understand what bits & bytes are

What are bits? • Stands for binary digit • Radix – 2, all representations in 1s and 0s • Everything in computers is stored in binary (programs, data (number, string), pictures, …. • Bits are easily represented in hardware • An open switch means a 0, closed switch means 1 (or vice versa) • Switches can be electrical, mechanical, semiconductor, magnetic

What are bytes? • A group of 8 bits • Ex: 01010101 • Memory can usually be addressable via bytes – What does that mean? • we can get a byte of data from memory if we know the memory address • we can change a byte of data in memory if we know the memory address

So what’s a word? • A group of bytes • Word size is dependent on architecture – 32-bit machine vs. 64-bit machine – Ex: MIPS uses 32 bit words (4 bytes)

• The memory of the computer will deliver 1 word at a time – So? • the wider the word, the greater the processing power

– Why? • more data can be processed each step

• CPU Instructions are word sized

So how much memory is that? • For MIPS Registers: – 32 registers X – 32 bits per register _______________ – 1024 bits (256 bytes)

• Hmm, that doesn’t seem like much

What is Cache? • A memory block in the CPU • It duplicates part of memory in RAM – still much smaller than RAM – Ex: Intel Core 2 has 8 MB of cache

• Why does it do this? – cache can be accessed faster than RAM

• How does it do this? – when a program executes, parts are loaded into cache – when memory is addressed, cache is checked first • if found it’s called a cache “hit” • for cache misses, parts of cache might need to be replaced

Registers vs. Cache • Registers: – is very small – can be directly accessed by developer code • we can load data into them • we can get data from them • we can specify which registers to use (they have names)

• Cache – is slightly bigger – is used managed automatically by the CPU – developers don’t directly instruct the CPU to use cache memory

Memory Comparisons faster

CPU Registers CPU Cache RAM (main memory) Hard Disk

more space

What is an instruction set? • Part of a system’s Architecture • Instructions: the words used to command a computer • Instruction set: a computer’s vocabulary • Different computers may use different instruction sets • NOTE: CPUs are hard-wired with: – an instruction set – an implementation of each type of available instruction

Are all instruction sets the same? • No • There are many similarities among them • But they are all different • Code used by a CPU with one architecture is generally unusable by a CPU

Common Operations • What types of things must all Instruction Sets be able to do? – – – – –

load data from memory addresses write data to memory addresses add/subtract/multiply/divide numbers conditional branching etc.

• Each will have different ways of doing these

What is an ISA? • Instruction Set Architecture • Includes: – – – – –

instruction set registers arrangement memory addressing numeric formats etc.

• Determines how instructions are given to a computer on the lowest level

Some ISAs • ARM – cell phones • Cell – PlayStation 3 • IA-32 – x86 PCs • MIPS – embedded systems • PowerPC – XBOX 360, GameCube, Wii • SPARC – Sun SPARC Workstations • And many, many more of course

What is an assembly language? • An implementation of an instruction set • Assembly code is written in an assembly language • It gets translated into machine code (binary) – by assembler

• The machine code is executed by the machine

Who writes assembly code? • Compilers • Crazy people – who have lots of time on their hands – who register for classes like CSE 220 • Smart people – working on a project where the speed or size of the program is critically important – like game programmers – who register for classes like CSE 220

HL vs. Assembly Language Programs

Critically Important Code? • NOTE: a skilled Assembly Programmer can in many cases write code that is more efficient than what a compiler may create • Compilers have become smarter & smarter though • Compilers may have optimization options

Some C/C++ programmers will mix in some assembly float arg1, arg2, add ; printf( "Enter two numbers : " ); scanf( "%f%f", &arg1, &arg2 ); /* Perform floating point Addition */ __asm__("fld %1;“ "fld %2;“ "fadd;“ "fstp %0;":"=g"(add):"g"(arg1),"g"(arg2)); printf( "%f + %f = %f\n", arg1, arg2, add );

Ref: http://www.codeproject.com/KB/cpp/edujini_inline_asm.aspx

MIPS - Course Assembly Language • MIPS – “Microprocessor without Interlocked Pipeline Stages” – ISA used primarily in embedded systems • PlayStation 1 & 2, Nintendo64, & PSP • digital cameras, DVD players, routers, wireless phones, HDTVs, etc.

• Why MIPS? – has a long educational legacy – good textbook – still widely used • MIPS Architecture and Assembly Language Overview

MIPS • Designed in early 1980s by John Hennessy – our textbook author and Stony Brook CS alumni

• Is a Reduced Instruction Set Computer architecture (RISC) – as opposed to Complex Instruction Set Computer architecture (CISC) • once used by most PCs • starting with the 486 and Pentium-I processors Intel implemented a RISC core in its processors • more on RISC vs. CISC later this semester

Classes of computers • Desktop Computers • Servers • Supercomputers • Embedded Systems

What are embedded systems? • “Computers designed to run one application or one set of applications which is normally integrated with the hardware and delivered as a single system” • Good to know: – more of these than all the others combined – very wide range of price & performance – most users don’t even know they’re using a computer

• Any examples?

MARS – Course IDE • MARS – MIPS Assembler & Runtime Simulator – freely downloadable 2.1 MB JAR file – http://courses.missouristate.edu/KenVollmar/MARS/

• Online tutorial: – http://courses.missouristate.edu/KenVollmar/MARS/tutorial.htm

• All MIPS programming assignments should be done using MARS

Why don’t CPUs just use C?

Abstraction

What’s so good about abstraction? • CPU makers can make CPUs better – faster – more efficient – easier to program

• Same for high level language programmers – you write a program in C – a compiler translates the C code into MIPS – an assembler translates the MIPS code into bytecode

hello.c /* hello.c * Purpose - print hello */ #include <stdio.h> int main(void) { printf("Hello, world!\n"); return 0; }

hello.asm ## hello.asm - print out "hello world" # text Segment # .text # tells assembler program code starts here .globl main # defines label for execution start main: # execution starts here la $a0,str # put string address into a0 li $v0,4 # system call to print syscall # out a string li $v0, 10 # Load exit syscall value syscall # Exit # data segment # .data # tells assembler data segment begins here str: .asciiz "hello world\n" # declaration of a string

bytecode executed by hardware 00111100000000010001000000000001 00110100001001000000000000000000 00100000000000100000000000000100 00000000000000000000000000001100 00100000000000100000000000001010 00000000000000000000000000001100

What did you learn today? • How many of these things can you define? – – – – – – – – –

CPU Register Cache Instruction Set ISA Assembly Language Assembler MIPS MARS

Next Time • Basic MIPS program format • MIPS instructions • MIPS registers

Related Documents