Salta al contenuto
Note per Studenti Microcontrollers and DSP - Mock Exam 3 Report

Microcontrollers and DSP - Mock Exam 3

Questa pagina non ha ancora la versione ripasso: qui sotto c'è il testo completo.

In questa pagina 8

The written test of this course is described in the course sheet as a written test with some theory questions and some application exercises (programming of microcontrollers and peripherals, DSP), with a possible additional oral exam: this part is official. No past tests are public, so this mock exam is built only on the notes of the course. The split into 4 theory questions worth 3 points each and 3 exercises worth 6 points each (total 30 points) and the time of 2 hours are a proposal of this site. The questions and the data are new: they are not a copy of any real test. The notes of the course contain no sections on DSP and no register-level description of the peripherals, so the exercises use the instruction formats, the ARM assembly and the semiconductor memories that the notes do describe.

Conventions: numbers written with the prefix 0x are hexadecimal; memory is byte-addressed and a word has 44 bytes; the ARM syntax is the one of the notes (comments after @).

How to use it: work with a timer, write the formula or the idea in words before the numbers, and look at the "Result" only when a question is finished.

Question 1 (points 3)

(a) List the registers PC, IR, MAR, MBR and AC of a simple machine and say what each one holds. (b) Describe the path of a load instruction (lw rt, off(rs)) through the datapath of a simple RISC core and say why it is the longest instruction. (c) Which multiplexers are needed and what does each one choose?

Show the result
  • PC: address of the next instruction; IR: instruction being executed; MAR: address sent to memory; MBR: datum read from or written to memory; AC: operand and result in accumulator machines.
  • Load: read rs, ALU computes rs + sext(off), data memory read, write rt.
  • It is the longest because it uses all the elements of the datapath.
  • Multiplexers: ALUSrc (rt or extended immediate), MemtoReg (ALU result or memory data), RegDst (rd or rt), PCSrc (PC + 4 or branch target, Branch AND Zero).
Show the full solution

PC holds the address of the next instruction, IR the instruction being executed, MAR the address sent to memory on the address bus, MBR the datum read from or to be written to memory, AC the operand and result in accumulator machines (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 →). In a load the register rs is read, the ALU computes rs + sext(off), the data memory is read and the datum is written into rt. The load is the longest instruction because it uses all the elements of the datapath. The multiplexers choose: the second ALU input, register rt or the extended immediate (ALUSrc); the data written back, ALU result or memory data (MemtoReg); the destination register, rd or rt (RegDst); the new PC, PC + 4 or the branch target (PCSrc, that is Branch AND Zero).

Typical mistakes: confusing PC with IR; forgetting the sign extension of the offset, which goes from 16 to 32 bits; saying that the load does not use the ALU.

Question 2 (points 3)

(a) What does "number of addresses" of an instruction mean? Distinguish the 33-address and the 22-address forms. (b) Write the statement X=(B⋅C+D)/(E−F)X=(B\cdot C+D)/(E-F), with all the variables in memory, with 33-address instructions and with 11-address instructions (accumulator), and count the instructions of each program. (c) What is the general trade-off when the number of addresses decreases, and which form do RISC architectures use?

Show the result
  • Number of addresses: how many explicit operands an arithmetic instruction has; 33 addresses OP dest, src1, src2; 22 addresses OP dest, src with the destination also first operand.
  • 33 addresses: MUL T, B, C; ADD T, T, D; SUB X, E, F; DIV X, T, X: 44 instructions.
  • 11 address: LOAD E; SUB F; STOR X; LOAD B; MUL C; ADD D; DIV X; STOR X: 88 instructions.
  • Fewer addresses: shorter instructions but more numerous; RISC uses 33 register addresses.
Show the full solution

The number of addresses is how many explicit operands an arithmetic instruction has (see 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 →). With 33 addresses, SUB Y, A, B names the destination and the two sources; with 22 addresses, SUB A, B has the destination coinciding with the first operand. For X=(B⋅C+D)/(E−F)X=(B\cdot C+D)/(E-F) the 33-address program is MUL T, B, C, ADD T, T, D, SUB X, E, F, DIV X, T, X: 44 instructions. The 11-address program uses the implicit accumulator: LOAD E, SUB F, STOR X, LOAD B, MUL C, ADD D, DIV X, STOR X: 88 instructions. Fewer addresses make each instruction shorter but the instructions more numerous. RISC architectures use 33 register addresses.

