Logo/

Processor Structure and Instruction Cycle

Log in

Made with ScholarlyMake flashcards like these from your own notes

Processor Structure and Instruction Cycle

Questions and answers

82 cards
  1. Question:What are the main requirements of a processor in executing instructions?

    Answer:The processor must fetch instructions, interpret (decode) them, fetch data from memory or I/O if needed, process data by performing arithmetic or logical operations, write results back to memory or I/O, and store some data temporarily using internal memory.

  2. Question:What are the major components of a processor?

    Answer:The major components include the Arithmetic and Logic Unit (ALU) which performs computations, the Control Unit (CU) which manages data and instruction flow and controls the ALU, and registers which are small storage locations within the processor.

  3. Question:How are data transferred within the CPU?

    Answer:Data are transferred between various registers and the ALU using the internal processor bus, which connects these elements within the CPU's internal structure.

  4. Question:Compare the internal structure of the computer as a whole to the internal structure of the processor.

    Answer:Both have a small collection of major elements connected by data paths: the computer includes processor, I/O, and memory; the processor includes control unit, ALU, and registers.

  5. Question:What is the role of registers within a processor?

    Answer:Registers serve as a small, fast memory above main memory and cache, supporting temporary data storage; they perform control and status functions and can be user-visible for program execution.

  6. Question:What are the two roles of registers in the processor?

    Answer:They function as control and status registers, used by the control unit and privileged programs, and as user-visible registers utilized by assembly language programmers to optimize memory references.

  7. Question:Describe categories of user-visible registers in a processor.

    Answer:User-visible registers include general purpose registers (used for various functions), data registers (hold data only, not for calculating operand addresses), address registers (may be general or specialized for addressing modes, e.g., segment pointers, index registers, stack pointer), and condition code registers (flags set by hardware after operations).

  8. Question:What are condition codes or flags in a processor?

    Answer:They are bits set by the processor hardware as the result of operations to indicate conditions such as zero result, carry, overflow, or equality, used for controlling program flow and decisions.

  9. Question:What are the four essential control and status registers for instruction execution?

    Answer:Program Counter (PC) holds the address of the next instruction to fetch; Instruction Register (IR) holds the most recently fetched instruction; Memory Address Register (MAR) holds the address for memory access; Memory Buffer Register (MBR) holds data to be written to or read from memory.

  10. Question:What is the purpose of the Program Counter (PC)?

    Answer:The PC contains the address of the instruction to be fetched next from memory.

  11. Question:What does the Instruction Register (IR) do?

    Answer:The IR contains the instruction most recently fetched from memory, ready for decoding and execution.

  12. Question:What is the function of the Memory Address Register (MAR)?

    Answer:The MAR contains the address of a location in memory to be read from or written to.

  13. Question:What is stored in the Memory Buffer Register (MBR)?

    Answer:The MBR stores a word of data to be written to memory or the word most recently read from memory.

  14. Question:What is the Program Status Word (PSW) and what does it contain?

    Answer:The PSW is a register or set of registers holding status information including flags such as sign, zero, carry, equal, overflow, interrupt enable/disable, and supervisor mode flag.

  15. Question:Explain some common flags contained in the Program Status Word (PSW).

    Answer:- Sign flag: sign bit of last arithmetic result - Zero flag: set if result is zero - Carry flag: set if addition results in carry or subtraction in borrow - Equal flag: set if logical compare results in equality - Overflow flag: indicates arithmetic overflow - Interrupt Enable/Disable: controls interrupt processing - Supervisor mode flag: indicates if processor operates in supervisor or user mode.

  16. Question:Why is the supervisor mode flag important in the PSW?

    Answer:It indicates whether the processor is running in supervisor (privileged) mode or user mode, controlling access to certain instructions and memory areas reserved for system-level operations.

  17. Question:What are the register types and sizes in the MC68000 microprocessor?

    Answer:The MC68000 has 32-bit registers, including 8 data registers and 9 address registers. It also has a 32-bit program counter and a 16-bit status register.

  18. Question:How are data registers used in the MC68000 processor?

    Answer:Data registers are primarily used for data manipulation and also serve as index registers for addressing.

  19. Question:What is unique about the register organization in the Intel 8086 microprocessor?

    Answer:The Intel 8086 uses 16-bit registers, with every register being special purpose. It includes 4 data registers, 4 pointer and index registers, and 4 segment registers.

  20. Question:How does the Intel 80386 differ from the Intel 8086 in terms of registers?

    Answer:The Intel 80386 is a 32-bit extension of the 8086, but there is no universally accepted philosophy concerning the best way to organize processor registers.

  21. Question:What are the usual stages included in the instruction cycle?

    Answer:The instruction cycle includes Fetch, Execute, and Interrupt stages.

  22. Question:What happens during the interrupt stage of the instruction cycle if an interrupt has occurred and interrupts are enabled?

    Answer:The current process state is saved, and the interrupt is serviced.

  23. Question:What must be done after fetching an instruction if indirect addressing is involved?

    Answer:Operands required by indirect addressing are fetched by performing memory access operations to retrieve those operands from memory.

  24. Question:Describe the general steps during the fetch cycle of the instruction cycle.

    Answer:1. Program Counter (PC) contains the address of the next instruction. 2. Address moved to Memory Address Register (MAR). 3. Address placed on address bus to identify the memory location. 4. Control unit sends a memory read signal. 5. Data retrieved from memory is placed on the data bus, copied to Memory Buffer Register (MBR), then to Instruction Register (IR). 6. Meanwhile, the PC is incremented by 1 to prepare for the next fetch.

  25. Question:What is the purpose of the indirect cycle following the fetch cycle?

    Answer:The indirect cycle fetches the effective address of the operand when the instruction uses indirect addressing, ensuring the operand can be accessed for execution.

  26. Question:Outline the steps involved in the indirect cycle.

    Answer:1. The rightmost N bits of the MBR are transferred to the MAR and placed on the address bus to identify the memory location. 2. The control unit sends a memory read signal. 3. The retrieved result (address of the operand) is moved to the MBR.

  27. Question:Why are fetch and indirect cycles considered predictable?

    Answer:Because they follow a fixed sequence of well-defined steps, making their behavior consistent and reliable during instruction processing.

  28. Question:What is the first step in processing an interrupt in a CPU according to the described interrupt cycle?

    Answer:The contents of the Program Counter (PC) are copied to the Memory Buffer Register (MBR).

  29. Question:Why is the current Program Counter (PC) value saved during an interrupt cycle?

    Answer:To allow resumption of the program after the interrupt has been handled.

  30. Question:Describe the steps involved in processing an interrupt as outlined in the interrupt cycle.

    Answer:1. Contents of PC copied to MBR. 2. Special memory location (e.g., stack pointer) loaded to MAR to identify stack location. 3. MBR written to memory (saving the PC). 4. PC loaded with the address of the interrupt handling routine. Then, the next instruction fetched is the first of the interrupt handler routine.

  31. Question:How does pipelining in instruction execution relate to an assembly line in manufacturing?

    Answer:Just like an assembly line processes multiple items simultaneously at different stages, instruction pipelining breaks the instruction execution into separate stages, allowing multiple instructions to be processed concurrently, each at a different stage.

  32. Question:What is the significance of recognizing that an instruction has a number of stages for pipelining?

    Answer:Recognizing multiple stages in an instruction allows the CPU to accept new instructions before previous instructions have completed, improving instruction throughput by overlapping execution.

  33. Question:What are the two stages in the simplest instruction pipeline?

    Answer:The two stages are 'Fetch Instruction' and 'Execute Instruction'.

  34. Question:List some additional stages that increase speedup in an instruction pipeline beyond the basic two stages.

    Answer:Additional stages include: Fetch Instruction (FI), Decode Instruction (DI), Calculate Operands (CO), Fetch Operands (FO), Execute Instruction (EI), and Write Operand (WO).

  35. Question:What does the Decode Instruction (DI) stage entail in an instruction pipeline?

    Answer:Determining the opcode and the operand specifiers for the fetched instruction.

  36. Question:Explain the purpose of the Calculate Operands (CO) stage in the pipeline.

    Answer:Calculating the effective address of each source operand, which may involve displacement, register indirect addressing, or other forms of address calculation.

  37. Question:What is performed during the Write Operand (WO) stage in pipelined instruction execution?

    Answer:The calculated result, if any, is stored in memory or registers as specified by the instruction.

  38. Question:How does the presence of a conditional branch instruction affect instruction pipeline operation?

    Answer:Because the next instruction depends on the branch condition, the pipeline may have to discard or stall instructions already being fetched or decoded, causing delays or bubbles in the pipeline.

  39. Question:What is the formula for calculating the cycle time (τ) of an instruction pipeline with k stages?

    Answer:τ = max(τ_i) + d, where τ_i is the delay of stage i (1 ≤ i ≤ k), and d is the latch delay needed to propagate signals between stages.

  40. Question:In the pipeline cycle time formula, what does τ_m represent?

    Answer:τ_m is the delay through the pipeline stage that experiences the largest delay.

  41. Question:Why is there a latch delay (d) included in calculating pipeline cycle time?

    Answer:Because latches are used between pipeline stages to advance signals and data, their delay must be added to the critical path to ensure proper timing.

  42. Question:What is the formula for the total time units for an instruction pipeline?

    Answer:The total time units for the instruction pipeline is: Tk,n = [k + (n - 1)] × τ, where k is the number of stages of the pipeline, n is the number of instructions, and τ is the cycle time.

  43. Question:How is the speedup factor (Sk) of an instruction pipeline defined compared to execution without pipelining?

    Answer:Sk = (T1,n) / (Tk,n) = (n × k × τ) / ([k + (n - 1)] × τ) = nk / [k + (n - 1)], where T1,n is the time without pipeline and Tk,n is the time with pipeline.

  44. Question:In the example with k=6 stages, n=9 instructions, and cycle time τ=1 sec, what is the total pipeline time (Tk,n)?

    Answer:Tk,n = [6 + (9 - 1)] × 1 = 14 seconds.

  45. Question:Using the example above, what is the speedup factor Sk for the instruction pipeline?

    Answer:Sk = (9 × 6 × 1) / 14 = 54 / 14 ≈ 3.86.

  46. Question:How does increasing the number of pipeline stages affect potential speedup and what practical issues arise?

    Answer:Increasing the number of pipeline stages increases the potential speedup, but in practice it also increases costs and introduces delays between stages that can reduce overall efficiency.

  47. Question:What are pipeline hazards and what do they cause?

    Answer:Pipeline hazards occur when the pipeline must stall because conditions do not permit continued execution, causing delays often called pipeline bubbles.

  48. Question:What are the three main types of pipeline hazards?

    Answer:The three types are resource hazards, data hazards, and control hazards.

  49. Question:What is a resource hazard (or structural hazard) in pipeline processing?

    Answer:A resource hazard occurs when two or more instructions in the pipeline need the same resource simultaneously, forcing serialization of those instructions during that portion of the pipeline.

  50. Question:What is a data hazard in pipeline processing?

    Answer:A data hazard occurs when there is a conflict accessing an operand location, such as when two instructions access the same memory or register operand in a way that creates a timing conflict.

  51. Question:What are the three types of data hazards?

    Answer:1. Read after write (RAW): true dependency where a read occurs before a prior write is complete. 2. Write after read (WAR): antidependency where a write happens before a prior read is done. 3. Write after write (WAW): output dependency where writes to the same location occur out of intended order.

  52. Question:Explain the Read After Write (RAW) hazard.

    Answer:RAW hazard occurs when an instruction tries to read data from a register or memory location before a previous instruction has completed writing to that location.

  53. Question:Explain the Write After Read (WAR) hazard.

    Answer:WAR hazard occurs when an instruction writes to a register or memory location before a previous instruction completes reading from it, causing potential data inconsistency.

  54. Question:Explain the Write After Write (WAW) hazard.

    Answer:WAW hazard happens when two instructions write to the same location, and the writes occur in the reverse order of the intended sequence, possibly corrupting data.

  55. Question:What is a control hazard (also called a branch hazard) in pipeline processing?

    Answer:A control hazard occurs when the pipeline makes a wrong decision on a branch prediction, causing instructions that were fetched to be discarded.

  56. Question:List some methods used to deal with branch instructions to reduce control hazards.

    Answer:Methods include multiple streams, prefetching branch targets, loop buffers, branch prediction, and delayed branching.

  57. Question:What is the multiple streams approach to handle branches in pipelines?

    Answer:It replicates the initial portions of the pipeline to fetch both possible branch instructions simultaneously, using two streams to avoid penalties due to wrong branch predictions.

  58. Question:What are drawbacks of the multiple streams approach?

    Answer:Controversy delays for accessing registers and memory increase, and additional branch instructions may enter the pipeline before the original branch decision is resolved.

  59. Question:How does prefetching branch targets help reduce control hazards?

    Answer:When a conditional branch is recognized, both the target instruction and the instruction following the branch are prefetched, so if the branch is taken, the target is already available, reducing delays.

  60. Question:Which computer system is known for using prefetch branch target approach?

    Answer:IBM 360/91.

  61. Question:What is a loop buffer in the context of a pipeline instruction fetch stage?

    Answer:A loop buffer is a small, very-high speed memory maintained by the instruction fetch stage of the pipeline that contains the n most recently fetched instructions in sequence.

  62. Question:How does a loop buffer benefit instruction fetching in a pipeline?

    Answer:It allows instructions fetched in sequence to be available without the usual memory access time, and if a branch occurs to a target a few locations ahead, the target will already be in the buffer, improving speed especially for loops.

  63. Question:In what ways is a loop buffer similar to and different from an instruction cache?

    Answer:Similar: Both store instructions to improve fetch speed. Different: Loop buffer only retains sequential instructions and is much smaller and lower cost compared to a general instruction cache.

  64. Question:What are the two main categories of branch prediction techniques?

    Answer:Static branch prediction (which does not depend on execution history) and dynamic branch prediction (which depends on the execution history).

  65. Question:Give examples of static branch prediction methods.

    Answer:1. Predict never taken 2. Predict always taken 3. Predict by opcode of the conditional branch instruction.

  66. Question:Describe the 'predict never taken' static branch prediction approach.

    Answer:It assumes that a conditional branch will not be taken and always fetches the instructions sequentially.

  67. Question:Describe the 'predict always taken' static branch prediction approach and its rationale.

    Answer:It assumes that a conditional branch will always be taken, always fetching the target instruction. This approach is based on the analysis that more than 50% of the time, conditional branches are taken.

  68. Question:What does the 'predict by opcode' static branch prediction approach involve?

    Answer:The CPU decides whether a branch will be taken based on the opcode of the branch instruction, assuming some branch opcodes mean taken and others not. This can yield about 75% prediction accuracy.

  69. Question:What is the taken/not taken switch in branch prediction?

    Answer:It is a mechanism using 1 or more bits associated with each conditional branch instruction to reflect its recent history of being taken or not taken, helping the CPU make predictions on future occurrences.

  70. Question:How does using 1-bit history in the taken/not taken switch affect branch prediction accuracy?

    Answer:Using 1 bit records only the outcome of the previous execution, which may cause prediction errors twice during a loop: once on entering and once on exiting the loop.

  71. Question:What advantage does using 2 bits in the taken/not taken switch have over 1 bit?

    Answer:Using 2 bits records the last two executions or encodes state more robustly, reducing the number of mispredictions compared to a single bit history.

  72. Question:What is a branch history table and what key components does each entry contain?

    Answer:A branch history table is a small cache memory associated with the instruction fetch stage. Each entry contains: 1) address of the branch instruction, 2) history bits recording use-state, and 3) information about the target instruction (either target address or target instruction).

  73. Question:What is the trade-off between storing the target address versus the target instruction in the branch history table?

    Answer:Storing the target address results in a smaller table but causes greater instruction fetch time compared to storing the target instruction directly.

  74. Question:Explain how the 'predict never taken' strategy works in terms of instruction fetching and handling branches.

    Answer:The instruction fetch stage always fetches the next sequential instruction. If a branch is taken, the pipeline is flushed and fetching resumes from the branch target address.

  75. Question:How does the branch history table improve upon the 'predict never taken' strategy?

    Answer:Each prefetch triggers a lookup in the branch history table. If a match is found, prediction is made based on recorded history to decide fetching the next sequential or branch target instruction, updating the table entry after execution to improve accuracy.

  76. Question:What happens when a conditional branch instruction is not found in the branch history table?

    Answer:The next sequential address is used for fetching, and the branch instruction may be added to the table, replacing an existing entry.

  77. Question:What are the main stages of the Intel 80486 instruction pipeline?

    Answer:Fetch, Decode stage 1 (D1), Decode stage 2 (D2), Execute, and Write back.

  78. Question:What is the primary objective of the fetch stage in the Intel 80486 pipeline?

    Answer:To keep the prefetch buffers filled with new instruction data as soon as the old data have been consumed by the instruction decoder, operating independently from other stages.

  79. Question:What happens during the Decode stage 1 (D1) of the Intel 80486 pipeline?

    Answer:Opcode and addressing-mode information for 3 bytes of instruction is decoded, and the D1 decoder directs the D2 stage to capture the rest of the instruction.

  80. Question:What operations are performed during the Decode stage 2 (D2) of the Intel 80486 pipeline?

    Answer:Each opcode is expanded into control signals for the ALU and the D2 stage controls the computation of more complex addressing modes.

  81. Question:What occurs in the execute stage of the Intel 80486 pipeline?

    Answer:The execute stage performs ALU operations, cache access, and register updates.

  82. Question:What is the purpose of the write back stage in the Intel 80486 pipeline?

    Answer:It updates registers and status flags modified during the execute stage.