1 / 102

Look what I found in the attic…

Look what I found in the attic…. Programming Fundamentals 4 Feliks Klu ź niak. Executive summary : We look at the principles of operation of a very simple computer. An A1 computer!. I/O devices. CPU. MEMORY. An A1 computer!. I/O devices. CPU.

alena
Download Presentation

Look what I found in the attic…

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Look what I found in the attic… Programming Fundamentals 4 Feliks Kluźniak Found in the attic

  2. Executive summary: We look at the principles of operation of a very simple computer. Found in the attic

  3. An A1 computer! I/O devices CPU MEMORY Found in the attic

  4. An A1 computer! I/O devices CPU This sort of architecture is obsolete now, but it is simple! MEMORY Found in the attic

  5. An A1 computer! I/O devices CPU CAVEAT: This presentation is somewhat simplified, don’t show it to electrical engineers.  This sort of architecture is obsolete now, but it is simple! MEMORY Found in the attic

  6. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: . . . Found in the attic

  7. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: An address has 16 bits, so there are at most how many words? . . . Found in the attic

  8. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: An address has 16 bits, so there are at most 2**16 = 65536 words. . . . Found in the attic

  9. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: An address has 16 bits, so there are at most 2**16 = 65536 words. It’s easier to count it in terms of “kilos”, where 1 K = 2**10 = 1024. So we may have upto how many kilo words? . . . Found in the attic

  10. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: An address has 16 bits, so there are at most 2**16 = 65536 words. It’s easier to count it in terms of “kilos”, where 1 K = 2**10 = 1024. So we may have upto 64kilo words. . . . Found in the attic

  11. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: An address has 16 bits, so there are at most 2**16 = 65536 words. It’s easier to count it in terms of “kilos”, where 1 K = 2**10 = 1024. So we may have upto 64kilo words. Or 160KB(kilo bytes). . . . Found in the attic

  12. Memory: Each word has 20 bits Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … at most 1111111111111111: An address has 16 bits, so there are at most 2**16 = 65536 words. It’s easier to count it in terms of “kilos”, where 1 K = 2**10 = 1024. So we may have upto 64kilo words. Or 160 KB (kilo bytes). This is the size of the address space. But our actual machine has only 8 K words (40 KB). . . . Found in the attic

  13. Memory: Each word has 20 bits This is random access memory. Each word has an address, and each particular word can be accessed in essentially constant time. Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … . . . Found in the attic

  14. Memory: Each word has 20 bits This is random access memory. Each word has an address, and each particular word can be accessed in essentially constant time. “Random access” does not mean we access words randomly, but that accessing them in random order is as efficient as accessing them in sequence. Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … . . . Found in the attic

  15. Memory: Each word has 20 bits This is random access memory. Each word has an address, and each particular word can be accessed in essentially constant time. This main memory is often called core memory. Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … . . . Found in the attic

  16. Core memory: 1 ferrite core = 1 bit Found in the attic

  17. Found in the attic

  18. Found in the attic

  19. Times have changed… Found in the attic

  20. Found in the attic

  21. Memory: Each word has 20 bits The core memory holds data and programs. Programs are encoded as binary integers. Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … . . . Found in the attic

  22. Memory: Each word has 20 bits The core memory holds data and programs. Programs are encoded as binary integers. In order to execute a program we must place it in core memory. “execute” = “run” Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … . . . Found in the attic

  23. Memory: Each word has 20 bits The core memory holds data and programs. Programs are encoded as binary integers. In order to execute a program we must place it in core memory. (We will soon see how.) Addresses: 0000000000000000: 0000000000000001: 0000000000000010: 0000000000000011: … . . . Found in the attic

  24. The CPU has access to three registers which are its interface to the memory: Found in the attic

  25. The CPU has access to three registers which are its interface to the memory: A register is a short sequence of bits (about one word) which is held in fast electronic circuits and often can be manipulated in various ways. Found in the attic

  26. The CPU has access to three registers which are its interface to the memory: Roughly speaking: that which allows two entities to interact. Found in the attic

  27. The CPU has access to three registers which are its interface to the memory: • The Memory Address: MA (16 bits) Found in the attic

  28. The CPU has access to three registers which are its interface to the memory: • The Memory Address: MA (16 bits) • The Memory Register: MR (20 bits, i.e., one word) Found in the attic

  29. The CPU has access to three registers which are its interface to the memory: • The Memory Address: MA (16 bits) • The Memory Register: MR (20 bits, i.e., one word) • The Write flag: W (1 bit) Found in the attic

  30. The CPU has access to three registers which are its interface to the memory: • The Memory Address: MA (16 bits) • The Memory Register: MR (20 bits, i.e., one word) • The Write flag: W (1 bit) CPU MR MMRR W MA Memory Found in the attic

  31. To read from memory, the processor (CPU) sets W to zero, and MA to an address. The memory will place the contents of the addressed word in MR. CPU MR MMRR 0 MA Memory Found in the attic

  32. To read from memory, the processor (CPU) sets W to zero, and MA to an address. The memory will place the contents of the addressed word in MR. MR := m[ MA ] CPU MR MMRR 0 MA Memory Found in the attic

  33. To write to memory, the CPU fills MR with some contents, sets W to 1 and MA to an address. The memory will place the contents of MR at that address. CPU MR MMRR 1 MA Memory Found in the attic

  34. To write to memory, the CPU fills MR with some contents, sets W to 1 and MA to an address. The memory will place the contents of MR at that address (the old contents of the word at that address will disappear!). m [ MA ] := MR CPU MR MMRR 1 MA Memory Found in the attic

  35. The CPU has access to three registers which are its interface to the memory: • The Memory Address: MA (16 bits) • The Memory Register: MR (20 bits, i.e., one word) • The Write flag: W (1 bit) These three registers are ``hidden’’ from the programmer: she cannot manipulate them directly. CPU MR MMRR W MA Memory Found in the attic

  36. Inside the CPU there are three registers: Found in the attic

  37. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) Found in the attic

  38. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) Found in the attic

  39. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) Found in the attic

  40. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • On less ancient machines there are more registers. • But the IR and IC are always there. Found in the attic

  41. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • On less ancient machines there are more registers. • But the IR and IC are always there. • IR is “hidden” from the programmer. • IC and A can be manipulated, the former somewhat • indirectly. • This will all become more clear presently. Found in the attic

  42. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • A program is composed of one-word instructions. Found in the attic

  43. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • A program is composed of one-word instructions. • The instruction counter (IC) holds the address of the next instruction to be executed. Found in the attic

  44. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • A program is composed of one-word instructions. • The instruction counter (IC) holds the address of the next instruction to be executed. • The instruction register (IR) holds the instruction that is being executed. Found in the attic

  45. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • A program is composed of one-word instructions. • The instruction counter (IC) holds the address of the next instruction to be executed. • The instruction register (IR) holds the instruction that is being executed. Here is the format of an instruction: • opcode operand • 4 bits 16 bits Found in the attic

  46. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • A program is composed of one-word instructions. • The instruction counter (IC) holds the address of the next instruction to be executed. • The instruction register (IR) holds the instruction that is being executed. Here is the format of an instruction: • opcode operand Other machines have • 4 bits 16 bits other formats. Found in the attic

  47. Inside the CPU there are three registers: • The instruction register: IR (20 bits, i.e., one word) • The instruction counter: IC (16 bits, i.e., an address) • The accumulator: A (20 bits, i.e., one word) • A program is composed of one-word instructions. • The instruction counter (IC) holds the address of the next instruction to be executed. • The instruction register (IR) holds the instruction that is being executed. Here is the format of an instruction: • opcode operand • 4 bits 16 bits The bits in the opcode activate various circuits. Essentially, opcode = kind of instruction. Found in the attic

  48. opcode operand 4 bits 16 bits For example: opcode = 1 : store the contents of A , the operand is the address m[ operand ] := A Found in the attic

  49. opcode operand 4 bits 16 bits For example: opcode = 1 : store the contents of A , the operand is the address m[ operand ] := A In other words, the contents of the accumulator is copied to the memory word indicated by the operand (the contents of the accumulator remain the same). Found in the attic

  50. opcode operand 4 bits 16 bits For example: opcode = 1 : store the contents of A , the operand is the address m[ operand ] := A In other words, the contents of the accumulator is copied to the memory word indicated by the operand (the contents of the accumulator remain the same). The word “store” is justified by the fact that the memory used to be called “the store”. Found in the attic

More Related