S0.8.1 Follow the Forced Jump

EasyImplement12 minIcarus Verilog · serverReview the topic

Step a program through a reset and one timer interrupt, and find where the PC goes and comes back.

Hardware context: Teaching processor with a reset and one timer interrupt. Reading an interrupt entry and return in a trace

The teaching processor of lesson S0.8 runs the two programs below. Reset is held for the first two clock edges, e1 and e2, and one instruction runs at every edge after that. The reset address is 0 and the handler starts at address 8. The timer fires at edge e7. The switches at address 15 show 6.

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)InstructionPart of
0LOAD r1, 12main program
1LOAD r2, 13main program
2ADD r0, r1main program
3SUB r1, r2main program
4JUMPNZ r1, 2main program
5STORE r0, 11main program
6HALTmain program
8LOAD r3, 15handler
9STORE r3, 14handler
10RETIhandler
12the number 2data
13the number 1data

An interrupt is taken at the edge where the timer fires, before the instruction of that edge is fetched. The first instruction of the handler runs at that same edge.

EntryYour decision
FIRST_EDGENumber of the edge at which the first instruction runs.
FIRST_PCAddress of the first fetch after reset.
PC_AT_E6Address of the instruction that runs at edge 6.
SAVED_PCAddress that goes into the saved PC when the interrupt is taken.
FORCED_PCAddress forced into the PC at edge 7.
LAMPSValue that the handler writes to the lamps.
RETI_EDGENumber of the edge at which RETI runs.
RESUME_PCAddress of the instruction that runs at edge 10.
LOST_EDGESNumber of edges the main program lost to the interrupt.
SUMValue in box 11 when the processor halts.
HALT_EDGENumber of the edge at which HALT runs.
LATE_HALT_EDGEAt which edge would the HALT run if the handler had EXTRA more instructions before its RETI?

Examples

Example 1

FIRST EDGE
Input
Number of the edge at which the first instruction runs.
Output
matches = 1

Edges 1 and 2 are spent in reset. The instruction in box 0 runs at edge 3.

Example 2

FIRST PC
Input
Address of the first fetch after reset.
Output
matches = 1

A reset forces the PC to the reset address, 0.

Example 3

PC AT E6
Input
Address of the instruction that runs at edge 6.
Output
matches = 1

Edges 3, 4, 5 and 6 run boxes 0, 1, 2 and 3.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For LATE_HALT_EDGE, enter a constant expression using EXTRA. Only this entry changes with the parameter. The supported integer range is 0 through 15, inclusive.

Hints

Hint 1

Write one row for each edge from 3 onwards, with the PC and the instruction.

Hint 2

At edge 7, note the PC as the saved PC, and carry on from address 8.

Hint 3

After RETI, carry on from the saved PC as if nothing had happened.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

12 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 1 problem 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

FIRST EDGE

Input
Number of the edge at which the first instruction runs.
Expected output
matches = 1

Edges 1 and 2 are spent in reset. The instruction in box 0 runs at edge 3.

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

Icarus Verilog · server