Computer Architecture

Hardware. CPU, cores, registers, ALU, control unit. Series of videos by crashcourse: youtube

65 flashcards · Computer Science · by lakesare

  1. What's the name of a digital circuit used to perform logic operations in CPU?

    ALU - Arithmetic logic unit.

  2. Most of the operations of a CPU are performed by one or more ALUs, which load data from input registers. A register is a small amount of storage available as part of a CPU.

    The control unit tells the ALU what operation to perform on that data, and the ALU stores the result in an output register. The control unit moves the data between these registers, the ALU, and memory.

  3. How are registers used in CPU?

    Results from ALU are written to a register for quick access by subsequent instructions. In some cases results may be written to slower, but higher capacity RAM.

  4. Name 2 CPU instruction set architectures.

    x86 and ARM.

  5. What's a clock rate?

    CPU circles a certain amount of times per second

  6. Sleep vs Hibernate vs Off modes?

    Sleep - keeps contents of RAM by leaving current in RAM running, drains just enough power for it. Hibernate - copies contents of RAM to some non-volatile storage, drains no power. Off - resets RAM, drains no power. Hibernated computer must start up and read data back to RAM, which is slower than recovering from Sleep.

  7. Name 2 types of files.

    text file - stored as a sequence of bytes. Each byte has an integer value that corresponds to some character, encoding is ASCII. binary file - everything else Files such as hello.c that consist exclusively of ASCII characters are known as text files. All other files are known as binary files.

  8. What's a bus?

    Physical connections (cables, printed circuits, etc.) between hardware components in order to communicate.

  9. What's word size?

    Number of bits processed by CPU in one go (these days, typically 32 bits or 64 bits). Word size could be as low as 4 bits or as high as 64 bits, depending on what a particular processor can handle. Links: word size term history

  10. What's a program counter?

    It's a register that holds the address of next instruction. At any point in time, program counter points at (contains the address of) some machine-language instruction in main memory. In most processors, the PC is incremented after fetching an instruction, and holds the memory address of ("points to") the next instruction that would be executed.

  11. Name 3 examples of CPU instructions.

    Load: copy a word from RAM into register. Store: copy a word from register to a location in RAM. Update: copy the contents of two registers to the ALU, which adds the two words together and stores the result in a register. I/O Read: copy a word from I/O device into register. I/O Write: copy a word from register to I/O device. Jump: extract a word from the instruction itself and copy that word into the program counter (PC), overwriting the previous value of the PC.

  12. What exactly do they mean by: processor main memory CPU frequency

    processor => CPU main memory => RAM CPU frequency => clock rate

  13. What's meant by controller?

    Controller is a hardware device that manages flow of data between two entities. (Controllers may be cards, microchips or separate hardware devices for the control of a peripheral device) Links: simple article

  14. What's a register file?

    Just a collection of registers.

  15. Must word size and memory cell size be equal?

    No. This means that a word is not necessarily stored in one memory cell. E.g., if a computer uses a 32-bit processor and an 8-bit memory, then the word size is 32 bits whereas the memory cell size is only 8 bits.

  16. What do they mean by 32 VS 64 bit processors?

    Size of the registers. Which means that: operations on larger number can be performed certain registers are used as pointers into your memory space and hence limits the maximum amount of memory that you can reference. A 32-bit processor can only reference 2^32 bytes (which is about 4 GB of data).

  17. Controller VS adapter?

    Difference is mainly in packaging. Controller is a chip set in the device or motherboard. Adapter is a card that plugs into a slot on the motherboard. Regardless, the purpose of each is to transfer information back and forth between the I/O bus and an I/O device.

  18. Name 2 things that are the same size as a word size!

    amount of bits register can hold amount of bits CPU can process at one go Majority of the registers in a processor are usually word sized and the largest piece of data that can be transferred to and from the working memory in a single operation is a word in many (not all) architectures.

  19. When is multiple CPU cores useful?

    When we are going to use a laptop to, e.g., play a game that was built to be parallelizable well, so that game process can be distributed among multiple cores. Ideally, a dual core processor would be nearly twice as powerful as a single core processor. In practice, the performance gain is far smaller, only about 50%, due to imperfect software algorithms and implementation.

  20. When we say dual-core, or quad-core - what exactly do we mean?

    Multiple CPUs. Kind of. Core VS CPU VS processor are very poorly defined terms. We can pretend that they mean the same thing. Some computers employ a multi-core processor, which is a single chip containing two or more CPUs called "cores".

  21. Scalar VS superscalar CPU?

    scalar: can execute at most one single instruction per clock cycle. superscalar: implements instruction-level parallelism within a single processor - can execute more than one instruction per clock cycle by simultaneously dispatching multiple instructions to different execution units on the processor.

  22. What's instruction set architecture (ISA)?

    ISA is basically an abstraction for a machine-code programmer over actual hardware. The underlying hardware is far more elaborate, executing multiple instructions in parallel, but always in a way that is consistent with the simple, sequential model.

  23. Both Intel and AMD chips can power Windows computers despite their different hardware, how?

    While their implementation (actual circuits laid out on the CPU) can be completely different, if they implement x86 instruction set, they'll be able to support Windows.

  24. What does ISA define?

    instructions set (opcodes and their meaning) endianness makes it seem like machine code is executed on a CPU that performs one instruction at a time Link to instruction set definition for x86 isa: http://ref.x86asm.net/coder32.html The Intel x86 and also AMD64 / x86-64 series of processors use the little-endian format

  25. Is assembly cross-platform?

    Assembly is the same for machines with the same ISA, however for every ISA you need to write an assembly with different syntaxes.

  26. Is assembly a machine language?

    No! Machine languages are directly executable by a computer's CPU of some ISA. They are typically formulated as bit patterns. Assembly languages let programmers use symbolic addresses, which the assembler converts to absolute addresses.

  27. What's a GPU?

    Graphics Processing Unit. Core designed to perform parallel operations on graphics data. It is used to encode and render 2D and 3D graphics as well as process video.

  28. What do CISC vs RISC stand for? Name an example of each.

    CISC = complex instruction set computer RISC = reduced instruction set computer Example of instruction set architectures: x86 - CISC ARM (Advanced RISC Machine) - RISC

  29. What's a PCB?

    PCB (Printed Circuit Board) electrically connects electronic components using conductive tracks (copper) on a non-conductive substrate. An idea of embedding wires in a flat surface was essential to creating computers of current sizes. Links: techquickie explanation

  30. Typically, all operations begin with the pulse of the clock. Thus, at the most fundamental level, the speed of a processor is dictated by the pulse frequency produced by the clock, measured in cycles per second, or Hertz (Hz).

    There is no direct correspondence between clock cycle and one instruction. Sometime multiple instructions can be run per one clock cycle, sometimes one instruction requires multiple clock cycles.

  31. Name 4 parts of the CPU.

    Control Unit ALU Register file Clock The control unit obtains data / instructions from memory Interprets / decodes the instructions into commands / signals Controls transfer of instructions and data in the CPU Coordinates the parts of the CPU

  32. What's a clock in circuits?

    It's a signal that alternates between high to low voltages. Crystal of quartz can be made to distort in an electric field by applying a voltage to it. When the field is removed, the quartz generates a voltage.

  33. When is a clock signal needed in a circuit?

    If it's a sequential circuit (output depends on present input, and on previous inputs) as opposed to combinational (output is a pure function of input). Clock signal ensures that changes across a sequential circuit are simultaneous.

  34. Name 3 steps in CPU instruction cycle.

    PC - program counter IR - instruction register Fetch Fetch instruction RAM address from PC, store it in IR Store address of next instruction to PC Decode In circuitry known as instruction decoder, instruction is converted into signals that control other parts of the CPU. The way in which the instruction is interpreted is defined by the CPU's ISA. In some CPUs instruction decoder is implemented as a hardwired, unchangeable circuit. Execute ALU inputs are connected to a pair of operand sources (n…

  35. What's a CPI?

    CPI (cycles per instruction) - average amount of clock cycles per one instruction. Links: NERDfirst on clock rate VS CPI

  36. Clock speed: 3.5 kHz. CPI: 4. Find amount of instructions executed by this computer in a second.

    This computer: emits 3.5*103 clock cycles per second executes 1/4 instructions per one clock cycle. x instructions/s = 3500cycles/s / 4cycles/instruction = 875 instructions/s (on average) [Yes, clock rate is sometimes referred to as clock speed]

  37. Name 5 internal (not accessed by users) registers.

    Instruction Register (IR): current instruction. Program Counter (PC): RAM address of the next instruction. Accumulator: register in which intermediate arithmetic and logic results are stored. Memory Address Register (MAR): has its output hooked up to the address bus. This register is going to be the only way for the CPU to communicate with the bus. Memory Data (Buffer) Register (MDR): like MAR, except for the Data bus. Links: MDR vs MAR

  38. Why straight comparison of clock speeds is not useful?

    Because we must also consider average amount of instructions per cycle. It may be augmented by smart ISA, by use of superscalar processor, or by pipelining, or by using multiple cores.

  39. Name 2 approaches (not techniques) to instruction-level parallelism.

    software - compiler decides which instructions to execute in || (static parallelism) hardware - processor decides at run time which instructions to execute in || (dynamic parallelism)

  40. Name 2 hardware techniques to achieve instruction-level parallelism.

    instruction pipelining superscalar execution

  41. What formula is used for measuring average CPI for a program?

    Weighted arithmetic mean: average CPI = sumi=type(CPIi * n_of_times_instruction_was_executedi) _______________ n_of_times_all_instructions_were_executed

  42. What would be the CPIaverage for running this program:

    CPIaverage = 1 * 0.6x + 2 * 0.18x + 4 * 0.12x + 8 * 0.1x _____________ x ≈ 178. E.g., instruction type 'branch' was executed 12% of all instruction executions.

  43. How do buses convey multiple bits at a time?

    There are 2 types of buses: parallel - convey multiple bits simultaneously, serial - convey one bit at a time. Both are used in modern PCs.

  44. Describe 4 types of inputs and outputs of an ALU.

    2 inputs for operands input for opcode output for result output for flags (or status) ALU is usually signified as a V.

  45. How many bits is one instruction?

    RISC: fixed length CISC: variable length A RISC instruction set normally has a fixed instruction length (often 4 bytes = 32 bits), whereas a typical CISC instruction set may have instructions of widely varying length (1 to 15 bytes for x86).

  46. Do instruction sets tend to be getting larger or smaller?

    Larger! If we didn't have a multiplication instruction, we'd have to use up many clock cycles in order to multiply two numbers. Using multiplication opcode we can just run this operation through circuit once. Also instructions are rarely getting rid of for backwards compatibility. (Grew from 46 instructions for early Intel into around 1000 for modern x86)

  47. What's it called when we need some RAM value, and find VS not find this value in our cache?

    We find it: cache hit We don't find it: cache miss Retrieval from RAM may take dozens of clock cycles to complete, and cache hit can usually be completed in one clock cycle.

  48. Name 2 ways CPU cache is used.

    when we execute some program - we store many instructions from RAM into cache, instead of going to RAM every time we need next instruction when we calculated something, and we need to store it in RAM - we can update cache instead

  49. What's a dirty bit?

    When we update cache instead of RAM, and our RAM and cache go forking, we mark updated cache's block by a dirty bit in order to know if we need to update RAM when we interact with it next time (then we'd just copypaste this cache block into RAM).

  50. Name 4 standard flags outputted from ALU.

    Zero - when all bits of output are zero. Negative - when output of an arithmetic operation is negative. Overflow - when result of an arithmetic operation has exceeded the numeric range of output. Carry-out - carry resulting from an addition operation, or borrow from subtraction. Links: carry vs overflow

  51. What's the accumulator register used for?

    Accumulator is used to store intermediate results from arithmetic/logic operations. Modern computer systems often have multiple general purpose registers that operate as accumulators, and the term is no longer as common as it once was.

  52. Name 3 buses connecting CPU+RAM+I/O devices.

    Control bus: carries commands from the CPU and returns status signals from the devices. Data bus: will contain actual data that has either just been read from memory or is about to be written to a memory location. A data bus is bi-directional, which means that information can either be written or read using the bus lines. Address bus: contains location information. Address bus is unidirectional and usually CPU writes location information on it of where data will be read from or written to. Addr…

  53. When should you check for carry-out VS overflow ALU's flag?

    Will indicate the result is wrong, if you get: Carry-out flag: if your program treats the bits as unsigned numbers. Overflow flag: if your program treats the bits as two's complement signed values. You don't care about the overflow flag when doing unsigned math. (The overflow flag is only relevant to signed numbers, not unsigned.) You don't care about the carry flag when doing signed, two's complement math. (The carry flag is only relevant to unsigned numbers, not signed.) It's up to you, the p…

  54. ALU can set, e.g., overflow flag, but not carry-out flag. How is it possible?

    In English, we may say "the binary/integer math overflowed the number of bits available for the result, causing the carry flag to come on". Note how this English usage of the verb "to overflow" is *not* the same as saying "the overflow flag is on". A math result can overflow (the verb) the number of bits available without turning on the ALU "overflow" flag.

  55. What are the rules for setting carry-out ALU flag?

    Carry flag is set: 1. if the addition of two numbers causes a carry-out of the most significant (leftmost) bits added. 1111 + 0001 = 0000 (carry flag is turned on) 2. if the subtraction of two numbers requires a borrow into the most significant (leftmost) bits subtracted. 0000 - 0001 = 1111 (carry flag is turned on) Otherwise, the carry flag is turned off (zero). * 0111 + 0001 = 1000 (carry flag is turned off) * 1000 - 0001 = 0111 (carry flag is turned off)

  56. What are the rules for setting overflow ALU flag?

    Overflow flag is set: 1. sign bit 1 + sign bit 1 = sign bit 0 (because positive + positive can't be negative) 0100 + 0100 = 1000 (overflow flag is turned on) 2. sign bit 0 + sign bit 0 = sign bit 1 (because negative + negative can't be positive) 1000 + 1000 = 0000 (overflow flag is turned on) Otherwise, the overflow flag is turned off. * 0100 + 0001 = 0101 (overflow flag is turned off) * 0110 + 1001 = 1111 (overflow flag is turned off) * 1000 + 0001 = 1001 (overflow flag is turned off) * 1100 +…

  57. What's a decoder circuit?

    Combinational circuit that takes N inputs, and selects one of 2N outputs. It's also common to have an enable input - it just makes all outputs inactive no matter what.

  58. What's meant by an address line in the address decoder?

    These 3 lines leading into address decoder, resulting in 23 RAM addresses.

  59. What's the maximum amount of RAM cells a computer can have if it has 3 address lines?

    23 = 8. The width of the address bus determines the amount of memory a system can address. For example, a system with a 32-bit address bus can address 232 memory locations. If each memory location holds one byte, the addressable memory space is 4 GB.

  60. Explain the process of reading an instruction from the main memory. (Your answer should mention the data bus, address bus and the read/write control line.)

    # TODO

  61. What's pipelining?

    A method for achieving instruction-level parallelism: doing decode while fetching the next instruction, etc. Suppose that there are three instructions A, B and C. Without pipelining, these three instructions would take 6 time units (supposing that fetch and execution takes one time unit each). But with pipelining, the three instructions will only take 4 time units.

  62. Name 5 steps in pipelining.

    1. IF: Instruction fetch from memory - we read the PC register, and fetch instruction from RAM 2. ID: Instruction decode & register read - 3. EX: Execute operation or calculate address 4. MEM: Access memory operand 5. WB: Write result back to register

  63. What's a hazard?

    Situations that prevent starting the next instruction in the next cycle. E.g., a read after write (RAW) data hazard refers to a situation where an instruction refers to a result that has not yet been calculated or retrieved: add $s0, $t0, $t1 sub $t2, $s0, $t3

  64. Name 2 ways to deal with pipeline hazards.

    pipeline stalls operand forwarding

  65. Name 2 types of pipeline hazards.

    data hazards: dependencies that go backward in time control hazards