Typical mistakes: believing that fewer addresses give a shorter program, when the instructions are shorter but more numerous; forgetting the STOR of the intermediate result in the accumulator form; writing a 33-address instruction with only two operands.

Question 3 (points 3)

(a) List the 1616 visible registers of the 32-bit ARM core, grouped by role. (b) What does a read of r15 give? (c) What does the CPSR contain, and what happens to some registers when the processor enters an exception mode?

Show the result
  • r0-r3 arguments, return value, temporaries; r4-r11 variables (preserved by called functions); r12 IP temporary; r13 SP; r14 LR; r15 PC.
  • Reading r15 gives the address of the current instruction plus 88.
  • CPSR: flags N, Z, C, V in bits 3131-2828, interrupt-disable bits, bits of the current mode.
  • Entering an exception mode: at least SP and LR are replaced by private (banked) copies, the CPSR is saved into the SPSR of the mode.
Show the full solution

The 32-bit ARM core has 1616 visible 3232-bit registers (see The ARM Core ArchitectureThe 32-bit ARM core as the reference microcontroller core: registers r0-r15 with SP, LR and PC, the status register CPSR with flags NZCV, processor modes, the load/store model, conditional execution, the flexible second operand, Thumb, and the main differences of 64-bit ARMv8.The ARM Core Architecture →). r0-r3 hold the arguments and the return value of functions and temporaries; r4-r11 hold variables and must be preserved by the called functions; r12 (IP) is a temporary; r13 is the stack pointer SP, r14 the link register LR, which holds the return address after BL, and r15 is the program counter PC. Reading r15 gives the address of the current instruction plus 88, an effect of the original 33-stage pipeline. The CPSR holds the flags N, Z, C, V in bits 3131-2828, the interrupt-disable bits and the bits of the current mode. On entering an exception mode at least SP and LR are replaced by private (banked) copies and the CPSR is saved into the SPSR of that mode.

Typical mistakes: using r13-r15 as ordinary registers; believing that r15 gives the address of the instruction being executed; expecting ADD to update the flags.

Question 4 (points 3)

(a) Why does a single bus with many devices become a bottleneck, and how is a bus hierarchy organised? (b) What is the role of the bridge? (c) How did the I/O module evolve beyond the DMA module, and what do disk, network and GPU controllers do today?

Show the result
  • Single bus with many devices: propagation delay and contention grow, the bus is the bottleneck.
  • Hierarchy: local bus CPU-cache, system bus to main memory, expansion bus for I/O.
  • Bridge: interface acting as a buffer, slow peripherals do not slow down the CPU-memory traffic.
  • I/O channel: a processor with its own instruction set executing I/O programs in memory without CPU intervention; then an I/O processor with local memory.
  • Today controllers have their own DMA (bus mastering on PCI Express).
Show the full solution

With many devices on a single bus, propagation delay and contention grow and the bus becomes the bottleneck (see Buses and InterconnectionThe system bus divided into data, address and control lines; bus width and address space; arbitration; single bus and bus hierarchies; synchronous and asynchronous timing; point-to-point interconnections.Buses and Interconnection →). The solution is a bus hierarchy: a local bus between CPU and cache, a system bus between cache or controller and main memory, and an expansion bus for I/O. The expansion bus is connected through an interface, the bridge, which acts as a buffer: slow peripherals do not slow down the CPU-memory traffic. The I/O module evolved later (see Direct Memory AccessThe DMA module and the information it receives from the CPU; block transfer with a single final interrupt; cycle stealing and burst mode, points where the CPU may be suspended; bus configurations; channels and I/O processors; quantitative comparison with interrupt-driven I/O.Direct Memory Access →): first an I/O channel, a processor with its own instruction set that executes I/O programs in memory without CPU intervention, then a true I/O processor with a local memory. Today disk, network and GPU controllers have their own DMA, with bus mastering on PCI Express.

