S3.3.1 Split the Address for This Cache

EasyImplement12 minIcarus Verilog · serverReview the topic

Work out the widths of tag, index and offset for one cache, and then split three addresses.

Hardware context: A direct-mapped read cache of four lines with blocks of four words, in front of a slow memory, as test code. Designing and checking the hit path and the reset of a cache

A direct-mapped cache serves addresses of 32 bits, which count bytes. It has 64 lines. Each line holds a block of 8 words, and a word is 4 bytes. Work out the three fields of an address, and then use them on the addresses below.

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 in bits, and field values as plain numbers. For a yes-or-no entry, enter 1 for yes and 2 for no.

EntryYour decision
OFFSET_BITSHow many bits has the offset?
INDEX_BITSHow many bits has the index?
TAG_BITSHow many bits has the tag?
WORD_SELECT_BITSHow many bits of the offset pick the word inside the block?
A_INDEXAddress A is 0x00001b64. What is its index?
A_WORDWhich word of the block does address A pick?
A_TAGWhat is the tag of address A?
B_WORDAddress B is 0x00001b7c. It has the same tag and index as A. Which word does it pick?
C_TAGAddress C is 0x00002364. What is its tag?
C_REPLACES_AThe cache holds the block of A. Then C is read. Does C push the block of A out? Enter 1 for yes, 2 for no.
TAG_VARIANTNow the cache has LINES lines, a power of two from 1 to 1024, and the same blocks of 32 bytes. Give the width of the tag in bits.

Examples

Example 1

OFFSET BITS
Input
How many bits has the offset?
Output
matches = 1

A block is 8 words of 4 bytes: 32 bytes. Thirty-two is two to the power of five.

Example 2

INDEX BITS
Input
How many bits has the index?
Output
matches = 1

Sixty-four lines need six bits.

Example 3

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

The rest: 32 less 5 less 6.

Constraints and Contract

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

Hints

Hint 1

Count the bytes of a block. That many need how many bits?

Hint 2

Count the lines. That many need how many bits?

Hint 3

Write the address in binary and cut the offset off, then the index. The rest is 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

OFFSET BITS

Input
How many bits has the offset?
Expected output
matches = 1

A block is 8 words of 4 bytes: 32 bytes. Thirty-two is two to the power of five.

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

Icarus Verilog · server