S3.6.2 Best Cache Under a Bit Budget

HardImplement22 minIcarus Verilog · serverReview the topic

Count the bits of three small caches, run one trace through each, and choose the best design that fits the budget.

Hardware context: One cache as a counting model, with a fully associative shadow cache of the same size beside it. Sizing a cache from a trace before it is built

A cache may use at most 100 bits of storage. Block numbers have 6 bits, and a block is one word of 8 bits. Each line stores a valid bit, a tag and the word. The set of a block is its block number modulo the number of sets, and the tag is the rest of the block number. A set of two ways stores one more bit, which says which of its ways was used longer ago; a full set replaces that way. Design A has 8 lines and is direct-mapped. Design B has 8 lines as 4 sets of 2 ways. Design C has 4 lines as 2 sets of 2 ways. Each cache starts empty. The trace of block numbers is: 0, 8, 0, 8, 16, 0, 8, 2, 3, 2, 3, 0.

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 widths, bit counts and hit counts as whole numbers. For the last entry of the table, enter 1 for design A, 2 for B or 3 for C.

EntryYour decision
A_TAG_BITSHow many bits has the tag of design A?
A_LINE_BITSHow many bits does one line of design A store?
A_TOTAL_BITSHow many bits does design A store in all?
B_TOTAL_BITSHow many bits does design B store in all?
C_TOTAL_BITSHow many bits does design C store in all?
A_HITSHow many of the twelve reads hit in design A?
B_HITSHow many reads hit in design B?
C_HITSHow many reads hit in design C?
OVER_BUDGETHow many of the three designs need more than 100 bits?
BEST_DESIGNWhich design that fits the budget has the most hits? Enter 1, 2 or 3.
C_BITS_FOR_WORDThe word in each line now has WORD bits. Give the bits that design C stores in all.

Examples

Example 1

A TAG BITS
Input
How many bits has the tag of design A?
Output
matches = 1

Eight sets take 3 of the 6 bits as the set number. The other 3 are the tag.

Example 2

A LINE BITS
Input
How many bits does one line of design A store?
Output
matches = 1

A valid bit, a tag of 3 bits and a word of 8 bits.

Example 3

A TOTAL BITS
Input
How many bits does design A store in all?
Output
matches = 1

Eight lines of 12 bits.

Constraints and Contract

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

Hints

Hint 1

For each design, find the set number bits first. The tag is what is left of 6 bits.

Hint 2

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

Hint 3

Strike out what does not fit. Then compare hits, and only then bits.

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

A TAG BITS

Input
How many bits has the tag of design A?
Expected output
matches = 1

Eight sets take 3 of the 6 bits as the set number. The other 3 are the tag.

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

Icarus Verilog · server