V5.4.1 Guard Rails and Cover Points

MediumImplement22 minIcarus Verilog · serverReview the topic

Name the guard rail behind each rule of the chip's random program generator. Then read what twenty recorded random programs reached and missed.

Hardware context: Random programs of the chip's lockstep gate on ap_soc v1.5, with real interrupt lines. Naming guard rails and reading recorded coverage.

The lockstep gate of the chip runs random programs from tools/soc/rv32/random-program.mjs with the chip's blocks around them (random-chip.mjs). Seeds 1 to 20 were rerun for this sheet on ap_soc v1.5, the model compare on. 20 of 20 passed: 10,731 records in all, 0 mismatches.

This worksheet uses named constants. The first three entries show how to record your decisions.

Replace each unresolved value of 65535 with your result.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
CodeGuard rail
1A register no random instruction may write
2Branches and jumps only forward, to a known place
3A fixed trap handler that steps over a faulting instruction
4An end every program reaches
5Not a guard rail
Counted from the retire records of the recorded runs (the bins of lesson V5.4).
BinHits in 20 seedsSeeds that hit it
raw1422520
raw255620
load_use8518
load_store3012
store_load00
branch_raw104220
csr_raw11
x0_write22
EntryYour decision
LOOP_COUNTERx25 and x26 count loops down; no random instruction writes them.
FORWARDA branch goes to the start of a later block.
STEP_OVERAn illegal word raises an exception; the handler adds 4 to mepc.
RAM_POINTERx28 always points into SRAM.
LAST_WORDThe program ends with TB_STATUS = 0x900D and a jump to itself.
RANDOM_VALUEAn immediate is picked from a list of edge values half the time.
RAW1_HITSHits of raw1 in all 20 seeds.
STORE_LOAD_SEEDSSeeds that hit store_load.
CSR_SEEDSSeeds that hit csr_raw.
RAW2_ATHits of raw2 for random program SEED.

Examples

Example 1

LOOP COUNTER
Input
x25 and x26 count loops down; no random instruction writes them.
Output
matches = 1

A loop counter that random code changes can turn a loop into one that never ends.

Example 2

FORWARD
Input
A branch goes to the start of a later block.
Output
matches = 1

Backward targets chosen at random can make loops with no exit.

Example 3

STEP OVER
Input
An illegal word raises an exception; the handler adds 4 to mepc.
Output
matches = 1

The program goes on after any exception, so a bad word costs one trap, not the run.

Constraints and Contract

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

Hints

Hint 1

Ask what would kill the program without the rule.

Hint 2

The table counts each bin over the twenty seeds.

Hint 3

A bin with no seed is a hole: the generator needs a directed sequence for it.

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

14 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

LOOP COUNTER

Input
x25 and x26 count loops down; no random instruction writes them.
Expected output
matches = 1

A loop counter that random code changes can turn a loop into one that never ends.

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

Icarus Verilog · server