Typical mistakes: saying that the bridge makes the CPU faster instead of acting as a buffer; thinking that an I/O channel needs the CPU for every word; putting the I/O devices on the local bus.

Exercise 1 (points 6)

Addressing modes and instruction formats (Instruction Formats and Addressing ModesAddressing modes (immediate, direct, indirect, register, register indirect, displacement, PC-relative, scaled indexed, stack) with effective address and a numeric example, fixed versus variable instruction formats, the MIPS R, I and J formats and the 32-bit ARM data-processing format with the encodable-constant rule.Instruction Formats and Addressing Modes →).

a) The memory contains M[120]=340M[120]=340, M[340]=560M[340]=560, M[460]=700M[460]=700, M[560]=910M[560]=910 (decimal addresses and values) and the register R2R2 contains 340340. An instruction has address field A=120A=120. Give the operand for the immediate, direct, indirect, register (R2R2), register indirect (R2R2) and displacement (R2+AR2+A) modes, and the number of memory accesses needed for the operand in each mode. Then compute the effective address of a scaled-index access with Rb=8192R_b=8192, Ri=5R_i=5, s=4s=4, A=8A=8. (2 points)

b) In MIPS the instruction lw $8, 0x1200($9) has format I. Give the width of each field, the value of the immediate in decimal and the effective address if the register $9 contains 0x00400000. What changes if the offset is −8-8 (16-bit pattern 0xFFF8)? A format J instruction has the 2626-bit field 0x1000003: give the byte address that it denotes and explain the multiplication. (2 points)

c) A beq is at address 0x00400020. Compute the branch target (taken) for an offset field of −6-6 and for +10+10. What would the target be for −6-6 if the programmer forgot the advanced PC? How far, in bytes, can a branch with a 1616-bit offset reach in each direction? (2 points)

Show the result

a) Immediate 120120 (no memory access); direct M[120]=340M[120]=340 (1 access); indirect M[M[120]]=M[340]=560M[M[120]]=M[340]=560 (2 accesses); register 340340 (none); register indirect M[340]=560M[340]=560 (1 access); displacement M[340+120]=M[460]=700M[340+120]=M[460]=700 (1 access). Scaled index: 8192+5⋅4+8=82208192+5\cdot4+8=8220.

b) Fields: op 66, rs 55, rt 55, immediate 1616 bits. Immediate 0x1200=46080\text{x}1200=4608; effective address 0x00401200. Offset −8-8: the pattern 0xFFF8 is sign-extended to 0xFFFFFFF8, so the address is 0x00400000 - 8 = 0x003FFFF8. Format J: op 66, address 2626 bits; the address is a word address, multiplied by 44 (shift left by 22): 0x1000003 times 44 gives 0x400000C.

c) Target =PC+4+4⋅off=\text{PC}+4+4\cdot\text{off}: for −6-6: 0x0040000C; for +10+10: 0x0040004C. Without the +4+4 the target for −6-6 would be 0x00400008. Reach: offset from −215-2^{15} to 215−12^{15}-1 instructions, that is from −131 072-131\,072 to +131 068+131\,068 bytes around PC + 4.

Show the full solution

a) Effective addresses (see the table of the modes in the notes). The notation is AA for the address field, RR for the named register and (X)(X) for the content of XX.

  • Immediate: the operand is AA itself, 120120; no memory access.
  • Direct: the operand is (A)=M[120]=340(A)=M[120]=340; EA =A=A; one access.
  • Indirect: the operand is ((A))((A)): first M[120]=340M[120]=340 is the address, then M[340]=560M[340]=560; two memory accesses.
  • Register: the operand is (R2)=340(R2)=340; no memory access.
  • Register indirect: EA =(R2)=340=(R2)=340, operand M[340]=560M[340]=560; one access (the register must have been loaded first).
  • Displacement: EA =(R2)+A=340+120=460=(R2)+A=340+120=460, operand M[460]=700M[460]=700; one access, plus the addition.

