CSC203 Problem-Solving Guide
1. Introduction
Lecture 1: units, clock speed, memory sizes, Moore’s and Rock’s laws, generations, the von Neumann model.
1.1 Units: the two kinds of “kilo”
Memory sizes use powers of 2. Speeds, frequencies and disk sizes use powers of 10. Cycle time , or the shortcut (1 GHz is 1 ns, 500 MHz is 2 ns, 2 GHz is 0.5 ns).
| Prefix | Memory (power of 2) | Speed / disk (power of 10) |
|---|---|---|
| K (kilo) | ||
| M (mega) | ||
| G (giga) | ||
| T (tera) |
| Small unit | Value |
|---|---|
| ms (milli) | s |
| µs (micro) | s |
| ns (nano) | s |
| ps (pico) | s |
- Write the number part as a power of 2, then add the prefix power: bytes.
- For a ratio of sizes, subtract exponents: .
- For a time from a frequency, use and convert to ns or ps.
| Item in the advert | Formula | Working | Answer + unit |
|---|---|---|---|
| Clock cycle (CPU / bus) | |||
| Memory size in bytes | number | ||
| Ratio of two sizes | |||
| Disk “missing” space | |||
| One disk revolution | seconds | ||
| Screen memory | width height bits per pixel |
Worked example: a 3.9 GHz PC. 3.9 GHz CPU, 1600 MHz memory, 32 GB RAM, 128 KB L1, 2 MB L2, 1 TB disk at 7200 RPM, 1920 × 1200 screen with 24-bit colour.
| Question | Working | Answer |
|---|---|---|
| CPU cycle time | s | 0.256 ns |
| Memory bus cycle | 0.625 ns | |
| CPU cycles per bus cycle | about 2.4 | |
| 32 GB in bytes | 34,359,738,368 B | |
| L2 L1 | 16 times | |
| Why the OS shows “931 GB” | Maker: 1 TB B; OS divides by | 931.3 GB |
| Disk revolution, average delay | s; average delay is half a turn | 8.33 ms, 4.17 ms |
| Colours per pixel | 16,777,216 | |
| Screen memory | B; | 6.59 MB |
- Do not use 1000 for memory or 1024 for clock speeds.
- Convert bits to bytes (divide by 8) for screen memory.
- Convert units (MHz to Hz, ns to s) before dividing.
1.2 Moore’s law and Rock’s law (doubling problems)
Both laws say something doubles every fixed period. Moore: transistors per chip double every 18 months (original 1965 version: every year; Moore later said 2 years). Rock: the cost of a chip factory doubles every 4 years.
- Put the time passed and the doubling period in the same unit (months or years).
- Doublings time passed period.
- Factor ; new value old factor.
- To find the time for a growth of times: doublings , then time doublings period. Remember .
| Old value | Time passed | Doubling period | Doublings = time ÷ period | Factor = | New = old × factor |
|---|---|---|---|---|---|
Worked examples: Moore and Rock
| Problem | Doublings | Answer |
|---|---|---|
| 2 billion transistors today, 18-month doubling. After 3, 6, 9 years? | ; ; | 8, 32, 128 billion |
| 64 components in 1965, original law (every year). Predict 1975. | ||
| How long for a 1000-fold increase? | 15 years (18 months) or 20 years (2 years) | |
| Chip plant cost USD 12,000 in 1968. Rock’s law for 2012? | USD 24.6 million |
Moore and Rock are linked: denser chips need ever more expensive factories, so at some point nobody can pay for the next factory and one of the two trends must stop.
- Check which doubling period the question gives (1 year, 18 months or 2 years).
- Do not mix years and months in the exponent.
1.3 Generations, organization vs architecture, von Neumann
Which generation? Look for the switching technology
| Gen. | Years | Technology (the clue word) | Examples |
|---|---|---|---|
| 0 | 1642–1945 | Mechanical gears | Pascaline, Babbage’s Difference Engine, Hollerith cards |
| 1 | 1945–1953 | Vacuum tubes | ENIAC (about 17,000 tubes), UNIVAC |
| 2 | 1954–1965 | Transistors, magnetic core memory, COBOL/FORTRAN | IBM 7000 series |
| 3 | 1965–1980 | Integrated circuits (ICs) | IBM System/360, DEC PDP-8, Cray-1 |
| 4 | 1980– | VLSI: a whole CPU on one chip (microprocessor) | Intel 4004/8088, the PC |
| 5 | 2000– | ULSI: billions of transistors, multicore, GPU, AI | smartphone SoCs, cloud servers |
Organization or architecture? Ask: “Can the programmer see it?” Yes: architecture (instruction set, addressing modes, data types, number of bits, whether there is a multiply instruction). No: organization (control signals, clock speed, RAM chip type, multiply done by circuit or by shift-and-add).
Von Neumann model: CPU (control unit + ALU + registers), one memory for program and data, I/O, and a single path between CPU and memory. That single path is the von Neumann bottleneck. A Harvard machine has separate instruction and data memories.
Worked example: the von Neumann bottleneck. The memory bus does one transfer every 10 ns. Each instruction needs 2 transfers (fetch the instruction, then read/write the operand).
- von Neumann: per instruction, so = 50 million instructions per second, however fast the CPU is.
- Harvard: the two transfers use two buses at the same time, so 10 ns per instruction = 100 million per second.
Fetch-decode-execute order: fetch the instruction from the address in the PC, then PC + 1, decode the opcode, read the operand from memory, and the ALU executes.
- Clock speed and RAM type are organization, not architecture.
- The bottleneck limits instruction rate by bus speed, not CPU speed.
2. Numbers and Arithmetic
Lecture 2: base conversion, signed integers, complement arithmetic, overflow, multiplication, floating point.
2.1 Converting Between Bases
- Any base → decimal: digit × place value (), then add.
- Decimal whole part → base : divide by repeatedly; read remainders bottom to top.
- Decimal fraction → base : multiply by repeatedly; read whole parts top to bottom.
- Binary ↔ hex: groups of 4 bits. Binary ↔ octal: groups of 3. Group outward from the point, pad with 0s.
Binary ↔ hex table and powers of 2: see Tables 6.4a–b.
| Number ÷ b | Quotient | Remainder |
|---|---|---|
| Fraction × b | Result | Whole part |
|---|---|---|
| Place value | . | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Digit | . | ||||||||
| Digit × place |
Worked example: 147.8125 (decimal) → binary, hex, octal
| ÷ 2 | Quotient | Remainder |
|---|---|---|
| 147 | 73 | 1 |
| 73 | 36 | 1 |
| 36 | 18 | 0 |
| 18 | 9 | 0 |
| 9 | 4 | 1 |
| 4 | 2 | 0 |
| 2 | 1 | 0 |
| 1 | 0 | 1 ↑ |
| × 2 | Result | Bit |
|---|---|---|
| 0.8125 | 1.625 | 1 ↓ |
| 0.625 | 1.25 | 1 |
| 0.25 | 0.5 | 0 |
| 0.5 | 1.0 | 1 (stop: fraction is 0) |
Whole part (read up): 1001 0011. Fraction (read down): .1101.
- Binary: 10010011.1101₂
- Hex:
1001 0011 . 1101= 93.D₁₆ - Octal:
010 010 011 . 110 100= 223.64₈
Check: ✓ and ✓
Worked example: other bases and fractions that never end
- → decimal: 675
- → decimal: 11.625
- → base 3: r 2, r 1, r 2, r 0, r 1. Read up: 10212₃. Check: ✓
- → octal:
0111 1010 1001 . 1100, regroup in 3s from the point:011 110 101 001 . 110= 3651.6₈ (both equal 1961.75) - → binary, 8 bits: , , , , , , , → 0.00011001₂. It never ends (0.4, 0.8, 1.6, 1.2 repeat), so the stored value is only .
Bits needed for an unsigned value : the smallest with (1000 needs 10 bits, since ). Range of unsigned bits: to .
2.2 Signed Integers: Signed Magnitude, One’s and Two’s Complement
| System | Write (start from ) | Range with bits | Zeros |
|---|---|---|---|
| Signed magnitude | Change the sign bit (leftmost) to 1 | … | two |
| One’s complement | Flip every bit | … | two |
| Two’s complement | Flip every bit, then add 1. Shortcut: copy from the right up to and including the first 1, flip the rest. | … | one |
8 bits: SM and 1C give ; 2C gives . 4-bit 2C: . 16-bit 2C: .
| Pattern | Unsigned | Signed magnitude | One’s complement | Two’s complement |
|---|---|---|---|---|
| Rule | add place values | sign bit, then value of the rest | if MSB = 1: flip all, read, put − | MSB weighs , others normal |
Worked example: one pattern, four meanings
Pattern 1011 0101:
- Unsigned: 181
- Signed magnitude: sign 1, rest
011 0101= 53 → −53 - One’s complement: flip →
0100 1010= 74 → −74 - Two’s complement: −75
Worked example: −18 in 8 bits (+18 = 0001 0010)
| System | −18 |
|---|---|
| Signed magnitude | 1001 0010 |
| One’s complement | 1110 1101 |
| Two’s complement | 1110 1110 |
Sign extension (4 → 8 bits): SM puts the extra 0s after the sign bit (
1101→1000 0101); 1C and 2C copy the sign bit (2C1011→1111 1011).
2.3 Integer Arithmetic and Overflow
| System | How to add (subtract = add the negative) | Overflow when … |
|---|---|---|
| Signed magnitude | Same signs: add magnitudes, keep the sign. Different signs: big magnitude − small magnitude, take the sign of the bigger one. | a carry comes out of the leftmost magnitude bit |
| One’s complement | Add all bits including the sign. If a carry comes out of the MSB, add it back to the rightmost bit (end-around carry). | two same-sign numbers give the other sign |
| Two’s complement | Add all bits including the sign. Throw away any carry out of the MSB. | carry into MSB ≠ carry out of MSB |
Two’s complement overflow: . Quick test: positive + negative never overflows; two same-sign numbers overflow only when the answer has the other sign.
| Cout | b7 (MSB) | b6 | b5 | b4 | b3 | b2 | b1 | b0 | |
|---|---|---|---|---|---|---|---|---|---|
| carries | 0 | ||||||||
| A | |||||||||
| B (or −B) | |||||||||
| Sum |
Carry into MSB = ___ Carry out of MSB = ___ Overflow V = ___ Result in decimal = ___ Check: ___
Worked example (a): 19 − 48 in 8-bit two’s complement
0011 0000, so 1100 1111 + 1 = 1101 0000.
carries 0 0 1 0 0 0 0 0 (carry INTO each column)
19 0 0 0 1 0 0 1 1
+ (-48) 1 1 0 1 0 0 0 0
----------------------------
1 1 1 0 0 0 1 1 carry into MSB 0, carry out 0 -> no overflow
1110 0011 is negative. Flip + 1 → 0001 1101 = 29, so the answer is −29 ✓
Worked example (b): 9 + (−23) in 8-bit one’s complement
flip(0001 0111) = 1110 1000. 0000 1001 + 1110 1000 = 1111 0001, no carry out, so no end-around carry. Flip → 0000 1110 = 14 → −14 ✓
Worked example (c): 4-bit overflow checks
| Sum | Bits | Result | C into MSB | C out | Overflow? |
|---|---|---|---|---|---|
| (+5) + (+4) | 0101 + 0100 | 1001 (reads −7) | 1 | 0 | yes (9 > 7) |
| (−4) + (−1) | 1100 + 1111 | 1 1011 → 1011 = −5 | 1 | 1 | no |
| (−7) + (−6) | 1001 + 1010 | 1 0011 → 0011 (reads +3) | 0 | 1 | yes (−13 < −8) |
| (−7) + (+5) | 1001 + 0101 | 1110 = −2 | 0 | 0 | no |
Worked example (d): −3 − 5 in 4 bits, both systems
, true answer .
| System | Sum | After carry rule | Overflow? | ||
|---|---|---|---|---|---|
| One’s complement (range −7 … +7) | 1100 | 1010 | 1 0110 | end-around: 0110 + 1 = 0111 (+7) | yes (−8 is out of range, sign flipped) |
| Two’s complement (range −8 … +7) | 1101 | 1011 | 1 1000 | drop carry: 1000 (−8) | no (carry in = carry out = 1) |
Worked example (e): a counting loop that wraps (4-bit one’s complement)
j = -2; k = 6; while k ≠ -6 { j = j - 1; k = k + 1 }. Here (with end-around carry) and . The test value .
| Pass | before | after | after |
|---|---|---|---|
| 1 | 0110 (+6) | 1100 (−3) | 0111 (+7) |
| 2 | 0111 (+7) | 1011 (−4) | 1000 (−7) |
| 3 | 1000 (−7) | 1010 (−5) | 1001 (−6), stop |
is (the count wraps), so the loop runs 3 times: j = 1010 = −5.
- A carry out of the MSB on its own is not overflow in two’s complement.
- Only throw away the MSB carry in 2C; in 1C it goes back into the rightmost bit.
Adder–subtractor circuit
One control line M feeds an XOR gate on every B input and also the first carry .
- M = 0: B passes unchanged, → .
- M = 1: every B bit is flipped and → .
- Overflow flag (4 bits): .
Example : , then → , , so .
Sequential (shift-and-add) multiplier
- Set C = 0, A = 0, M = multiplicand, Q = multiplier, Count = .
- If Q₀ = 1 (rightmost bit of Q): C,A ← A + M. If Q₀ = 0: do nothing.
- Shift C, A, Q one place right as one long register (C → left bit of A, right bit of A → left bit of Q, Q₀ falls off). Count − 1.
- Repeat steps 2–3 until Count = 0. The product is A Q ( bits).
| Cycle | Step | C | A | Q | M |
|---|---|---|---|---|---|
| 0 | initial | 0 | |||
| 1 | Q₀ = ? → add / no add | ||||
| 1 | shift right | ||||
| 2 | Q₀ = ? → add / no add | ||||
| 2 | shift right | ||||
| … | … | ||||
| … | shift right |
Worked example: 11 × 13 with 4-bit registers (M = 1011, Q = 1101)
| Cycle | Step | C | A | Q |
|---|---|---|---|---|
| 0 | initial | 0 | 0000 | 1101 |
| 1 | Q₀ = 1 → A + M = 0000 + 1011 | 0 | 1011 | 1101 |
| 1 | shift right | 0 | 0101 | 1110 |
| 2 | Q₀ = 0 → no add | 0 | 0101 | 1110 |
| 2 | shift right | 0 | 0010 | 1111 |
| 3 | Q₀ = 1 → 0010 + 1011 | 0 | 1101 | 1111 |
| 3 | shift right | 0 | 0110 | 1111 |
| 4 | Q₀ = 1 → 0110 + 1011 = 1 0001 | 1 | 0001 | 1111 |
| 4 | shift right (C goes into A) | 0 | 1000 | 1111 |
Product A Q = 1000 1111₂ = 143 ✓ ().
Keep the carry C: in cycle 4 it becomes the top bit of A after the shift. Without it the top bit is lost.
2.4 Floating Point: the 14-bit Model and IEEE 754
A float is , normalized to exactly one 1 before the point. That leading 1 is not stored (hidden bit). Moving the point left places adds to the exponent. Stored exponent .
| Format | Sign | Exponent | Fraction | Bias | Value |
|---|---|---|---|---|---|
| Lecture 14-bit model | 1 | 5 | 8 | 16 | |
| IEEE single (32 bits) | 1 | 8 | 23 | 127 | |
| IEEE double (64 bits) | 1 | 11 | 52 | 1023 |
Bit layouts, ranges and special patterns of each format: see Table 6.4d.
| Step | Your work |
|---|---|
| 1. Sign bit (0 = +, 1 = −) | |
| 2. |number| in binary | |
| 3. Normalize: | |
| 4. Stored exponent bias (16 or 127), in binary | |
| 5. Fraction = bits after “1.” padded with 0s on the right |
14-bit model layout (bias 16):
IEEE single layout (bias 127):
For IEEE hex: write all 32 bits in a row, cut into eight groups of 4, and convert each group to one hex digit.
Worked example: 14-bit model (excess-16)
| Number | Binary and normalized | 14-bit pattern | |
|---|---|---|---|
| 9.625 | 19 = 10011 | 0 10011 00110100 | |
| −0.375 | 14 = 01110 | 1 01110 10000000 | |
| 17 | 20 = 10100 | 0 10100 00010000 |
Decode 0 10010 10100000: (+), , value 6.5
Worked example: IEEE 754 single precision
→ IEEE: . . . then 0s.
S E F
1 10000010 10001100000000000000000
1100 0001 0100 0110 0000 0000 0000 0000 -> C 1 4 6 0 0 0 0
Answer: C1460000₁₆
→ decimal: 0100 0001 1100 1000 0000… → , , → 25
, → 3E200000₁₆
| Special patterns (single) | Exponent E | Fraction F | Example hex |
|---|---|---|---|
| Zero (+0 or −0) | 0 | 0 | 00000000, 80000000 |
| Normal number | 1 – 254 | anything | 3F800000 = 1.0 |
| Infinity (+∞ or −∞) | 255 (all 1s) | 0 | 7F800000, FF800000 |
| NaN (not a number) | 255 | not 0 | 7FC00000 |
- Subtract the bias when decoding, add it when encoding.
- A plain 5-bit exponent cannot be negative; the bias (excess-16) lets it run from −16 to +15.
2.5 Floating-Point Arithmetic and Errors
| Operation | Steps |
|---|---|
| Add / subtract | 1. Align: shift the number with the smaller exponent right until exponents match. 2. Add or subtract the significands. 3. Normalize. 4. Truncate to the fraction bits. |
| Multiply | Sign = XOR of signs. (subtract one bias, or it is counted twice). Multiply significands. Normalize. |
| Divide | Sign = XOR. . Divide significands. Normalize. |
Worked example: add, subtract and multiply in the 14-bit model
(a) 0 10010 10000000, 0 10000 01000000. (= 6), (= 1.25). Align B to : . Add: (already normal). Result 0 10010 11010000 ✓
(b) : , . . Stored: 0 10011 01011000
(c) with biased fields: . Significands . Sign . Result 0 10011 11100000 ✓
Never test
x == 0.0. 0.1 has no exact binary form, so adding 0.1 ten times is not exactly 1.0. Use a tolerance:abs(x - y) < epsilon. Exponent bits set the range; fraction bits set the precision.
- Overflow: exponent too big to store. Underflow: exponent too small (number too close to 0), e.g. needs in the 14-bit model. These are blatant errors.
- Subtle errors give a believable wrong value: keeps only 8 fraction bits, so it is stored as 128.5.
3. Codes, Error Detection and Error Correction
Lecture 3: ASCII and parity, BCD, recording codes, check digits, CRC, Hamming distance, Hamming codes.
3.1 Character Codes and Parity
Parity bit = the 8th (leftmost) bit, chosen so the total number of 1s in the byte is even (even parity) or odd (odd parity). A wrong count means an error is detected. Parity cannot say which bit is wrong and misses two errors in the same byte.
| ASCII landmark (7 bits) | Hex |
|---|---|
| space | 20 |
| digits ‘0’ … ‘9’ | 30 … 39 (digit + 30) |
| ‘A’ … ‘Z’ | 41 … 5A (‘A’ + position − 1) |
| ‘a’ … ‘z’ | 61 … 7A (capital + 20) |
| control characters | 00 … 1F, 7F |
- Look up each character’s hex code and write its 7-bit binary.
- Count the 1s.
- Put a leading 0 or 1 so the count becomes even (even parity) or odd (odd parity).
- To check a received byte, count its 1s: the wrong parity means an error.
| Char | Hex | 7-bit binary | Number of 1s | Even-parity byte | Odd-parity byte |
|---|---|---|---|---|---|
Worked example: “CAT” with parity, then checking received bytes
| Char | Hex | 7 bits | 1s | Even parity | Odd parity |
|---|---|---|---|---|---|
| C | 43 | 100 0011 | 3 | 1100 0011 = C3 | 0100 0011 = 43 |
| A | 41 | 100 0001 | 2 | 0100 0001 = 41 | 1100 0001 = C1 |
| T | 54 | 101 0100 | 3 | 1101 0100 = D4 | 0101 0100 = 54 |
Received (even parity): 53 C9 D4. 53 = 0101 0011 (four 1s, ok) so the character is 53 = ‘S’. C9 = 1100 1001 (four, ok) so 49 = ‘I’. D4 = 1101 0100 (four, ok) so 54 = ‘T’. Message: “SIT”, no error detected. A byte such as 1000 0011 has three 1s, so an error is detected.
BCD: zoned and packed
Sign nibbles:
1100(C) = +,1101(D) = −,1111(F) = unsigned. Zoned: one digit per byte, zone F on every digit except the last, whose zone is the sign. Packed: two digits per byte, sign nibble at the right end; add a leading0000if the nibble count is odd.
| Number | Zoned decimal | Packed BCD |
|---|---|---|
| +305 | F3 F0 C5 | 0011 0000 0101 1100 = 30 5C |
| −1265 | F1 F2 F6 D5 | 0000 0001 0010 0110 0101 1101 = 01 26 5D |
Unicode: 17 planes × 65,536 = 1,114,112 code points (U+0000 … U+10FFFF, so the largest needs 21 bits). Plane 0 is the Basic Multilingual Plane. ASCII is the first 128 code points.
- Count the 1s of the 7 data bits only, then add the parity bit. Do not count the parity bit twice.
- Letters: count from ‘A’ = 41 (A … I = 41 … 49, J … O = 4A … 4F, P = 50, T = 54, Z = 5A).
3.2 Recording and Transmission Codes
Each bit gets a bit cell; the receiver keeps its clock in step by watching for transitions. Cell time = 1 / bit rate (2 Kbps gives 0.5 ms). Density (most data per area): RLL > MFM > FM.
| Code | Rule (1 = high, 0 = low) | Problem / use |
|---|---|---|
| NRZ | 1 = high for the whole cell, 0 = low | long runs are flat, so sync is lost |
| NRZI | a 1 = a transition (in the middle of the cell); 0 = no change | runs of 0s still flat |
| Manchester | every cell flips in the middle: 1 = low to high, 0 = high to low; an extra boundary flip between two equal bits | self-clocking (Ethernet); twice the transitions |
| FM | a flip at every cell boundary (clock) plus a flip in the middle of every 1 cell | easy to decode; least dense |
| MFM | a flip in the middle of every 1 cell; a boundary flip only between two 0s | floppy disks; about twice FM density |
| RLL(2,7) | re-code with the table below, then record the code with NRZI | 2 to 7 zeros between 1s; densest |
- Write the bits above the grid.
- Draw one row (code) at a time.
- For each cell ask: does it flip in the middle? does it flip at its left boundary?
Worked example: data 1 0 0 1 1 in every code
| Code | NRZ | NRZI | Manchester | FM | MFM |
|---|---|---|---|---|---|
| Transitions drawn | 2 | 3 (one per 1) | 5 middle + 2 boundary = 7 | 3 middle + 4 boundary = 7 | 3 middle + 1 between the 0s = 4 |
RLL(2,7)
Read the data from the left and cut it into groups:
- starts with 1: take 2 bits
- starts with 01 or 000: take 3 bits
- starts with 001: take 4 bits
Each code is twice as long as its data. Transitions after NRZI = number of 1s in the code.
| Data | RLL(2,7) code |
|---|---|
| 10 | 0100 |
| 11 | 1000 |
| 000 | 000100 |
| 010 | 100100 |
| 011 | 001000 |
| 0010 | 00100100 |
| 0011 | 00001000 |
Worked example: RLL(2,7) for 1000 1111
Cut 10 | 0011 | 11, so the code is 0100 | 00001000 | 1000. The code has three 1s, so NRZI gives 3 transitions for 8 data bits.
- NRZI: only a 1 causes a flip; a 0 keeps the level.
- MFM: a boundary flip appears only between two 0s, never next to a 1.
- Cut RLL data by its leading bits, not into fixed-size blocks.
3.3 Error Detection: Check Digits and CRC
Check digit (UPC-A)
Check digit = 10 − (S mod 10), where S = 3 × (sum of odd positions) + (sum of even positions) over the first 11 digits. If S mod 10 = 0, the check digit is 0.
Worked example: UPC-A check digit for 036000 24145?
Odd positions (1st, 3rd, … 11th): 0 + 6 + 0 + 2 + 1 + 5 = 14, and 14 × 3 = 42. Even positions (2nd … 10th): 3 + 0 + 0 + 4 + 4 = 11. S = 42 + 11 = 53. Check digit = 10 − (53 mod 10) = 10 − 3 = 7.
CRC (modulo-2 division)
Mod-2 add and subtract are both XOR (no carries, no borrows). In the long division, whenever the leftmost remaining bit is 1, write the key under it and XOR; never compare sizes. A key with bits (degree ) gives an -bit CRC. Key 1101 = .
- Sender: append zeros ( = key length − 1) to the data.
- Divide by the key with mod-2 division; the last bits are the remainder.
- Replace the appended zeros with the remainder. This is the codeword that is sent.
- Receiver: divide the whole codeword by the same key (do not add zeros). Remainder 0 means accept; anything else means error, ask for a resend.
Key = ________ (n+1 = ___ bits) -> append n = ___ zeros
data + zeros: _ _ _ _ _ _ _ _ _ _ _ _
key under the first 1: _ _ _ _
XOR, bring down -> _ _ _ _ _ _ _ _ _ _ _ _
key under the next 1: _ _ _ _
XOR -> _ _ _ _ _ _ _ _ _ _ _ _
... repeat until fewer than (n+1) bits remain after the last 1 ...
remainder = last n bits = _ _ _
Codeword = data followed by remainder = ________________Worked example: data 1111101, key 1101
Sender (key has 4 bits, so append 3 zeros):
1111101000
1101 step 1
0010101000
1101 step 2
0001111000
1101 step 3
0000010000
1101 step 4
0000001010
1101 step 5
0000000111 -> remainder 111
Codeword = 1111101 | 111 = 1111101111
Receiver divides what arrives by 1101:
- 1111101111 gives remainder 000, so accept.
- 1111100111 gives remainder 101, so reject (bit 4 from the right was flipped).
A CRC with a degree- key catches all single-bit errors and all bursts of length at most . It only detects; it cannot correct.
- Append zeros only at the sender, never at the receiver.
- The remainder must have exactly bits: keep leading zeros (for example 011).
3.4 Hamming Distance and Hamming Codes
Hamming distance = number of positions where two code words differ (XOR them, count the 1s). = smallest distance over all pairs. A code detects up to errors and corrects up to .
| 2 | 3 | 4 | 5 | |
|---|---|---|---|---|
| detects | 1 | 2 | 3 | 4 |
| corrects | 0 | 1 | 1 | 2 |
Worked example: of
| 01011 | 10101 | 11110 | |
|---|---|---|---|
| 00000 | 3 | 3 | 4 |
| 01011 | 4 | 3 | |
| 10101 | 3 |
= 3, so the code detects 2 and corrects 1.
How many check bits?
For data bits find the smallest with . The code word has bits.
| Data bits | 4 | 5–11 | 8 | 10 | 12–26 | 16 | 32 | 64 |
|---|---|---|---|---|---|---|---|---|
| Check bits | 3 | 4 | 4 | 4 | 5 | 5 | 6 | 7 |
| Code word | 7 | 9–15 | 12 | 14 | 17–31 | 21 | 38 | 71 |
Layout and encoding
Number positions 1 to from the right. Check bits sit at the powers of 2 (1, 2, 4, 8, 16). Data bits fill the other positions from the highest position down, in the order written. Check bit covers every position whose binary number contains (position 11 = 8 + 2 + 1 is checked by , , ). Even parity: each check bit = XOR of the data bits it covers.
Every position from 1 to 16 in binary, with the check bits that cover it: see Table 6.4c.
- Draw the positions and mark the powers of 2 as check bits.
- Write the data bits into the remaining positions, highest first.
- For each check bit, list the data positions it covers, count their 1s, and set the check bit to 0 (even count) or 1 (odd count).
- Read off the code word from position down to 1.
Ready lists (use only positions up to your ; for the check bit itself use data positions only):
| Check bit | () | () | () | () |
|---|---|---|---|---|
| P1 | 1, 3, 5, 7 | 1, 3, 5, 7, 9, 11 | 1, 3, 5, 7, 9, 11, 13 | all odd positions 1 … 21 |
| P2 | 2, 3, 6, 7 | 2, 3, 6, 7, 10, 11 | 2, 3, 6, 7, 10, 11, 14 | 2, 3, 6, 7, 10, 11, 14, 15, 18, 19 |
| P4 | 4, 5, 6, 7 | 4, 5, 6, 7, 12 | 4, 5, 6, 7, 12, 13, 14 | 4–7, 12–15, 20, 21 |
| P8 | none | 8, 9, 10, 11, 12 | 8, 9, 10, 11, 12, 13, 14 | 8–15 |
| P16 | none | none | none | 16–21 |
| Data positions (high to low) | 7, 6, 5, 3 | 12, 11, 10, 9, 7, 6, 5, 3 | 14, 13, 12, 11, 10, 9, 7, 6, 5, 3 | 21 … 17, 15 … 9, 7, 6, 5, 3 |
| Position | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Type | P8 | P4 | P2 | P1 | ||||||||
| Bit |
| Check bit | Covers data positions | Data bits there | Number of 1s | Value (even = 0, odd = 1) |
|---|---|---|---|---|
| P1 | 3, 5, 7, 9, 11 | |||
| P2 | 3, 6, 7, 10, 11 | |||
| P4 | 5, 6, 7, 12 | |||
| P8 | 9, 10, 11, 12 |
The 7-bit version (4 data bits) is positions 7 6 5 4 3 2 1 = , with P1 from 3, 5, 7; P2 from 3, 6, 7; P4 from 5, 6, 7.
Worked example: encode M = 1101 0110
| Position | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Type | d | d | d | d | P8 | d | d | d | P4 | d | P2 | P1 |
| Data | 1 | 1 | 0 | 1 | ? | 0 | 1 | 1 | ? | 0 | ? | ? |
| Check | Data positions and bits | 1s | Value |
|---|---|---|---|
| P1 | 3, 5, 7, 9, 11: 0, 1, 0, 1, 1 | 3 | 1 |
| P2 | 3, 6, 7, 10, 11: 0, 1, 0, 0, 1 | 2 | 0 |
| P4 | 5, 6, 7, 12: 1, 1, 0, 1 | 3 | 1 |
| P8 | 9, 10, 11, 12: 1, 0, 1, 1 | 3 | 1 |
Key K = P8 P4 P2 P1 = 1101. Code word (position 12 first): 1101 1011 1001
Finding and correcting an error (syndrome)
Recompute the check bits from the data read (), XOR with the stored check bits (). The result , read as binary (P8 P4 P2 P1), is the position of the wrong bit. 0 = no error; a power of 2 = a check bit itself is wrong (data fine); anything else = flip that data position.
| Check bit | Recomputed from data read () | Stored () | |
|---|---|---|---|
| P8 | |||
| P4 | |||
| P2 | |||
| P1 |
Syndrome (P8 P4 P2 P1 as binary) = ______ = position ____
Worked example: data read back as 1101 0100, stored K = 1101
Place the data read at positions 12, 11, 10, 9, 7, 6, 5, 3 = 1, 1, 0, 1, 0, 1, 0, 0.
| Check | Recompute from data read | |||
|---|---|---|---|---|
| P8 | 9, 10, 11, 12: 1, 0, 1, 1 | 1 | 1 | 0 |
| P4 | 5, 6, 7, 12: 0, 1, 0, 1 | 0 | 1 | 1 |
| P2 | 3, 6, 7, 10, 11: 0, 1, 0, 0, 1 | 0 | 0 | 0 |
| P1 | 3, 5, 7, 9, 11: 0, 0, 0, 1, 1 | 0 | 1 | 1 |
Syndrome = 0101 = 5, so the bit at position 5 is wrong. Flip it from 0 to 1. Corrected data: 1101 0110 (P4 and P1 failed, and 4 + 1 = 5).
Worked example: labels and , word read = 01000011 1010
Labels count from the right: sit at positions 1, 2, 4, 8 and fill positions 3, 5, 6, 7, 9, 10, 11, 12. Here and .
| Position | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Label | ||||||||||||
| Bit | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
When the check bit is part of the word, count the 1s of the whole group including the check bit: odd means the check fails.
| Group | Positions | 1s | Fails? |
|---|---|---|---|
| 1 | 1, 3, 5, 7, 9, 11 | 3 | 1 |
| 2 | 2, 3, 6, 7, 10, 11 | 3 | 1 |
| 4 | 4, 5, 6, 7, 12 | 1 | 1 |
| 8 | 8, 9, 10, 11, 12 | 2 | 0 |
Syndrome = 0111 = 7 → position 7 = is wrong. Flip it: corrected message = 0100 1011 (check bits unchanged, 1010).
- Number positions from the right.
- When computing a check bit, use data bits only, never other check bits.
- A single-error-correcting code () cannot fix two errors: the syndrome then points at the wrong place.
4. Boolean Algebra and Digital Logic
Lectures 4–5: gates, truth tables, Boolean laws, SOP/POS, K-maps, adders, decoders, multiplexers, flip-flops, sequential circuits
4.1 Gates and Truth Tables
Notation: NOT is , AND is , OR is , XOR is . Order of work: NOT, then AND, then OR. A function of variables has rows. NAND alone (or NOR alone) can build every circuit.
Gate symbols, truth tables and NAND/NOR replacements: see Tables 6.2a–c.
An AND–OR circuit becomes NAND–NAND by double complement and DeMorgan: . Also, when an odd number of inputs are 1 (parity bit).
Why OR is NAND of the complements: NAND gives 0 only when both of its inputs are 1. Feeding it and gives 0 only when , which is exactly when .
| NAND(, ) | |||||
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 1 |
Recipe: any SOP using only NAND gates
- Draw the circuit with ordinary NOT, AND and OR gates, straight from the formula.
- Replace every gate with its NAND version from Table 6.2a: AND becomes NAND then NOT, and OR becomes NOT on each input then NAND.
- On each path from an AND to the OR you now have NAND → NOT → NOT → NAND. Two NOTs in a row cancel, leaving NAND → NAND.
- Each NOT on an input variable stays, and becomes NAND with both inputs joined.
- Check with a truth table (or one row by hand).
| Gate in the ordinary circuit | NAND gate | Its inputs | Its output |
|---|---|---|---|
| NOT | |||
| NOT | |||
| AND | |||
| AND | |||
| OR |
Worked example: XOR from NAND only,
Step 1, the ordinary circuit: NOT makes , and NOT makes . AND(, ) makes , and AND(, ) makes . An OR joins them.
Steps 2–4: swap each gate, then cancel the NOT pairs.
| Path | Ordinary | After swapping | After cancelling |
|---|---|---|---|
| AND to OR | AND → OR | NAND → NOT → NOT → NAND | NAND → NAND |
| Input NOT | NOT | NAND(, ) | NAND(, ) |
| Gate in the ordinary circuit | NAND gate | Its inputs | Its output |
|---|---|---|---|
| NOT | , | ||
| NOT | , | ||
| AND | , | ||
| AND | , | ||
| OR | , |
Check , : , , , , 1 ✓. The 4-gate version shares one gate in place of both inverters, because and .
- “Only NAND” means no separate NOT gates: every inverter is NAND(, ).
- Only cancel two NOTs that are directly in a row on the same wire. The NOTs on the input variables have nothing to cancel with, so they stay.
Worked example: bitwise operations on , (column by column)
| Operation | Result |
|---|---|
| A AND B | 0010 0010 |
| A OR B | 1111 1011 |
| A XOR B | 1101 1001 |
| NOT A | 0100 1101 |
| A NAND B | 1101 1101 |
| A NOR B | 0000 0100 |
4.2 Boolean Laws, DeMorgan, SOP and POS
| Law | AND form | OR form |
|---|---|---|
| Identity | ||
| Null | ||
| Idempotent | ||
| Inverse | ||
| Commutative | ||
| Associative | ||
| Distributive | ||
| Absorption | ||
| DeMorgan |
Also useful: , , consensus .
Complement of a whole expression (extended DeMorgan): swap every AND and OR, and prime every variable. Keep the brackets so the order of work does not change. Example: gives .
SOP (sum of minterms): one AND term per row where ; write for bit 1 and for bit 0; OR the terms. Short form . POS (product of maxterms): one OR term per row where ; write for bit 0 and for bit 1; AND the terms.
| # | part 1 | part 2 | minterm | ||||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | ||||
| 1 | 0 | 0 | 1 | ||||
| 2 | 0 | 1 | 0 | ||||
| 3 | 0 | 1 | 1 | ||||
| 4 | 1 | 0 | 0 | ||||
| 5 | 1 | 0 | 1 | ||||
| 6 | 1 | 1 | 0 | ||||
| 7 | 1 | 1 | 1 |
Worked example: simplify with laws (name the law at every step)
(a)
| Step | Law |
|---|---|
| Distributive | |
| Inverse | |
| Identity | |
| DeMorgan | |
| Distributive | |
| Inverse, Identity |
(b) Show : (distributive) (inverse) (identity).
(c) : the 1s are rows 000, 010, 100, 101, 110. Rows 0, 2, 4, 6 all have , giving . Rows 4, 5 have , , giving . So .
4.3 Karnaugh Maps
Rows and columns go in Gray order 00, 01, 11, 10. Circle rectangles of 1s of size 1, 2, 4, 8 or 16 (wrap-around allowed; the four corners form one group). Use as few, as large groups as possible, overlaps allowed, every 1 covered. Don’t-cares may be used as 1s but need not be covered. In each group keep only the variables that do not change (1 gives , 0 gives ); a group of cells removes variables.
| Group | Cells | Term |
|---|---|---|
| A | ||
| B | ||
| C | ||
| D |
Worked example 1:
- m0, m1, m8, m9→x'y'
- m0, m2, m8, m10→x'z'
- m1, m5→w'y'z
F = x'y' + x'z' + w'y'z
| Group | Cells | Unchanged | Term |
|---|---|---|---|
| A | 0, 1, 8, 9 | , | |
| B (corners) | 0, 2, 8, 10 | , | |
| C | 1, 5 | , , |
Worked example 2: don’t-cares,
- m3, m7, m15, m11→yz
- m0, m1, m3, m2→w'x'
F = yz + w'x'
Group A is the whole column giving . Group B is the top row, using d0 and d2 as 1s, giving . d5 is not needed, so leave it as 0.
Worked example 3: word problem (puppy biscuit). Biscuit () for = 110, 011, 100, 111, otherwise 0.
- m3, m7→WB
- m4, m6→SB'
F = WB + SB'
Group (column 11) gives ; group (wraps around the row) gives . (1 NOT, 2 AND, 1 OR).
- Label order is 00, 01, 11, 10, so cells 12–15 sit above 8–11.
- Groups must be powers of 2 and rectangular, never L-shaped or size 3 or 6.
- Do not forget wrap-around groups (edges and four corners).
4.4 Combinational Circuits
Half adder: Sum , Carry . Full adder: Sum , . Sum is 1 for an odd number of 1s; is 1 for two or more 1s. Ripple-carry adder: full adders chained; each feeds the next . Decoder: inputs give outputs, exactly one is 1 (inputs outputs). Multiplexer: data inputs need select lines.
| Sum | ||||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
- Start with at bit 0.
- For each bit, add : Sum bit is the low bit of the total, carry is the high bit.
- Pass the carry to the next bit.
- Read the result as .
| Full adder | |||||
|---|---|---|---|---|---|
| FA0 (bit 0) | 0 | ||||
| FA1 | |||||
| FA2 | |||||
| FA3 (bit 3) |
Result
Worked example (a): , in a 4-bit ripple-carry adder
| FA | Sum | ||||
|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 1 |
| 2 | 0 | 1 | 1 | 0 | 1 |
| 3 | 1 | 0 | 1 | 0 | 1 |
Sum with final carry 1, so 10001 = 17 (); it does not fit in 4 unsigned bits.
Worked example (b): decoder and mux sizes. 64 outputs need 6 inputs. A 32-input mux needs 5 select lines. A 32-word memory of 8 chips 4 words with address : top 3 bits go to a 3-to-8 decoder (chip select), low 2 bits pick the word. Address 10110 gives chip , word .
Worked example (c): 4-to-1 mux. . With and , the output is 0.
Worked example (d): full adder from a 3-to-8 decoder. Inputs ; Sum OR of outputs 1, 2, 4, 7; OR of outputs 3, 5, 6, 7.
Worked example (e): 2-bit ALU (: 00 ADD, 01 OR, 10 NOT A, 11 AND) with , : ADD gives 11, OR gives 11, NOT A gives 10, AND gives 00.
4.5 Sequential Circuits: Flip-Flops
A sequential circuit has memory: output depends on the inputs and the present state . Flip-flops change only on the clock edge, all together. is after the next clock pulse.
Symbols, characteristic tables, the JK excitation table and how SR, JK, D and T are built from each other: see Tables 6.3a–d.
Worked example: JK sequence. Start ; at six pulses: (1,0) (0,0) (1,1) (1,1) (0,1) (1,1).
| Pulse | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Action | set | hold | toggle | toggle | reset | toggle |
| 1 | 1 | 0 | 1 | 0 | 1 |
Analysis recipe
- Name the flip-flops (state variables , , …) and the inputs (, …).
- Follow the wires and write an input equation for every flip-flop input (, , , …).
- For every row (present state plus input), evaluate the equations using present values only.
- Apply each flip-flop’s rule (Tables 6.3a–c) to get the next state.
| FF A inputs ( or ) | FF B inputs ( or ) | |||||
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | ||||
| 0 | 0 | 1 | ||||
| 0 | 1 | 0 | ||||
| 0 | 1 | 1 | ||||
| 1 | 0 | 0 | ||||
| 1 | 0 | 1 | ||||
| 1 | 1 | 0 | ||||
| 1 | 1 | 1 |
Worked example: two D flip-flops, ,
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
When , (state held). When : 00, 01, 10, 11, 00, and so on. The circuit is a 2-bit binary up-counter with count enable .
- Use the old and on the right-hand side of every equation, even if changes in the same row.
- SR input 11 is not allowed; JK 11 toggles.
5. MARIE: CPU, Assembly and the Control Unit
Lectures 6–7: clocks, address lines, memory chips, MARIE ISA, fetch–decode–execute, assembly, control signals, microcode.
6.1 Clocks, Address Lines and Memory Chips
A memory written L × W has L locations, each W bits wide. Address lines = (addressable locations); the width W only decides the data lines. Byte-addressable: locations = L × (W / 8).
Cycle time · instruction time = cycles × cycle time · peak bus bandwidth = (data lines / 8) bytes × transfers per second.
- Chips per row = memory width ÷ chip width.
- Rows = memory locations ÷ chip locations.
- Total chips = rows × chips per row.
- Total address bits = (memory locations); bits inside a chip = (chip locations).
- Row-select bits = total − inside (feeds a -to- decoder).
- For a given address: high bits = row, low bits = location inside the chip.
| Quantity | Value |
|---|---|
| Chips per row | |
| Rows | |
| Total chips | |
| Total address bits | |
| Bits inside a chip | |
| Row-select bits / decoder |
Worked examples
| Problem | Working | Answer |
|---|---|---|
| 800 MHz clock; instruction of 6 cycles | ns; | 1.25 ns, 7.5 ns |
| 4M × 16, word-addressable | words | 22 lines |
| 4M × 16, byte-addressable | words × 2 bytes = bytes | 23 lines |
| MARIE: 4K × 16 words | 12 lines | |
| 2M × 32 from 256K × 8 chips | per row ; rows ; address , inside chip , select | 32 chips, 21 bits = 18 + 3, 3-to-8 decoder |
| MARIE 4K × 16 from 1K × 8 chips; where is 9AB? | per row 2, rows 4 → 8 chips; 12 bits = 2 select + 10 inside; 9AB = 10 01 1010 1011 | row 2 (from 0), location 1AB |
| 32 data lines, 100 MHz, one transfer per cycle | 400 MB/s | |
| 5 devices fully point-to-point | 10 links (1 shared bus instead) | |
| Flip-flops for all MARIE registers | AC 16 + MAR 12 + MBR 16 + PC 12 + IR 16 + InREG 8 + OutREG 8 | 88 D flip-flops |
- Width never changes the number of address lines (unless byte-addressable).
- Use the number of locations, not bits, inside the log.
6.2 MARIE Architecture and Instruction Set
| Register | Bits | Holds |
|---|---|---|
| AC | 16 | working value / result |
| MAR | 12 | address for memory |
| MBR | 16 | data to/from memory |
| PC | 12 | address of next instruction |
| IR | 16 | current instruction |
| InREG / OutREG | 8 / 8 | input / output |
Address registers (MAR, PC) are 12 bits because memory has 4K = words; data registers (AC, MBR, IR) are 16 bits because a word is 16 bits.
Bit-by-bit examples (Load 3, Skipcond 800) and the full opcode table in binary and hex: see Section 6.5.
| Hex | Instruction | RTN (after fetch/decode) |
|---|---|---|
| 0 | JnS X | M[X] ← PC; PC ← X + 1 |
| 1 | Load X | MAR ← X; MBR ← M[MAR]; AC ← MBR |
| 2 | Store X | MAR ← X, MBR ← AC; M[MAR] ← MBR |
| 3 | Add X | MAR ← X; MBR ← M[MAR]; AC ← AC + MBR |
| 4 | Subt X | MAR ← X; MBR ← M[MAR]; AC ← AC − MBR |
| 5 | Input | AC ← InREG |
| 6 | Output | OutREG ← AC |
| 7 | Halt | stop |
| 8 | Skipcond | skip next instruction if condition is true |
| 9 | Jump X | PC ← IR[11–0] |
| A | Clear | AC ← 0 |
| B | AddI X | AC ← AC + M[M[X]] |
| C | JumpI X | PC ← M[X] |
| D | LoadI X | AC ← M[M[X]] |
| E | StoreI X | M[M[X]] ← AC |
| Instruction | Hex | Skips next when |
|---|---|---|
| Skipcond 000 | 8000 | AC < 0 |
| Skipcond 400 | 8400 | AC = 0 |
| Skipcond 800 | 8800 | AC > 0 |
- AC is two’s complement: any value 8000–FFFF is negative (FFFB = −5, so Skipcond 000 skips and Skipcond 800 does not).
- Input, Output, Halt, Clear, Skipcond have no real address: Halt = 7000, Clear = A000.
- Split the word: first hex digit = opcode, last three = address X.
- Look up the opcode (or mnemonic) in the table.
- Write the address as 3 hex digits, then convert each hex digit to 4 bits for binary.
| Assembly | Opcode (hex) | Address (3 hex) | Hex word | Binary (4 + 12 bits) | RTN / meaning |
|---|---|---|---|---|---|
Worked example: encode, decode, indirect addressing
| Given | Split | Answer |
|---|---|---|
| Store 1A3 | 2 / 1A3 | 21A3 = 0010 0001 1010 0011 |
| AddI 20F | B / 20F | B20F = 1011 0010 0000 1111 |
| C108 | C / 108 | JumpI 108 (PC ← M[108]) |
| 0010 0000 0000 0111 | 2 / 007 | Store 007 (M[007] ← AC) |
| 1000 1000 0000 0000 | 8 / 800 | Skipcond 800 (skip if AC > 0) |
With M[200] = 0205, M[205] = 0042, AC = 0010 (each instruction starts from this state):
| Instruction | What happens | Result |
|---|---|---|
| Load 200 | AC ← M[200] | AC = 0205 |
| LoadI 200 | M[200] = 0205 is a pointer, AC ← M[205] | AC = 0042 |
| AddI 200 | AC ← 0010 + M[205] | AC = 0052 |
| StoreI 200 | M[205] ← AC | M[205] = 0010 |
| JumpI 200 | PC ← M[200] | PC = 205 |
6.3 The Fetch–Decode–Execute Cycle
| Stage | RTN | Meaning |
|---|---|---|
| Fetch | MAR ← PC | send the address of the next instruction to memory |
| IR ← M[MAR] | read the instruction into the IR | |
| PC ← PC + 1 | point to the following instruction | |
| Decode | MAR ← IR[11–0]; decode IR[15–12] | address field to the MAR; find the opcode |
| Get operand | MBR ← M[MAR] | only for instructions that read memory (Load, Add, Subt …) |
| Execute | e.g. AC ← AC + MBR | the instruction’s own steps, then back to fetch |
- Start with the initial register values (PC = first address).
- Write one row per microoperation, in the order of the table above.
- On each row change only the register on the left of ←; the others keep their value.
- Memory reads give the next register its value (use the stated memory contents); AC arithmetic is two’s complement hex.
| Stage | RTN | PC | IR | MAR | MBR | AC |
|---|---|---|---|---|---|---|
| (initial) | ||||||
| Fetch | MAR ← PC | |||||
| IR ← M[MAR] | ||||||
| PC ← PC + 1 | ||||||
| Decode | MAR ← IR[11–0] | |||||
| Get operand | MBR ← M[MAR] | |||||
| Execute |
Worked example: Load 104, Add 105, Store 106 (M[104] = 0023, M[105] = FFE9, PC = 100)
| Instr. | RTN | PC | IR | MAR | MBR | AC |
|---|---|---|---|---|---|---|
| (initial) | 100 | ---- | --- | ---- | ---- | |
| Load 104 | MAR ← PC | 100 | ---- | 100 | ---- | ---- |
| IR ← M[MAR] | 100 | 1104 | 100 | ---- | ---- | |
| PC ← PC + 1 | 101 | 1104 | 100 | ---- | ---- | |
| MAR ← IR[11–0] | 101 | 1104 | 104 | ---- | ---- | |
| MBR ← M[MAR] | 101 | 1104 | 104 | 0023 | ---- | |
| AC ← MBR | 101 | 1104 | 104 | 0023 | 0023 | |
| Add 105 | MAR ← PC | 101 | 1104 | 101 | 0023 | 0023 |
| IR ← M[MAR] | 101 | 3105 | 101 | 0023 | 0023 | |
| PC ← PC + 1 | 102 | 3105 | 101 | 0023 | 0023 | |
| MAR ← IR[11–0] | 102 | 3105 | 105 | 0023 | 0023 | |
| MBR ← M[MAR] | 102 | 3105 | 105 | FFE9 | 0023 | |
| AC ← AC + MBR | 102 | 3105 | 105 | FFE9 | 000C | |
| Store 106 | MAR ← PC | 102 | 3105 | 102 | FFE9 | 000C |
| IR ← M[MAR] | 102 | 2106 | 102 | FFE9 | 000C | |
| PC ← PC + 1 | 103 | 2106 | 102 | FFE9 | 000C | |
| MAR ← IR[11–0] | 103 | 2106 | 106 | FFE9 | 000C | |
| MBR ← AC | 103 | 2106 | 106 | 000C | 000C | |
| M[MAR] ← MBR | 103 | 2106 | 106 | 000C | 000C |
FFE9 = −23, so AC = 35 − 23 = 12 = 000C. Final: M[106] = 000C.
- PC is incremented during fetch, so jumps and JnS see the already-incremented PC.
- Store has no memory read: it copies AC to MBR, then writes M[MAR].
6.4 MARIE Assembly and the Two-Pass Assembler
A source line is Label, Mnemonic Operand / comment. Directives: ORG n (start at hex address n), DEC n (decimal data word; negatives in two’s complement), HEX n (hex data word), END. Put the data after Halt.
- Pass 1: start the location counter (LC) at the ORG value. Give each line one address (every instruction and every DEC/HEX takes one word). Each label and its LC go into the symbol table.
- Pass 2: for each line write the opcode hex digit + the label’s address (3 hex digits). DEC/HEX lines give the 4-digit hex value.
| Address (LC) | Label | Instruction | Opcode | Operand address | Hex |
|---|---|---|---|---|---|
| Symbol | Address |
|---|---|
Control structures = test, Skipcond, Jump. Put a value in the AC whose sign answers the question (usually AC = X − Y). Skipcond skips the Jump when the condition is true.
| Condition | Compute | Skipcond meaning “condition true” |
|---|---|---|
| X > Y | X − Y | 800 (AC > 0) |
| X < Y | X − Y | 000 (AC < 0) |
| X = Y | X − Y | 400 (AC = 0) |
For ≥, ≤ or ≠, test the opposite condition and swap the THEN and ELSE parts.
/ if (X > Y) THEN-part ; else ELSE-part
Load X
Subt Y
Skipcond 800 / X-Y > 0 ?
Jump Else / no -> else
...THEN-part...
Jump EndIf
Else, ...ELSE-part...
EndIf, ...
/ while (X < Limit) body
Loop, Load X
Subt Limit
Skipcond 000 / X-Limit < 0 ?
Jump Done / no -> leave loop
...body...
Jump Loop
Done, ...
/ subroutine call and return
JnS Sub / M[Sub] <- return addr
Sub, HEX 0 / holds return address
...body...
JumpI Sub / go back
Worked example: if X > 1 then X = 0 after Y = X + X; then Y = Y + 1 (X = 2, Y = 10)
| Addr | Source | Hex |
|---|---|---|
| 100 | If, Load X | 110D |
| 101 | Subt One | 410F |
| 102 | Skipcond 800 | 8800 |
| 103 | Jump EndIf | 9109 |
| 104 | Then, Load X | 110D |
| 105 | Add X | 310D |
| 106 | Store Y | 210E |
| 107 | Clear | A000 |
| 108 | Store X | 210D |
| 109 | EndIf, Load Y | 110E |
| 10A | Add One | 310F |
| 10B | Store Y | 210E |
| 10C | Halt | 7000 |
| 10D | X, Dec 2 | 0002 |
| 10E | Y, Dec 10 | 000A |
| 10F | One, Dec 1 | 0001 |
| Symbol | Address |
|---|---|
| If | 100 |
| Then | 104 |
| EndIf | 109 |
| X | 10D |
| Y | 10E |
| One | 10F |
Trace: AC = 2 − 1 = 1 > 0, so the Jump is skipped. Y = 2 + 2 = 4, X = 0. Then Y = 4 + 1. Result: Y = 5, X = 0. (With X = 1: AC = 0, no skip, Jump EndIf is taken, only Y = Y + 1 = 11 runs.)
- Skipcond skips the next line, so the line after it must be the Jump that handles the false case.
- JnS stores the return address in the first word of the subroutine; return with JumpI.
7.1 Control Signals, Timing Diagrams and Microprogramming
| Device | Memory | MAR | PC | MBR | AC | InREG | OutREG | IR |
|---|---|---|---|---|---|---|---|---|
| Bus number | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
One RTL step becomes signals: source number on , destination number on (list only the bits that are 1). Reading memory adds , writing adds . ALU into AC: = 01 add (), 10 subtract (), 11 clear; add and . Add the time signal (execution starts at ; fetch/decode use –) and on the last step. One bus means only one bus transfer per clock cycle.
- Write the execute steps in RTL, one bus transfer per cycle starting at .
- For each step find the source and destination device numbers.
- Source number gives the bits that are 1; destination number gives the bits that are 1.
- Add / / / / as needed, then , and on the last cycle.
| Cycle | RTL | Source, | Dest, | Extra (, , , , ) | Signals that are 1 |
|---|---|---|---|---|---|
Worked example: control signals for Add X, Load X, Store X, JumpI X
| Instr. | Cycle | RTL | Source / Dest | Signals |
|---|---|---|---|---|
| Add X | MAR ← X | IR 111 / MAR 001 | ||
| MBR ← M[MAR] | memory 000 / MBR 011 | |||
| AC ← AC + MBR | ALU / AC 100 | |||
| Load X | MAR ← X | IR 111 / MAR 001 | ||
| MBR ← M[MAR] | memory 000 / MBR 011 | |||
| AC ← MBR | MBR 011 / AC 100 | |||
| Store X | MAR ← X | IR 111 / MAR 001 | ||
| MBR ← AC | AC 100 / MBR 011 | |||
| M[MAR] ← MBR | MBR 011 / memory 000 | |||
| JumpI X | MAR ← X | IR 111 / MAR 001 | ||
| MBR ← M[MAR] | memory 000 / MBR 011 | |||
| PC ← MBR | MBR 011 / PC 010 |
Subt X is the same as Add X except the last step uses (subtract) instead of . One-step Jump X in : (IR → PC).
Worked example: timing diagram for Add X. One row per signal; a signal is high in exactly the cycles whose list contains it (for example is in the and lists, so it is high in both).
- only on the last cycle; / do not add P bits (memory = 000).
- Load’s last step (MBR → AC) uses the bus (), not the ALU.
Hardwired control
Opcode bits go to an instruction decoder (one AND gate per instruction); a ring counter gives ; each signal = OR of (instruction · time).
- Add (0011); Load (0001).
- Using only Load and Add:
Microprogrammed control
Each instruction is a small routine of microinstructions in a ROM (control store); one microinstruction per clock cycle. Slower (extra fetch/decode level) but easy to change; hardwired is faster but must be redesigned to change.
18 bits. Dest is 7 bits because the microprogram has at most lines (128 × 18 = 2304 bits of ROM). A routine ends with Jump = 1, Dest = 0000000 (back to fetch).
| Code | Microoperation | Code | Microoperation | Code | Microoperation |
|---|---|---|---|---|---|
| 00000 | NOP | 01001 | MAR ← MBR | 10010 | If AC = 00 |
| 00001 | AC ← 0 | 01010 | MAR ← PC | 10011 | If AC > 0 |
| 00010 | AC ← MBR | 01011 | MAR ← X | 10100 | If AC < 0 |
| 00011 | AC ← AC − MBR | 01100 | MBR ← AC | 10101 | If IR[11–10] = 00 |
| 00100 | AC ← AC + MBR | 01101 | MBR ← M[MAR] | 10110 | If IR[11–10] = 01 |
| 00101 | AC ← InREG | 01110 | OutREG ← AC | 10111 | If IR[11–10] = 10 |
| 00110 | IR ← M[MAR] | 01111 | PC ← IR[11–0] | 11000 | If IR[15–12] = MicroOp2[4–1] |
| 00111 | M[MAR] ← MBR | 10000 | PC ← MBR | ||
| 01000 | MAR ← IR[11–0] | 10001 | PC ← PC + 1 |
- List the RTN steps of the instruction (one microoperation per MicroOp field).
- Look up each code in the table above; put it in MicroOp1 (MicroOp2 = 00000 if unused).
- Number the lines from the start address; Jump = 0, Dest = 0000000 on all but the last line.
- On the last line set Jump = 1, Dest = 0000000 (return to fetch). Join the fields into the 18-bit word.
| Address (7 bits) | MicroOp1 | MicroOp2 | Jump | Dest (7 bits) | 18-bit word |
|---|---|---|---|---|---|
| 00000 | 0 | 0000000 | |||
| 00000 | 0 | 0000000 | |||
| 00000 | 1 | 0000000 |
Worked example: microcode for Load (starting at line 0110000)
| Address | MicroOp1 | MicroOp2 | Jump | Dest |
|---|---|---|---|---|
| 0110000 | 01000 (MAR ← IR[11–0]) | 00000 | 0 | 0000000 |
| 0110001 | 01101 (MBR ← M[MAR]) | 00000 | 0 | 0000000 |
| 0110010 | 00010 (AC ← MBR) | 00000 | 1 | 0000000 |
Worked example: decode 11000 00110 1 0101100. 11000 = “if IR[15–12] = MicroOp2[4–1]”; MicroOp2[4–1] = 0011 = Add; Jump = 1 to 0101100 (line 44). If the IR holds 3105 (opcode 3), control jumps to the Add routine; if the IR holds 1104 (Load) there is no match and control goes on to the next line.
- A routine must end with Jump = 1, Dest = 0000000, or control never returns to fetch.
- MicroOp2[4–1] drops the last bit: 00110 gives 0011 (opcode 3).
6. Quick Reference
All the formulas on one page, the reference tables the problems refer to (gates, flip-flops, number tables, MARIE format), and the checks to run before you hand in.
6.1 Formulas
Units, time and growth
| Topic | Formula / rule |
|---|---|
| Time and frequency | · |
| Execution time | instruction time cycles · program time instructions CPI |
| Sizes (memory) | , , , |
| Sizes (speed, disk) | , , |
| Doubling laws | · Moore months (original: 1 year) · Rock years |
Number representation and arithmetic
| Topic | Formula / rule |
|---|---|
| Range with bits | unsigned · SM, 1C · 2C |
| Negation | SM: flip sign bit · 1C: flip all bits · 2C: flip all bits, add 1 |
| Overflow | 2C: · 1C: add the end-around carry · 2C: drop the carry |
| Floating point | · bias 16 (14-bit), 127 (single), 1023 (double) |
| FP multiply / divide | multiply: · divide: |
Error detection and correction
| Topic | Formula / rule |
|---|---|
| CRC | key of bits → append zeros → mod-2 divide → -bit remainder replaces the zeros · receiver remainder = accept |
| Hamming | smallest with · check bits at 1, 2, 4, 8, 16 · syndrome = error position |
| detect errors · correct |
Boolean algebra and digital logic
| Topic | Formula / rule |
|---|---|
| Boolean laws | DeMorgan , · · · |
| Adders | Sum · |
| Decoder / mux | decoder: inputs → outputs · mux: data inputs → select lines |
| Flip-flops | SR: · JK: · D: · T: |
| Memory | address bits · chips · select bits total inside chip |
MARIE and control
| Topic | Formula / rule |
|---|---|
| MARIE word | 16-bit word 4-bit opcode 12-bit address · 4K words |
| Skipcond | (), (), () |
| Control signals | source → , destination → · Mem 0, MAR 1, PC 2, MBR 3, AC 4, InREG 5, OutREG 6, IR 7 |
| ALU | : add, subtract, clear |
6.2 Logic gates
Table 6.2a: the seven gates. and are the inputs, the output.
| Gate | Symbol | Expression | when | Made from NAND only | Made from NOR only |
|---|---|---|---|---|---|
| NOT | the input is 0 | NAND(, ) | NOR(, ) | ||
| AND | all inputs are 1 | NOT(NAND(, )) | NOR(, ) | ||
| OR | any input is 1 | NAND(, ) | NOT(NOR(, )) | ||
| XOR | the inputs differ | 4 NAND gates (see 4.1) | 5 NOR gates | ||
| NAND | any input is 0 | NAND | NOT(NOR(, )) | ||
| NOR | all inputs are 0 | NOT(NAND(, )) | NOR | ||
| XNOR | the inputs are equal | XOR, then NOT | 4 NOR gates |
Table 6.2b: truth tables
| NOT | AND | OR | XOR | NAND | NOR | XNOR | ||
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 |
Table 6.2c: how the gates relate
| Relation | Meaning |
|---|---|
| A bubble (small circle) means NOT | NAND is AND with a bubble on the output; NOR is OR with one; XNOR is XOR with one. |
| NAND and NOR are universal | Any circuit can be built from NAND alone (or NOR alone). They are cheap, fast and low-power, so chips use them. |
| DeMorgan swaps AND and OR | : a NAND is the same as an OR with bubbles on both inputs. : a NOR is an AND with input bubbles. |
| AND–OR becomes NAND–NAND | : every AND and the final OR in a sum of products can become a NAND (see 4.1). |
| XOR is a “difference” detector | when the bits differ; it is the sum bit of a half adder and the parity of the inputs. |
6.3 Flip-flops
A flip-flop stores one bit, . Its next value (also written ) is set at the clock tick from the inputs and the present . Flip-flops change on the clock edge (edge-triggered) or while the clock is high (level-triggered).
Table 6.3a: SR (set/reset) flip-flop
| Symbol | Inside |
|---|---|
| Two NOR gates, each output fed back into the other gate’s input. |
| Action | |||
|---|---|---|---|
| 0 | 0 | no change | |
| 0 | 1 | 0 | reset |
| 1 | 0 | 1 | set |
| 1 | 1 | undefined | not allowed (unstable) |
Equation (with ): .
Table 6.3b: JK flip-flop
| Symbol | Inside |
|---|---|
| An SR flip-flop with two AND gates in front: , . |
| Action | |||
|---|---|---|---|
| 0 | 0 | no change | |
| 0 | 1 | 0 | reset |
| 1 | 0 | 1 | set |
| 1 | 1 | toggle |
Equation: .
| 0 → 0 | 0 | d |
| 0 → 1 | 1 | d |
| 1 → 0 | d | 1 |
| 1 → 1 | d | 0 |
The last table is the JK excitation table (which inputs cause a given change; d = don’t care). Use it when you design or convert a flip-flop.
Table 6.3c: D (data) flip-flop
| Symbol | Inside |
|---|---|
| An SR flip-flop with and (one inverter). |
| Action | ||
|---|---|---|
| 0 | 0 | store 0 |
| 1 | 1 | store 1 |
Equation: . The output only changes when changes. A row of D flip-flops sharing one clock is a register; the D flip-flop is the basic cell of computer memory.
Table 6.3d: how the flip-flops relate
| Flip-flop | Built from | Inputs 11 | Use it for |
|---|---|---|---|
| SR | two NOR gates with feedback | not allowed | the basic memory cell |
| JK | SR + AND gates , | toggle | general design: no forbidden input |
| D | SR + inverter , | cannot happen () | registers and memory |
| T | JK with | (one input) 1 = toggle | binary counters () |
6.4 Number tables
Table 6.4a: 4-bit binary → hex (and decimal). One hex digit is exactly 4 bits, so convert binary ↔ hex one group of 4 at a time.
| Binary | Hex | Decimal | Binary | Hex | Decimal |
|---|---|---|---|---|---|
| 0000 | 0 | 0 | 1000 | 8 | 8 |
| 0001 | 1 | 1 | 1001 | 9 | 9 |
| 0010 | 2 | 2 | 1010 | A | 10 |
| 0011 | 3 | 3 | 1011 | B | 11 |
| 0100 | 4 | 4 | 1100 | C | 12 |
| 0101 | 5 | 5 | 1101 | D | 13 |
| 0110 | 6 | 6 | 1110 | E | 14 |
| 0111 | 7 | 7 | 1111 | F | 15 |
Table 6.4b: powers of 2 (binary place values; , , )
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 20 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096 | 65 536 | 1 048 576 |
Fractions: , , , , .
Table 6.4c: bit positions in binary (Hamming codes). Positions are counted from 1 at the right. Each 1 in a position’s binary form names a check bit that covers it; the check bits sit at the powers of 2.
| Position | Binary (16 8 4 2 1) | Covered by | Position | Binary (16 8 4 2 1) | Covered by |
|---|---|---|---|---|---|
| 1 | 00001 | P1 (check bit) | 9 | 01001 | P8, P1 |
| 2 | 00010 | P2 (check bit) | 10 | 01010 | P8, P2 |
| 3 | 00011 | P2, P1 | 11 | 01011 | P8, P2, P1 |
| 4 | 00100 | P4 (check bit) | 12 | 01100 | P8, P4 |
| 5 | 00101 | P4, P1 | 13 | 01101 | P8, P4, P1 |
| 6 | 00110 | P4, P2 | 14 | 01110 | P8, P4, P2 |
| 7 | 00111 | P4, P2, P1 | 15 | 01111 | P8, P4, P2, P1 |
| 8 | 01000 | P8 (check bit) | 16 | 10000 | P16 (check bit) |
So P1 covers 1, 3, 5, 7, 9, 11, 13, 15; P2 covers 2, 3, 6, 7, 10, 11, 14, 15; P4 covers 4–7 and 12–15; P8 covers 8–15.
Table 6.4d: floating-point formats
| Format | Total bits | Sign | Exponent | Fraction | Bias | Normal exponent | Precision |
|---|---|---|---|---|---|---|---|
| Lecture 14-bit model | 14 | 1 | 5 | 8 | 16 | 8 fraction bits | |
| IEEE single precision | 32 | 1 | 8 | 23 | 127 | about 7 decimal digits, up to about | |
| IEEE double precision | 64 | 1 | 11 | 52 | 1023 | about 15–16 decimal digits, up to about |
Value . Special patterns (single; for double read 2047 for 255):
| Exponent | Fraction | Meaning | Example (single, hex) |
|---|---|---|---|
| 0 | 0 | zero ( or ) | 00000000, 80000000 |
| 1 – 254 | anything | normal number | 3F800000 = 1.0 |
| 255 (all 1s) | 0 | or | 7F800000, FF800000 |
| 255 | not 0 | NaN (not a number) | 7FC00000 |
6.5 MARIE instruction format
Every MARIE instruction is one 16-bit word: a 4-bit opcode (bits 15–12, one hex digit) and a 12-bit address (bits 11–0, three hex digits). So the hex word is the opcode digit followed by the address: Load 003 = 1003.
Load 3 as it sits in the IR: opcode 1 (0001), address 3.
| opcode | address | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Skipcond 800 as it sits in the IR: opcode 8 (1000); bits 11–10 = 10 mean “skip the next instruction if AC > 0”.
| opcode | address | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Bits 11–10 | Hex word | Skips the next instruction when |
|---|---|---|
| 00 | 8000 | AC < 0 |
| 01 | 8400 | AC = 0 |
| 10 | 8800 | AC > 0 |
Table 6.5: MARIE opcodes
| Binary | Hex | Instruction | Meaning |
|---|---|---|---|
| 0000 | 0 | JnS X | store the PC at X, jump to X + 1 (subroutine call) |
| 0001 | 1 | Load X | load the contents of address X into AC |
| 0010 | 2 | Store X | store the contents of AC at address X |
| 0011 | 3 | Add X | add the contents of address X to AC |
| 0100 | 4 | Subt X | subtract the contents of address X from AC |
| 0101 | 5 | Input | input a value from the keyboard into AC |
| 0110 | 6 | Output | output the value in AC to the display |
| 0111 | 7 | Halt | terminate the program |
| 1000 | 8 | Skipcond | skip the next instruction on a condition |
| 1001 | 9 | Jump X | load the value of X into PC |
| 1010 | A | Clear | put 0 in AC |
| 1011 | B | AddI X | add indirect: AC ← AC + M[M[X]] |
| 1100 | C | JumpI X | jump indirect: PC ← M[X] |
| 1101 | D | LoadI X | load indirect: AC ← M[M[X]] |
| 1110 | E | StoreI X | store indirect: M[M[X]] ← AC |
6.6 Exam-day checklist
Number conversion and arithmetic
- Base conversion: convert the answer back to decimal. Integer remainders are read bottom-up, fraction bits top-down.
- Signed numbers: is the result within the range of bits? Overflow means carry into MSB carry out. Check the answer in decimal.
- Floating point: bias added (16 or 127)? Hidden 1 not stored? Fraction padded on the right? Decode your pattern to check.
Error codes
- Parity / CRC: count the 1s again. CRC: the zeros are appended at the sender only; the remainder has bits; the codeword divides with remainder 0.
- Hamming: positions counted from the right; check bits at 1, 2, 4, 8; every group (check bit plus the positions it covers) has an even number of 1s.
Logic design
- K-map: Gray order 00 01 11 10; groups of 1, 2, 4, 8; wrap-around used; every 1 covered; test one 0-row and one 1-row against your answer.
- Flip-flops: use present values only; JK = toggle; SR is not allowed.
MARIE and control
- MARIE: address is 3 hex digits; DEC negatives in two’s complement; data placed after Halt; symbol-table addresses match the code; trace the AC.
- Control signals: source → , destination → ; / for memory; only on the last step; one bus transfer per cycle.