S8.4.3 Decode a Trace by Hand

EasyImplement12 minIcarus Verilog · serverReview the topic

Rebuild the path of a program from its listing and six packets, and find where an interrupt broke in.

Hardware context: Trace funnel and circular sink. Postmortem instruction history

This is the decoder of lesson S8.4 with another program. A decoder walks the listing from the start address. It takes a packet only where the listing cannot tell what comes next. Packet S gives the start address. Packet T means that a branch was taken, packet N that it was not. Packet I gives the address of the instruction that an interrupt held up: the program goes to the handler in its place. Packet A gives the address to which a return went.

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
AddressInstruction
16Plain
20Branch to 32
24Plain
28Jump to 20
32Plain
36Stop
96Plain. The interrupt handler starts here.
100Return

The capture holds six packets, in this order: S 16, N, I 28, A 28, N, T. All numbers on this page are decimal, and instructions are four apart. The path is the list of every address that ran, in order. Count the stop as an instruction.

EntryYour decision
FIRSTThe first address on the path.
SECONDThe second address on the path.
THIRDThe third address on the path.
FOURTHThe fourth address on the path.
IN_HANDLERHow many instructions of the handler ran?
AFTER_RETURNThe address that ran straight after the return.
BRANCH_RUNSHow many times did the branch at 20 run?
BEFORE_IRQHow many instructions ran before the interrupt broke in?
LASTThe last address on the path.
TOTALHow many instructions are on the path?
NO_PACKETHow many of those instructions needed no packet of their own? Count T, N and A as the packet of an instruction. Do not count S or I.
TOTAL_NSuppose the capture had N more packets N just before its last packet. How many instructions would be on the path?

Examples

Example 1

FIRST
Input
The first address on the path.
Output
matches = 1

The packet S gives the start address.

Example 2

SECOND
Input
The second address on the path.
Output
matches = 1

The instruction at 16 is plain, so 20 follows. No packet is needed.

Example 3

THIRD
Input
The third address on the path.
Output
matches = 1

The branch at 20 takes the packet N: not taken, so 24 follows.

Constraints and Contract

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

Hints

Hint 1

Start at the address in the packet S. After a plain instruction or a jump, the listing gives the next address.

Hint 2

A branch takes T or N. A return takes A.

Hint 3

Before each instruction, look at the next packet. If it is I with this address, go to the handler.

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 3 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

FIRST

Input
The first address on the path.
Expected output
matches = 1

The packet S gives the start address.

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

Icarus Verilog · server