Scaled index: EA =(Rb)+(Ri)⋅s+A=8192+5⋅4+8=8220=(R_b)+(R_i)\cdot s+A=8192+5\cdot4+8=8220 (in hexadecimal 0x201C). Typical mistake: confusing direct and immediate addressing: in the direct mode the field is an address, in the immediate mode it is the value.

b) Format I and J. In format I the fields are op (66 bits), rs (55), rt (55) and the 1616-bit immediate: 6+5+5+16=326+5+5+16=32 bits. In lw $8, 0x1200($9) the base register $9 goes in rs, the destination $8 in rt, as in the datapath lw rt, off(rs), and the immediate is 0x1200=1⋅4096+2⋅256=46080\text{x}1200=1\cdot4096+2\cdot256=4608. The effective address is (\9)+4608=0\text{x}00400000+0\text{x}1200=0\text{x}00401200$.

With the offset −8-8 the 1616-bit pattern is 0xFFF8; the immediate is sign-extended to 3232 bits, 0xFFFFFFF8, which is −8-8, so the address is 0x00400000−8=0x003FFFF80\text{x}00400000-8=0\text{x}003FFFF8. Extending with zeros (0x0000FFF8) would give +65 528+65\,528: wrong. Typical mistake: forgetting the sign extension of the immediate in negative displacements.

In format J the fields are op (66 bits) and address (2626 bits). The address is a word address: instructions are 44-byte aligned, so the byte address is obtained by multiplying by 44, that is a left shift by 22: 0x1000003 ⋅4=0x400000C\cdot4=0\text{x}400000C (a 2828-bit byte address).

c) Branch target. The PC is already advanced in the fetch, so the target is relative to PC + 4 and the offset counts instructions of 44 bytes (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 →): target=PC+4+4⋅off\text{target}=\text{PC}+4+4\cdot\text{off}. For off=−6\text{off}=-6: 0x00400020+4−24=0x0040000C0\text{x}00400020+4-24=0\text{x}0040000C, a backward branch. For off=+10\text{off}=+10: 0x00400020+4+40=0x0040004C0\text{x}00400020+4+40=0\text{x}0040004C. If the +4+4 is forgotten the target for −6-6 would be 0x00400020−24=0x004000080\text{x}00400020-24=0\text{x}00400008, four bytes too low. Typical mistake: forgetting that a branch target is relative to PC + 4.

The 1616-bit offset is signed, from −215-2^{15} to 215−12^{15}-1 instructions; in bytes, multiplying by 44, from −131 072-131\,072 to +131 068+131\,068 around PC + 4.

Exercise 2 (points 6)

ARM loads and stores (ARM Memory-Access InstructionsLDR and STR for words, bytes and half-words with and without sign; addressing modes with immediate or scaled-register offset, pre-indexed with write-back and post-indexed, with effective address examples; loading addresses and constants; LDM and STM.ARM Memory-Access Instructions →). The word array aa starts at address 0x2000 and contains (decimal values) a[0]=7a[0]=7, a[1]=−3a[1]=-3, a[2]=12a[2]=12, a[3]=5a[3]=5, a[4]=9a[4]=9.

a) The register r1 contains 0x2000 and the following code is executed.

armasm
        MOV  r2, #0
        MOV  r3, #4
loop:   LDR  r0, [r1], #4
        ADD  r2, r2, r0
        SUBS r3, r3, #1
        BNE  loop

