S3.4.1 Hits for Three Shapes

MediumImplement22 minIcarus Verilog · serverReview the topic

Run one trace of ten reads through four cache lines arranged in three ways, and count what each arrangement costs.

Hardware context: Eight cache lines arranged as sets and ways, as a counting model, and the compare-and-select logic of 1, 2, 4 and 8 ways through synthesis. Choosing the number of ways of a cache

A cache has four lines, and each line holds one block. The lines can be arranged as 4 sets of 1 way (direct-mapped), as 2 sets of 2 ways, or as 1 set of 4 ways (fully associative). The set of a block is its block number modulo the number of sets. A miss uses an empty way of its set first. When the set is full, it replaces the block of that set that was used longest ago. The cache starts empty. The trace of block numbers is: 0, 4, 0, 4, 2, 6, 0, 2, 8, 8.

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

Enter set numbers, counts and widths as whole numbers. Block numbers have 8 bits.

EntryYour decision
DM_SET_OF_6With 4 sets of 1 way, which set does block 6 use?
TWO_WAY_SET_OF_6With 2 sets of 2 ways, which set does block 6 use?
FULL_SETSHow many sets has the fully associative arrangement?
DM_HITSHow many of the ten reads hit with 4 sets of 1 way?
TWO_WAY_HITSHow many of the ten reads hit with 2 sets of 2 ways?
FULL_HITSHow many of the ten reads hit with 1 set of 4 ways?
FULL_LAST_OUTWith 1 set of 4 ways, which block is replaced when block 8 arrives?
FULL_COMPARATORSHow many tag comparators does the fully associative arrangement need?
TWO_WAY_TAG_BITSBlock numbers have 8 bits. How many bits has the tag with 2 sets of 2 ways?
FULL_TAG_BITSAnd how many bits has the tag with 1 set of 4 ways?
PING_PONG_HITSA new trace reads blocks 0 and 4 in turn, ROUNDS times each, on the empty cache with 2 sets of 2 ways. Give the number of hits. With 4 sets of 1 way the same trace would have none.

Examples

Example 1

DM SET OF 6
Input
With 4 sets of 1 way, which set does block 6 use?
Output
matches = 1

6 modulo 4 is 2.

Example 2

TWO WAY SET OF 6
Input
With 2 sets of 2 ways, which set does block 6 use?
Output
matches = 1

6 modulo 2 is 0.

Example 3

FULL SETS
Input
How many sets has the fully associative arrangement?
Output
matches = 1

All four lines are the four ways of one set.

Constraints and Contract

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

Hints

Hint 1

For each arrangement, write the set of every block in the trace.

Hint 2

Follow each set alone, and keep its blocks in order of last use.

Hint 3

Count one comparator for each way, and take the set number out of the block number to get the tag.

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

11 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

DM SET OF 6

Input
With 4 sets of 1 way, which set does block 6 use?
Expected output
matches = 1

6 modulo 4 is 2.

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

Icarus Verilog · server