Decode a program stored as numbers and step it through fetch, decode and execute.
Hardware context: Sixteen-box stored-program machine. First model of any processor
The sixteen-box machine of lesson S0.1 holds the program below. An instruction is stored as kind times 16 plus the address. The kinds are HALT 0, LOAD 1, ADD 2 and STORE 3. The PC starts at 0.
This worksheet uses named constants. The first three entries show how to record your decisions.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Box (address) | Content |
|---|---|
| 0 | 25 |
| 1 | 41 |
| 2 | 42 |
| 3 | 59 |
| 4 | 0 |
| 9 | 6 |
| 10 | BOX10 |
| 11 | 0 |
Every box not listed holds 0. Box 10 holds the value of the parameter BOX10.
| Entry | Your decision |
|---|---|
| KIND_0 | Kind number of the instruction in box 0. |
| ADDR_0 | Address part of the instruction in box 0. |
| A_AFTER_0 | Register A after the first instruction has run. |
| KIND_1 | Kind number of the instruction in box 1. |
| A_AFTER_1 | Register A after the second instruction has run. |
| ADDR_2 | Address part of the instruction in box 2. |
| PC_AFTER_2 | The PC after the third instruction has run. |
| STORE_BOX | The box that the fourth instruction changes. |
| HALT_PC | The PC value at which the machine fetches HALT. |
| STORE_15 | The number that means STORE 15 on this machine. |
| RESULT | What does box 11 hold when the machine halts, if box 10 starts with the value BOX10? |
Examples
Example 1
KIND 0- Input
Kind number of the instruction in box 0.
- Output
matches = 1
25 is 1 times 16 plus 9, so the kind is 1: LOAD.
Example 2
ADDR 0- Input
Address part of the instruction in box 0.
- Output
matches = 1
Taking 16 away from 25 leaves 9.
Example 3
A AFTER 0- Input
Register A after the first instruction has run.
- Output
matches = 1
LOAD 9 copies the content of box 9, which is 6.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For RESULT, enter a constant expression using BOX10. Only this entry changes with the parameter. The supported integer range is 0 through 20, inclusive.
Hints
Hint 1
Divide each program number by 16. The quotient is the kind and the remainder is the address.
Hint 2
An instruction names a box. It works on what is inside that box.
Hint 3
After each instruction the PC moves on by one.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
11 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path