CS232: Computer Architecture IIWhat is computer architecture about?Sections start next week (Monday)Who we areInstruction set architecturesMIPSWhat you will need to learn this monthMIPS: register-to-register, three addressRegister file reviewMIPS register fileMIPS register namesBasic arithmetic and logic operationsLarger expressionsImmediate operandsA more complete exampleWe need more space!Memory reviewMIPS memoryLoading and storing bytesByte loadsLoading and storing wordsAn array of wordsComputing with memoryMemory alignmentNext timeJanuary 14, 2019 ©2006 Craig Zilles (adapted from slides by Howard Huang)1CS232: Computer Architecture IIFall 2007January 14, 2019 Introduction to CS232 2Computer architecture is about building and analyzing computer systems.In CS232, we will take a tour of the whole machine, but …—I’m post-poning the real “class intro” until Wednesday, becauseWhat is computer architecture about?MemoryProcessorInput/OutputCompilerHLL ASMJanuary 14, 2019 Introduction to CS232 3Sections start next week (Monday)And I want to make good use of section. Note: Sections attendance is not optional.We will use section to present course materialSection problems useful for gauging your understanding of the material—Weekly, graded on effort, and good practice for the exams—In lieu of weekly written homeworkBut, a mistake was made scheduling the sections; there weren’t supposed to be Tuesday sections.—If you were registered for a Tuesday section, fill out form.January 14, 2019 Introduction to CS232 4Who we areLecturer: Prof. Craig Zilles•I do research on computer architecture and compilersSection Instructors & Teaching Assistants:Abdullah Al-NayeemAbhilasha ChoudharyPeter YoungJanuary 14, 2019 ©2006 Craig Zilles (partly adapted from slides by Howard Huang)5In CS232, we’ll talk about several important issues that we didn’t see in the simple processor from CS231.—The instruction set in CS231 lacked many features, such as support for function calls. We’ll work with a larger, more realistic processor.—We’ll also see more ways in which the instruction set architecture affects the hardware design.Instruction set architecturesSoftwareHardwareISAJanuary 14, 2019 Introduction to CS232 6MIPSIn this class, we’ll use the MIPS instruction set architecture (ISA) to illustrate concepts in assembly language and machine organization—Of course, the concepts are not MIPS-specific—MIPS is just convenient because it is real, yet simple (unlike x86)The MIPS ISA is still used in many places today. Primarily in embedded systems, like:—Various routers from Cisco—Game machines like the Nintendo 64 and Sony Playstation 2January 14, 2019 Introduction to CS232 7What you will need to learn this monthYou must become “fluent” in MIPS assembly:—Translate from C to MIPS and MIPS to CExample problem from a previous mid-term 1:Question 3: Write a recursive function (30 points)Here is a function pow that takes two arguments (n and m, both 32-bit numbers) and returns nm (i.e., n raised to the mth power). intpow(int n, int m) { if (m == 1) return n; return n * pow(n, m-1);}Translate this into a MIPS assembly language function.January 14, 2019 Introduction to CS232 8MIPS: register-to-register, three addressMIPS is a register-to-register, or load/store, architecture.—The destination and sources must all be registers.—Special instructions, which we’ll see later today, are needed to access main memory. MIPS uses three-address instructions for data manipulation.—Each ALU instruction contains a destination and two sources.—For example, an addition instruction (a = b + c) has the form:add a, b, coperationdestination sourcesoperandsJanuary 14, 2019 Introduction to CS232 9Register file reviewHere is a block symbol for a general 2k n register file.—If Write = 1, then D data is stored into D address.—You can read from two registers at once, by supplying the A address and B address inputs. The outputs appear as A data and B data.Registers are clocked, sequential devices.—We can read from the register file at any time. —Data is written only on the positive edge of the clock.D data Write D address A address B addressA data B data 2k n Register Filekkk n n nJanuary 14, 2019 Introduction to CS232 10MIPS register fileMIPS processors have 32 registers, each of which holds a 32-bit value. —Register addresses are 5 bits long.—The data inputs and outputs are 32-bits wide.More registers might seem better, but there is a limit to the goodness.—It’s more expensive, because of both the registers themselves as well as the decoders and muxes needed to select individual registers.—Instruction lengths may be affected, as we’ll see in the future.D data Write D address A address B addressA data B data32 32 Register File555 32 32 32January 14, 2019 Introduction to CS232 11MIPS register namesMIPS register names begin with a $. There are two naming conventions:—By number:$0 $1 $2 … $31—By (mostly) two-character names, such as:$a0-$a3 $s0-$s7 $t0-$t9 $sp $raNot all of the registers are equivalent:—E.g., register $0 or $zero always contains the value 0•(go ahead, try to change it)Other registers have special uses, by convention:—E.g., register $sp is used to hold the “stack pointer”You have to be a little careful in picking registers for your programs.January 14, 2019 Introduction to CS232 12Basic arithmetic and logic operationsThe basic integer arithmetic operations include the following:add sub mul divAnd here are a few logical operations:and or xorRemember that these all require three register operands; for example:add $t0, $t1, $t2 # $t0 = $t1 + $t2mul $s1, $s1, $a0 # $s1 = $s1 x $a0Note: a full MIPS ISA reference can be found in Appendix A (linked from website)January 14, 2019 Introduction to CS232 13More complex arithmetic expressions may require multiple operations at the instruction set level.t0 (t1 t2) (t3 t4) add $t0, $t1, $t2 # $t0 contains $t1 + $t2sub $s0, $t3, $t4 # Temporary value $s0 = $t3 - $t4mul $t0, $t0, $s0 # $t0 contains the final productTemporary registers may be necessary, since each MIPS instructions can access only two source registers and one destination.—In this example, we could re-use $t3 instead of introducing $s0.—But be careful not to modify registers that are needed
View Full Document