Give, for each iteration, the address read and the value loaded in r0, then the final values of r2 and r1. Then replace the LDR instruction with LDR r0, [r1, #4]! and answer again. (2 points)

b) The byte at address 0x3000 contains 0xC8, and the half-word at address 0x3002 contains 0x8123. With r4 = 0x3000, give the value (hexadecimal and decimal) of the destination register after LDRB r0, [r4], LDRSB r0, [r4], LDRH r0, [r4, #2] and LDRSH r0, [r4, #2]. (2 points)

c) With r1 = 0x2000 and r2 = 5 give the effective address and the value of r1 after the access for these operands: [r1, #12], [r1, #-8], [r1, r2], [r1, r2, LSL #2], [r1, #16]!, [r1], #16. Which one reads the element a[r2] of the word array? With sp = 0x7FF0 the instruction STMDB sp!, {r4-r6, lr} is executed: give the new sp and the address where each register is saved. (2 points)

Show the result

a) With LDR r0, [r1], #4: addresses 0x2000, 0x2004, 0x2008, 0x200C; values 7,−3,12,57,-3,12,5; r2 =21=21, r1 =0x2010=0\text{x}2010. With LDR r0, [r1, #4]!: addresses 0x2004, 0x2008, 0x200C, 0x2010; values −3,12,5,9-3,12,5,9; r2 =23=23, r1 =0x2010=0\text{x}2010.

b) LDRB: 0x000000C8 =200=200; LDRSB: 0xFFFFFFC8 =−56=-56; LDRH: 0x00008123 =33 059=33\,059; LDRSH: 0xFFFF8123 =−32 477=-32\,477.

c) [r1, #12]: 0x200C, r1 unchanged; [r1, #-8]: 0x1FF8, unchanged; [r1, r2]: 0x2005, unchanged; [r1, r2, LSL #2]: 0x2014, unchanged; [r1, #16]!: 0x2010, r1 =0x2010=0\text{x}2010; [r1], #16: 0x2000, r1 =0x2010=0\text{x}2010. The element a[r2] is read with [r1, r2, LSL #2] (0x2014). STMDB: sp =0x7FE0=0\text{x}7FE0; r4 at 0x7FE0, r5 at 0x7FE4, r6 at 0x7FE8, lr at 0x7FEC.

Show the full solution

a) Post-indexed and pre-indexed. With post-indexed addressing, LDR r0, [r1], #4 accesses the address held in r1 and then adds 44 to r1. The loop runs 44 times (r3 counts 4,3,2,14,3,2,1 and SUBS sets Z when it reaches 00, see ARM Data-Processing InstructionsAdd, subtract, logical, move and multiply instructions of ARM, the immediate and shifted-register second operand, flag updates with S, CMP and TST, and translation of C expressions into ARM code.ARM Data-Processing Instructions →):

iteration address read r0 r2 after the ADD r1 after the load
1 0x2000 7 7 0x2004
2 0x2004 -3 4 0x2008
3 0x2008 12 16 0x200C
4 0x200C 5 21 0x2010

Final: r2 =7−3+12+5=21=7-3+12+5=21, r1 =0x2010=0\text{x}2010 (=0x2000+4⋅4=0\text{x}2000+4\cdot4).

With pre-indexed with write-back, LDR r0, [r1, #4]! first computes the address r1+4r1+4, accesses it, and then writes it back into r1. The first access is already at 0x2004:

iteration address read r0 r2 after the ADD r1 after the load
1 0x2004 -3 -3 0x2004
2 0x2008 12 9 0x2008
3 0x200C 5 14 0x200C
4 0x2010 9 23 0x2010

Final: r2 =−3+12+5+9=23=-3+12+5+9=23, r1 =0x2010=0\text{x}2010. The element a[0]a[0] is skipped and a[4]a[4], beyond the four elements meant, is read: with the pre-indexed form the pointer must start one element before the array. Typical mistake: confusing pre-indexed (the base is updated, then used) with post-indexed (used, then updated).

b) Loads of bytes and half-words. LDRB zero-extends the byte to 3232 bits: 0xC8→0x000000C8=12⋅16+8=2000\text{xC8}\to0\text{x}000000C8=12\cdot16+8=200. LDRSB sign-extends it: the most significant bit of 0xC8=1100 10000\text{xC8}=1100\,1000 is 11, so the result is 0xFFFFFFC8, which is 200−256=−56200-256=-56. LDRH zero-extends the half-word: 0x00008123 =8⋅4096+1⋅256+2⋅16+3=33 059=8\cdot4096+1\cdot256+2\cdot16+3=33\,059. LDRSH sign-extends it: the half-word 0x81230\text{x}8123 has the most significant bit 11, the result is 0xFFFF8123 =33 059−65 536=−32 477=33\,059-65\,536=-32\,477. Typical mistake: reading a signed byte with LDRB.

