U17.6.1 The Interrupt That Fired During Service

HardImplementUVM · server3 hidden designsReview the topic

Write the interrupt service for a peripheral with two sources. Serve every interrupt, keep main traffic out of a service, serve the error first, and report three design faults.

Hardware context: APB peripheral with a FIFO-threshold and an error interrupt, a write-1-to-clear STATUS and a MASK register. Write an interrupt service sequence and its loop, and report a stuck status bit, a stuck line and a masked source.

A peripheral raises a level interrupt for two sources, a FIFO threshold and an error. STATUS says which are pending, and writing 1 clears a bit. Main traffic writes twelve DATA bytes on the same APB sequencer.

Write irq_service, one service, and irq_loop, which waits for the line and starts a service each time. Serve every interrupt, including one already pending when the loop starts and one that fires during a service. Once the line has been high for 40 ns, no main write may start until STATUS is clear. When both sources are pending, clear the error first.

Three banks hide a design fault. Call ctx.flag() when the design is wrong, without hanging the test or keeping main traffic out for good. A fault counts as reported only when the bank also shows that you handled it. That means the stuck bit masked, main traffic finished, or the missing interrupt found by final_check. Your code cannot know which bank is which.

Full specification
What you write (the starter only waits for edges)
// One service: called by the loop, on the bus sequencer, while the line is high.
class irq_service extends irq_service_base;
  `uvm_object_utils(irq_service)
  bit nothing_pending;                 // set when the line was high but STATUS read 0
  function new(string name = "irq_service"); super.new(name); endfunction
  task body();
    // Serve every pending source, the error first, and leave only when STATUS reads 0.
  endtask
endclass

// The service loop: runs for the whole test on the bus sequencer.
class irq_loop extends irq_loop_base;
  `uvm_object_utils(irq_loop)
  function new(string name = "irq_loop"); super.new(name); endfunction
  task body();
    forever begin
      irq_service s;
      @(posedge ctx.vif.irq);
      s = irq_service::type_id::create("isr");
      s.ctx = ctx;
      s.start(m_sequencer, this);
    end
  endtask
  task final_check();
  endtask
endclass
GivenWhat it offers
ctx.regsRegister model: status (thr[0], err[1], W1C) and mask, frontdoor on this sequencer.
ctx.vif.irqThe interrupt line, a level.
ctx.flag(why)Records a design fault; it does not stop anything.
ctx.served_thr, ctx.served_errCounts you may keep.
TimingThe loop starts at 50 ns. Errors pulse at 30 and 820 ns; the eighth DATA byte sets both sources. final_check runs at 930 ns; the run ends at 1000 ns.

Examples

Example 1

The Correct Peripheral: Serve Everything, Flag Nothing
Input
Correct peripheral; twelve DATA writes; errors at 30 and 820 ns; the eighth byte sets both sources
Output
alarm = no

The error pending at 50 ns, both sources together after the eighth byte, and the late error are all served. STATUS is 0 at the end, and no main write starts during a service.

Example 2

An Error Bit That Will Not Clear Must Be Reported
Input
Error bit does not clear; twelve DATA writes; errors at 30 and 820 ns; the eighth byte sets both sources
Output
alarm = yes

Writing 1 to STATUS.err leaves it set. The service must give up on that bit, report it, and mask it so the line can fall.

Example 3

A Stuck Line Must Be Reported
Input
Stuck interrupt line; twelve DATA writes; errors at 30 and 820 ns; the eighth byte sets both sources
Output
alarm = yes

After the first error the line stays high although STATUS reads 0. A level wait would start empty services for ever.

Constraints and Contract

  • Keep both class names, the nothing_pending field and the task signatures.
  • Reach registers only through ctx.regs, passing .parent(this).
  • Do not change the main traffic or the driver.

Hints

Hint 1

An interrupt is already pending at 50 ns. Which kind of wait still sees it?

Hint 2

What can main traffic do between your ungrab and the next service's grab?

Hint 3

A bit that will not clear keeps the line high for ever. How many times will you try before you report it and mask it?

What the grader checks: Your service runs on four real APB peripherals with a register model. One is correct and three have a planted fault, in an order your code cannot know. On the correct one the bench checks every rule from the bus. On each faulty one it checks that you reported the fault. It also checks each fault's own evidence: a masked bit, finished main traffic, or a late report from final_check.

4 checks on UVM · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. 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

The Correct Peripheral: Serve Everything, Flag Nothing

Input
Correct peripheral; twelve DATA writes; errors at 30 and 820 ns; the eighth byte sets both sources
Expected output
alarm = no

The error pending at 50 ns, both sources together after the eighth byte, and the late error are all served. STATUS is 0 at the end, and no main write starts during a service.

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

UVM · server