Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
    • SRAM and ROM
    • Register Files
    • Valid/Ready Handshake
    • AXI-Lite
    • AXI-Stream
    • Bus Integration
    • Synchronous FIFO
    • Register-Map and CSR RTL
      • CSR Contract and Address Map
      • Field Access Types
      • Hardware/Software Arbitration
      • Byte Strobes and Partial Writes
      • Atomic and Shadowed Updates
      • Interrupt Register Pattern
      • Adapter and Signoff
      • Generated Register Workflow
      • The Firmware Side: a C Driver for W1C, RC and Shadow Registers
    • Memory Reliability
    • Peripheral RTL Integration
    • Full AXI4: RTL Roadmap
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Register-Map and CSR RTL
  1. Topics
  2. RTL Design
  3. Memory & Buses
  4. Register-Map and CSR RTL
  5. Hardware/Software Arbitration

Part 7 · Memory & Buses · Intermediate

Hardware/Software Arbitration

Define deterministic priority when software and hardware update the same field on one edge.

Why this matters

Hardware sets a sticky bit on the same edge that software clears it. If the clear wins, a new completion or fault disappears and the driver never sees it.

After this lesson you can: choose set-wins or clear-wins for a sticky bit and write the equation for it.

One register, two owners

Sticky status commonly receives a hardware set and software clear on the same edge. The specification must decide whether the event remains pending.

The packet processor uses set-wins for STATUS.done and STATUS.error, so software cannot erase a newly arriving completion or fault while acknowledging an older one.

Policy

Equation

Use

Set wins

next = (q & ~sw_clear) | hw_set

Retain a new cause on a simultaneous clear

Clear wins

next = (q | hw_set) & ~sw_clear

Explicit acknowledgement dominates

Illegal collision

Assert collision never occurs

Mutually exclusive command ownership

Each slot is one clock cycle, and an input takes effect at the edge that ends its slot. status_sw uses set-wins and status_cw uses clear-wins; both see the same inputs.

  • Slot 1: a hardware set alone. Both bits are 1 from slot 2.

  • Slot 3, the collision: set and clear arrive together. Set-wins stays 1; clear-wins drops to 0 in slot 4, and the new event is lost.

  • Slot 4: a clear alone. Set-wins now clears too, in slot 5.

Interrupt and error status normally use set wins: software clearing an old event must not erase a new event arriving simultaneously.

design.sv
1
2
3
4
5
6
// snippet: set-dominant sticky status
logic [N-1:0] sw_clear;
assign sw_clear = csr_write && addr_hit ? wdata[N-1:0] & write_mask[N-1:0] : '0;
always_ff @(posedge clk or negedge rst_n)
  if (!rst_n) status_q <= '0;
  else        status_q <= (status_q & ~sw_clear) | hw_event_i;
Check yourself Software clears bit 2 on the same edge that hardware raises event 2. Under set-wins policy, what is stored?

One. The clear acknowledges the old event, while the new hardware event remains pending.

Remember

  • Status and interrupt bits normally use set-wins: clearing an old event must not erase a new one.

  • Set-wins keeps one pending cause. It does not count occurrences.

  • Use one equation for the STATUS view and the interrupt view, so they cannot disagree.

Rule of thumb: write the collision policy in the spec, not in the code comments.

Keep going

  • Interview: run a mock interview on this topic

Related topics

  • Byte strobes and partial writes

Previous

225 / 350

Next: Byte Strobes and Partial Writes

Up next

Up nextByte Strobes and Partial Writes

Sign in to save progress

Practice this lessonReport an error

See also

  • CSR Contract and Address Map
  • Atomic and Shadowed Updates
  • Interrupt Register Pattern
clkhw_setsw_clearstatus_swstatus_cw
One sticky bit under both policies: when a hardware set and a software clear hit the same edge, set-wins keeps the bit and clear-wins drops it