S9.3.1 The MESI State Table

MediumImplement30 minIcarus Verilog · serverReview the topic

Extend the MSI line controller of the lab with the Exclusive state, including the shared line that decides it.

Hardware context: Two MESI cache lines on a snoop bus model. Multicore cache controller design

In the S9.3 lab, each cache line runs the MSI controller msi_line. Write mesi_line, the same controller with a fourth state, Exclusive. Porting the lab code is allowed. The new state and the shared signals are the part graded.

The bus serialises accesses, so each step brings one op to the line. A requester sees shared_in from the other caches during its own read miss. Every snooping cache drives shared_out.

Signals in the Timeline

SignalWidthRole
sample10input of each check
Full specification
opValueMeaning
IDLE0Nothing happens to this block
PR_RD1This processor reads the block
PR_WR2This processor writes the block
EVICT3This cache replaces the block
SN_RD4Another cache placed a read miss for this block
SN_WRMISS5Another cache placed a write miss for this block
SN_INV6Another cache placed an invalidate for this block
reserved7Never sent. Hold the state and drive no outputs

A read miss from Invalid becomes Exclusive when shared_in is 0 and Shared when it is 1. A write to an Exclusive line needs no bus command. Exclusive is clean, so dropping it never writes back.

On SN_RD every valid copy drives shared_out and ends Shared, and a Modified copy also flushes. SN_WRMISS invalidates every copy, flushing a Modified one. SN_INV invalidates a Shared copy.

The bus never sends SN_INV while you hold E or M, since an invalidate comes only from a Shared holder. Those rows are not graded. In all other rows shared_in matters only for PR_RD in Invalid. Patterson and Hennessy, section 5.12, Figure e5.12.9, gives the MSI rows and the Exclusive state.

Examples

Example 1

Read Miss Alone
Input
state=I, op=PR_RD, shared_in=0
Output
next = E (2), bus_cmd = read miss (1), flush = 0, shared_out = 0

No other cache answers, so the line takes the clean, private state.

Example 2

Read Miss with a Sharer
Input
state=I, op=PR_RD, shared_in=1
Output
next = S (1), bus_cmd = read miss (1), flush = 0, shared_out = 0

Another cache raised shared_in, so both copies are Shared.

Example 3

Snooped Read of a Dirty Line
Input
state=M, op=SN_RD, shared_in=0
Output
next = S (1), bus_cmd = none (0), flush = 1, shared_out = 1

The owner flushes, keeps a Shared copy and raises its shared line.

Constraints and Contract

  • Keep the ports and encodings. Drive every output from state, op and shared_in alone: this is next-state logic, and the caller holds the state register.
  • Stay inside your module: hierarchical names, $root, force, release, bind and defparam are refused.

Hints

Hint 1

List the four states down the side and the six ops across the top before writing code.

Hint 2

Ask which rows need shared_in, and which need shared_out.

Hint 3

Exclusive behaves like Shared toward the bus and like Modified toward its own processor.

What the grader checks: Every state, op and shared_in combination is checked, except SN_INV in E or M, which a correct bus never sends.

63 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 2 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

Read Miss Alone

Input
state=I, op=PR_RD, shared_in=0
Expected output
next = E (2), bus_cmd = read miss (1), flush = 0, shared_out = 0

No other cache answers, so the line takes the clean, private state.

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

Icarus Verilog · server