S0.1.1 Run the Program by Hand

EasyImplement12 minIcarus Verilog · serverReview the topic

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

SignalWidthRole
question8input of each check
Full specification
Box (address)Content
025
141
242
359
40
96
10BOX10
110

Every box not listed holds 0. Box 10 holds the value of the parameter BOX10.

EntryYour decision
KIND_0Kind number of the instruction in box 0.
ADDR_0Address part of the instruction in box 0.
A_AFTER_0Register A after the first instruction has run.
KIND_1Kind number of the instruction in box 1.
A_AFTER_1Register A after the second instruction has run.
ADDR_2Address part of the instruction in box 2.
PC_AFTER_2The PC after the third instruction has run.
STORE_BOXThe box that the fourth instruction changes.
HALT_PCThe PC value at which the machine fetches HALT.
STORE_15The number that means STORE 15 on this machine.
RESULTWhat 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

KIND 0

Input
Kind number of the instruction in box 0.
Expected output
matches = 1

25 is 1 times 16 plus 9, so the kind is 1: LOAD.

Run samples executes all 3 public checks. Check all tests runs 11 checks on the server.

Icarus Verilog · server