Basic Components

The instruction _is the smallest piece of work specified in a computer program.
The von Neumann model consists of five parts : _memory, a processing unit, input, output and a control unit.

image.png :::info

Memory

MAR, memory’s address register
MDR, memory’s data register
The value stored in the location can be changed, but the location’s memory address remains unchanged.
Address space of LC-3 is 216 memory locations and LC-3 is 16-bit addressable.
TO READ / LOAD

  1. Load the address of the location in MAR.
  2. Interrogate the memory.
  3. The information stored in the corresponding location will be loaded in MDR.

TO WRITE / STORE

  1. Write the address of the memory location in the MAR and the value to be stored in the MDR.
  2. Interrogate the memory with the WE signal asserted.
  3. The information in the MDR will be stored into the corresponding location. :::

    Processing Unit

    Computation Unit

    ALU arithmetic and logic unit The ALU processes data elements of a fixed size referred to as the word length. The data elements are called words. Each ISA has its own word length. LC-3 has a word length of 16-bits. Temporary Storage The most common form of temporary storage is a set of registers

x86 microarchitectures have 8 registers. Some have 256 registers.

:::info

Input and Output

or say peripherals
In our course, we only use one input device keyboard and one output device monitor. :::

Control Unit

instruction register contain the instruction to be executed PC, program counter or say_ instruction counter, _contains the next instruction’s address to keep track of which instrcutions is to be processed next. finite state machine

Instruction Processing

Instruction

There are fundamentally 3 kinds of instructions : operates, data movement and control.
Operate instructions operate the data. e.g. ADD and AND.
Data movement instructions move information from the processing unit to and from memory and to and from input/output devices. e.g. LD and ST.
Control instructions alter the sequential processing of instrcution. e.g. BR

An LC-3 instruction consists of 16 bits (one word).
Bits [15:12] contain the opcode. Bits [11:0] are used to figure out where the operands are.

ADD

Opcode Chapter 4 The von Neumann Model - 图3 Operand

  • Chapter 4 The von Neumann Model - 图4 DR (for destination register)
  • Chapter 4 The von Neumann Model - 图5 SR1 (for source register 1)
  • Chapter 4 The von Neumann Model - 图6 Signification digit
    • register if its value is0,
      the second operands is the value in SR2 specified by bitsChapter 4 The von Neumann Model - 图7.
      Chapter 4 The von Neumann Model - 图8must be 0.
    • immediate / literal if its value is 1,
      the second operand is obtained by sign-extending bitsChapter 4 The von Neumann Model - 图9to 16 bits.

FUNTION Chapter 4 The von Neumann Model - 图10 Condition Codes ✓ based on whether the result is negative, zero, or positive. image.png

AND

Opcode Chapter 4 The von Neumann Model - 图12 Operand

  • Chapter 4 The von Neumann Model - 图13 DR
  • Chapter 4 The von Neumann Model - 图14 SR1
  • Chapter 4 The von Neumann Model - 图15 Signification digit
    • register if its value is0,
      the second operands is the value in SR2 specified by bitsChapter 4 The von Neumann Model - 图16.
      Chapter 4 The von Neumann Model - 图17must be 0.
    • immediate / literal if its value is 1,
      the second operand is obtained by sign-extending bitsChapter 4 The von Neumann Model - 图18to 16 bits.

FUNTION Chapter 4 The von Neumann Model - 图19 Condition Codes ✓ based on whether the result is negative, zero, or positive. image.png

LD

Opcode Chapter 4 The von Neumann Model - 图21 Operand

  • Chapter 4 The von Neumann Model - 图22 DR
  • Chapter 4 The von Neumann Model - 图23 PCoffset PC-Relative Mode

FUNTION
Chapter 4 The von Neumann Model - 图24 Condition Codes ✓ based on whether the value loaded is negative, zero, or positive. image.png

BR

Opcode Chapter 4 The von Neumann Model - 图26 Operand

  • Chapter 4 The von Neumann Model - 图27 n, z, p (negative, zero, positive)
    • if bitsChapter 4 The von Neumann Model - 图28is 1, N is tested
    • if bitsChapter 4 The von Neumann Model - 图29is 1, Z is tested
    • if bitsChapter 4 The von Neumann Model - 图30is 1, P is tested

if any of the condition code tested is 1, the PC is loaded with the following address.

  • Chapter 4 The von Neumann Model - 图31 PCoffset PC-Relative Mode

FUNTION
Chapter 4 The von Neumann Model - 图32 Condition Codes ✗ image.png

Instruction Cycle

Instruction Cycle the entire sequence of steps needed to process an instruction
It consists of six sequential phases.
Every instruction consists FETCH and DECODE, but NOT all phases are needed for all instructions.
e.g. LD skips phase EXECUTE, ADD skips phase EVALUATE ADDRESS and FETCH OPERANDS.

1. FETCH

At least THREE clock cycles to complete. ( Depend on the memory speed )

  1. MAR is loaded with the contents of the PC, and simultaneously increment PC.
  2. The memory is interrogated. ( the next instruction specified by MAR is placed into MDR)
  3. IR is loaded with the contents of MDR

    2. DECODE

    It examines the instruction to figure out what the microarchitecture is being asked to do.

    3. EVALUATE ADDRESS

    It happens EITHER when it loads data from memory to register OR when it stores data from register to memory. It computes the address of the memory location that is needed to process the instruction.

    4. FETCH OPERANDS

    It obtains the source operands needed to process the instruction.

    5. EXECUTE

    It carries out the execution of the instruction.

    6. STORE RESULT

    The result is written to its desinated destination.

Control of the Instruction Cycle

The instruction cycle is controlled by a synchronous finite state machine.

image.png

Halting the Computer (TRAP x25)

:::warning Stopping the instruction cycle requires stopping the clock.
The clock generator is a crystal oscillator.
Considering the following circuiut, stoppoing the instruction cycle only clearing the RUN latch. ::: image.png