c) Effective addresses. With r1 = 0x2000 and r2 = 5:

Operand Effective address r1 afterwards
[r1, #12] 0x2000+12=0x200C0\text{x}2000+12=0\text{x}200C unchanged
[r1, #-8] 0x2000−8=0x1FF80\text{x}2000-8=0\text{x}1FF8 unchanged
[r1, r2] 0x2000+5=0x20050\text{x}2000+5=0\text{x}2005 unchanged
[r1, r2, LSL #2] 0x2000+5⋅4=0x20140\text{x}2000+5\cdot4=0\text{x}2014 unchanged
[r1, #16]! 0x20100\text{x}2010 0x2010
[r1], #16 0x2000 0x2010

The index must become a byte offset for an array of words: LDR r0, [r1, r2, LSL #2] reads a[r2]a[r2] at 0x2014; [r1, r2] would step by one byte. Typical mistake: walking an array of words with step 11 instead of 44.

STMDB sp!, {r4-r6, lr} saves 44 registers, so it subtracts 4⋅4=164\cdot4=16 from sp: 0x7FF0−16=0x7FE00\text{x}7FF0-16=0\text{x}7FE0. The registers go to memory in register-number order, the lowest register at the lowest address: r4 at 0x7FE0, r5 at 0x7FE4, r6 at 0x7FE8 and lr (that is r14) at 0x7FEC. This is the usual way to save registers at the start of a function (see Stack and Function Calls in ARMCall with BL and return with BX LR; the AAPCS calling convention (arguments in r0-r3, result in r0, registers to preserve r4-r11); full-descending stack with PUSH and POP; activation record; leaf and non-leaf functions; recursive factorial example with the evolution of the stack.Stack and Function Calls in ARM →).

Exercise 3 (points 6)

Semiconductor memories (Semiconductor MemoryMemory cell and operations; dynamic RAM (capacitor, refresh) and static RAM (flip-flop) compared; ROM, PROM, EPROM, EEPROM and flash; organisation of chips and modules with calculation of address lines and number of chips; synchronous DRAM and DDR; errors and correcting codes.Semiconductor Memory →). Memories are built with chips N×bN\times b (NN words of bb bits); the word of the memory is the unit that is addressed.

a) A byte-addressed memory of 44 MB (word of 88 bits) is built with 512K×2512\text{K}\times2 bit chips. Compute the number of chips in a bank, the capacity of a bank, the number of banks, the total number of chips, the number of address bits of the memory, the number of address lines of each chip and the number of bits that enter the decoder. (2 points)

b) A memory of 1M1\text{M} words of 1616 bits is built with 256K×4256\text{K}\times4 bit chips and the address selects a word. Give the same data as in part a. If the chips are DRAM with row and column sent in two steps on the same lines (RAS and CAS), how many address pins does each chip need? (2 points)

c) A cache of 256256 KB is built with SRAM cells of about 66 transistors per bit. How many transistors do the cells need, and how many would a DRAM of the same capacity need (one transistor and one capacitor per cell)? A student counts the chips of part a by dividing only the number of words, 4M/512K4\text{M}/512\text{K}: which number does he get and why is it wrong? What must be done after reading a DRAM cell? (2 points)

Show the result

a) 44 chips per bank; bank =512K×8=512=512\text{K}\times8=512 KB; 88 banks; 3232 chips; 2222 address bits; 1919 address lines per chip; 33 bits into a 33-to-88 decoder.

b) 44 chips per bank; bank =256K×16=256\text{K}\times16 bits; 44 banks; 1616 chips; 2020 address bits; 1818 address lines per chip; 22 bits into a 22-to-44 decoder. With RAS and CAS: 18/2=918/2=9 pins.

c) 256 KB=2 097 152256\text{ KB}=2\,097\,152 bits: SRAM 6⋅2 097 152=12 582 9126\cdot2\,097\,152=12\,582\,912 transistors (about 12.612.6 million); DRAM 2 097 1522\,097\,152 transistors and as many capacitors. Dividing only the words gives 88 chips instead of 3232, because the width of the chip (22 bits instead of 88) is ignored. After reading a DRAM cell the bit must be rewritten (the read is destructive).

