Salta al contenuto
Note per Studenti CPU Structure and Registers Report

CPU Structure and Registers

In questa pagina 7
In questa pagina 4

Architecture and organization

Definition (architecture and organization).

Architecture Organization
What it is attributes visible to the programmer that affect the logical execution of a program the operational units and their interconnections that implement the architecture
Examples instruction set, data width, addressing modes, I/O mechanisms control signals, memory technology, peripheral interfaces, circuits used
Typical question is there a multiply instruction? is multiplication done by a dedicated circuit or by repeated additions?

A processor family shares one architecture with different organizations (faster or cheaper): a program written for one model runs on the others. Backward compatibility weighs heavily on design choices (x86 from the late 1970s to today). A microcontroller or a DSP is a processor core plus memory and peripherals on one chip; what follows describes the core.

Stored-program (von Neumann) machine

Definition (von Neumann machine). Early machines were programmed by rewiring (hardwired program). The von Neumann idea is a general hardware that performs different operations according to the control signals it receives, with these commands written as instructions stored in memory together with the data.

  1. data and instructions share the same memory, readable and writable;
  2. memory is addressed by position, regardless of content;
  3. instructions execute in sequence, unless an explicit jump occurs.

Example. In the IAS machine a 40-bit word holds two 20-bit instructions (8-bit opcode + 12-bit address): 212=4096≥10002^{12}=4096\ge1000 words are all addressable.

The separate-memory alternative is the Harvard architecture (distinct instruction and data memories/buses). It is used today, for example, for the L1 instruction and data caches.

Internal components

The CPU must fetch instructions, interpret them, fetch data, process them and write results (see Fetch-Execute Cycle and DatapathThe registers PC, IR, MAR and MBR, the fetch and execute phases and the four kinds of action, the full instruction-cycle state diagram with interrupt check, a worked accumulator-machine example, and the datapath of a simple RISC core with single-cycle and multicycle timing.Fetch-Execute Cycle and Datapath →). It needs a small, very fast internal memory: the registers. Components:

User-visible registers

The "programmer" is whoever writes assembly, or the compiler.

Type Use
general purpose operands, results, addresses
data data only (in some architectures)
address pointers: segment base registers, index registers, stack pointer
condition codes (flags) bits set by the ALU, read by conditional instructions

Property (number of registers and instruction bits). More registers mean fewer memory accesses, but more instruction bits to name them (log⁡216=4\log_2 16=4 bits per operand with 16 registers, 55 with 32) and more state to save at every call or interrupt. RISC machines typically have 16-32 registers (Instruction Set ArchitectureWhat an instruction set defines, the elements of an instruction, operand and operation types, 0-, 1-, 2- and 3-address machines on the same calculation, load/store architectures, and the RISC and CISC design philosophies with register windows and register allocation by graph coloring.Instruction Set Architecture →); 32-bit ARM has 16, MIPS 32.

Example: evaluating (a+b)⋅(c+d)−(e+f)(a+b)\cdot(c+d)-(e+f) with variables in memory. With 6 free registers each variable is loaded once; with 4 registers some intermediate results must be saved to memory and reloaded, giving more loads and stores.

Property (register width and address space). Address registers must hold a whole address: 32-bit registers address 2322^{32} bytes =4=4 GB, 64-bit registers 2642^{64}.

Control and status registers

Usually not directly accessible: PC, IR, MAR, MBR (defined in Fetch-Execute Cycle and DatapathThe registers PC, IR, MAR and MBR, the fetch and execute phases and the four kinds of action, the full instruction-cycle state diagram with interrupt check, a worked accumulator-machine example, and the datapath of a simple RISC core with single-cycle and multicycle timing.Fetch-Execute Cycle and Datapath →) and the program status word (PSW; called CPSR in ARM).

Definition (PSW). Typical contents:

Example. At 8 bits in two's complement, 127+1=1000 0000127+1=1000\,0000 gives N=1N=1, Z=0Z=0, C=0C=0, V=1V=1.

Segmentation

In some architectures (x86) memory is logically divided into segments (code, data, stack). Addresses within a segment start from 0 (logical address); the linear address is the segment base, held in a segment register, plus the logical address. ARM and MIPS use a linear address space, with protection left to virtual memory.

Common mistakes

  • Treating the PC as a general register: in MIPS it is not; in ARM it is r15, and writing to it is a jump.
  • Thinking a user program can change the supervisor bit: only an interrupt or an operating-system call changes it.
  • Calling the memory technology or the adder type "architecture": these are organization choices.
  • Thinking von Neumann means "separate program memory": it is the opposite (separation is Harvard).

Versione ripasso

Architecture = what the programmer sees (ISA, data width, addressing modes, I/O); organization = how it is built (control signals, memory technology, circuits). A family shares the architecture.

Stored program

von Neumann: instructions and data in the same memory, addressed by position, executed in sequence unless jumped. Harvard: separate instruction and data memories (used today for L1 caches).

Components

ALU (Arithmetic Logic UnitRole of the ALU, its inputs and the N Z C V flags, the 1-bit ALU built from AND, OR, a full adder and a multiplexer, the N-bit ALU with subtraction, NOR, set-less-than, zero and overflow detection, comparators, bus sharing with tri-state outputs, and the other computation units.Arithmetic Logic Unit →), control unit (Hardwired and Microprogrammed ControlWhat the control unit does, control signals of a single-cycle datapath with the table for each instruction class, hardwired control (combinational or finite-state machine), microprogrammed control (control memory, horizontal and vertical microinstructions, microsequencer), and a comparison.Hardwired and Microprogrammed Control →), register file, internal bus; see Fetch-Execute Cycle and DatapathThe registers PC, IR, MAR and MBR, the fetch and execute phases and the four kinds of action, the full instruction-cycle state diagram with interrupt check, a worked accumulator-machine example, and the datapath of a simple RISC core with single-cycle and multicycle timing.Fetch-Execute Cycle and Datapath →.

Registers

Segmentation

x86: linear address = segment base + logical address. ARM and MIPS: linear space.

Common mistakes: the PC is not a general register (ARM r15: writing it is a jump); only an interrupt or system call changes the supervisor bit.

Teoria collegata