CS1101: Lecture 28 the Microarchitecture Level

CS1101: Lecture 28 the Microarchitecture Level

Lecture Outline CS1101: Lecture 28 The Microarchitecture Level Dr. Barry O’Sullivan • What is a microarchitecture? [email protected] • OPCODE • Stacks • How does a stack works? • Use of a stack for storing local variables • Operand Stacks Course Homepage • Use of an Operand Stack http://www.cs.ucc.ie/˜osullb/cs1101 • Reading: Tanenbaum, Chapter 4: 4.1, 4.2, 4.5.1 Department of Computer Science, University College Cork Department of Computer Science, University College Cork 1 CS1101: Systems Organisation The Microarchitecture Level CS1101: Systems Organisation The Microarchitecture Level Where are we now? Introduction • The level above the digital logic level is the microarchitecture level. Level 5 Problem-oriented language level Translation (compiler) • Its job is to implement the ISA (Instruction Set Level 4 Assembly language level Architecture) level above it, as illustrated in Fig. 1-2. Translation (assembler) Level 3 Operating system machine level • The design of the microarchitecture level Partial interpretation (operating system) depends on the ISA being implemented, as Level 2 Instruction set architecture level well as the cost and performance goals of the computer. Interpretation (microprogram) or direct execution Level 1 Microarchitecture level • Many modern ISAs, particularly RISC designs, Hardware have simple instructions that can usually be executed in a single clock cycle. Level 0 Digital logic level • More complex ISAs may require many cycles Figure 1-2. Our six-level computer. to execute a single instruction. • Executing an instruction may require locating the operands in memory, reading them, and storing results back into memory. Department of Computer Science, University College Cork 2 Department of Computer Science, University College Cork 3 What is a microarchitecture? OPCODE • A convenient model for the design of the • Each instruction has a few fields, usually one or microarchitecture is to think of the design as a two, each of which has some specific purpose. programming problem, where each instruction at the ISA level is a function to be called by a • master program. The first field of every instruction is the opcode (short for operation code). • In this model, the master program is a simple, endless loop that determines a function to be • The opcode identifies the instruction, telling invoked, calls the function, then starts over. whether it is an ADD or a BRANCH, or something else. • The microprogram has a set of variables, called the state of the computer, which can be • Many instructions have an additional field, accessed by all the functions. which specifies the operand. • Each function changes at least some of the • For example, instructions that access a local variables making up the state. variable need a field to tell which variable. • For example, the Program Counter is part of • This model of execution is sometimes called the state – the memory location for the next the fetch-execute cycle. instruction. Department of Computer Science, University College Cork 4 Department of Computer Science, University College Cork 5 CS1101: Systems Organisation The Microarchitecture Level CS1101: Systems Organisation The Microarchitecture Level Stacks How does a stack works? • Virtually all programming languages support the concept of procedures (methods), which • Instead, an area of memory, called the stack, is have local variables. reserved for variables, but individual variables do not get absolute addresses in it. • These variables can be accessed from inside the procedure but cease to be accessible once • Instead, a register, say, LV, is set to point to the procedure has returned. the base of the local variables for the current procedure. • Where should these variables be kept in memory? • Another register, SP,points to the highest word of the local variables. • The simplest solution, to give each variable an absolute memory address, does not work, • since a procedure may call itself (be recursive). Variables are referred to by giving their offset (distance) from LV. • Why? • The data structure between LV and SP (and • If a procedure is active (i.e., called) twice, it including both words pointed to) is called a is impossible to store its variables in absolute variable’s local variable frame. memory locations because the second invocation will interfere with the first. Department of Computer Science, University College Cork 6 Department of Computer Science, University College Cork 7 Department of Computer Science, University College Cork 10 CS1101 • • • • CS1101: Systems Organisation The Microarchitecture Le stack and stored back inFinally, local variable the a1. top word can beresult back popped onto the off stack. the the stack, adds them together,executing an and instruction pushes that the pops twoThe words off actual computation can be doneNext, by a3 now is pushed onto the stack. address now pointed to bysay, SP. 4, andincremented by the the number first ofPush bytes a2 operand in a onto stored word, the at stack – the here SP has been : Systems Organisation Use of a stack for storing local variables Use of an Operand Stack SP c2 LV c1 SP d5 SP b4 b4 d4 b3 b3 d3 b2 b2 d2 LV b1 b1 LV d1 SP a3 108 a3 a3 a3 a2 104 a2 a2 a2 LV a1 100 a1 a1 a1 (a) (b) (c) (d) The Microarchitecture Level Figure 4-8. Use of a stack for storing local variables. (a) While A is activ (b) After A calls B. (c) After B calls C. (d) After C and B return and A calls D Department of Computer Science, University College Cork Department of Computer Science, University College Cork 9 • • • • CS1101: Systems Organisation The Microarchitecture Level the When used this way, the stack is referred to as the computation of an arithmeticThey expression. can be used for holding operands during local variables. Stacks have another use, in addition to holding to do the computation: Example: suppose that before calling B, A has Use of an Operand Stack operand stack Operand Stacks SP a3 SP a2 a2 SP a2 + a3 a3 a3 a3 SP a3 a a2 a2 a2 a2 1= LV a1 LV a1 LV a1 LV a2 + a3 . (a) (b) (c) (d) a Figure 4-9. Use of an operand stack for doing an arithmetic computation. 2+ a 3 Department of Computer Science, University College Cork 11.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us