Show the full solution

a) Byte-addressed memory. A chip N×bN\times b has log⁡2N\log_2N address lines and bb data lines. Each chip gives b=2b=2 bits, so for a word of 88 bits we need 8/2=48/2=4 chips in parallel, forming a bank of 512K×8512\text{K}\times8 bits, that is 512K512\text{K} bytes =512=512 KB. The memory is 4 MB/512 KB=84\ \text{MB}/512\ \text{KB}=8 banks, so 4⋅8=324\cdot8=32 chips. The address has log⁡2(4 MB)=log⁡2222=22\log_2(4\ \text{MB})=\log_2 2^{22}=22 bits. The low log⁡2(512K)=log⁡2219=19\log_2(512\text{K})=\log_2 2^{19}=19 bits go to all the chips (address lines of each chip), the high 22−19=322-19=3 bits enter a 33-to-88 decoder that enables one of the 88 banks. Typical mistake: counting chips by dividing only the capacities, without the word width of the chip.

b) Memory of words. Here the address selects a word of 1616 bits, so 1M=2201\text{M}=2^{20} words need 2020 address bits. Each chip gives 44 bits: a bank needs 16/4=416/4=4 chips in parallel and has 256K×16256\text{K}\times16 bits, that is 256K256\text{K} words. The number of banks is 1M/256K=41\text{M}/256\text{K}=4 and the chips are 4⋅4=164\cdot4=16 (check: 22 MB of memory and 1616 chips of 128128 KB each). Each chip has log⁡2(256K)=18\log_2(256\text{K})=18 address lines, the high 20−18=220-18=2 bits enter a 22-to-44 decoder. In a DRAM row and column arrive in two steps on the same lines, which halves the pins: 18/2=918/2=9 address pins.

c) Cells, count of chips and refresh. 256256 KB =256⋅1024⋅8=2 097 152=256\cdot1024\cdot8=2\,097\,152 bits. With about 66 transistors per SRAM cell: 6⋅2 097 152=12 582 9126\cdot2\,097\,152=12\,582\,912 transistors. A DRAM cell has one transistor and one capacitor: 2 097 1522\,097\,152 transistors and 2 097 1522\,097\,152 capacitors, six times fewer transistors; this is why the DRAM holds more bits in the same area and is used as main memory, while the faster SRAM is used for the cache.

Dividing only the number of words gives 4M/512K=84\text{M}/512\text{K}=8 chips: it is the number of banks, and it forgets that each chip supplies only 22 of the 88 bits of the word, so the right number is 8⋅4=328\cdot4=32. Finally, the read of a DRAM cell is destructive: it discharges the capacitor, so the bit must be rewritten (and the charge leaks anyway, so a periodic refresh is needed). Typical mistake: thinking that a DRAM cell keeps its charge after a read.

Self-assessment grid
Part Points Criteria
Question 1 3 1 for the five registers, 1 for the path of the load and why it is the longest, 1 for the multiplexers
Question 2 3 1 for the meaning of the number of addresses and the 33 and 22 address forms, 1 for the two programs, 1 for the trade-off and the RISC choice
Question 3 3 1 for the register roles, 1 for r15 plus 88, 1 for CPSR and banked registers
Question 4 3 1 for the bottleneck and the hierarchy, 1 for the bridge, 1 for I/O channel and today's controllers
Exercise 1 6 2 for part a (operands, accesses, scaled index), 2 for part b (I and J formats, sign extension), 2 for part c (branch target and reach)
Exercise 2 6 2 for part a (post-indexed and pre-indexed), 2 for part b (signed and unsigned loads), 2 for part c (effective addresses and STMDB)
Exercise 3 6 2 for part a (chips, banks, address bits), 2 for part b (words, decoder, RAS and CAS pins), 2 for part c (cell counts, counting error, refresh)
Total 30

Criteria for each point: the idea is correct, the formula is written before the numbers, units are present, the result is checked.