S2.27.1 Who Shares an Entry

EasyImplement12 minIcarus Verilog · serverReview the topic

Six branches and a table of eight entries. Find the entry of each branch, the branches that alias, and the bits that the tables cost.

Hardware context: Test code that replays the branches and jumps which the real core ap_rv32 executed, with a table of 2-bit counters and a branch target buffer of 1 to 16 entries each. Sizing a branch target buffer and a counter table from a branch trace

A program has six branches, at these addresses in hex: 0c, 1c, 24, 2c, 40 and 5c. A counter table and a branch target buffer have eight entries each. An address uses the entry given by its bits 4 to 2. Addresses have 32 bits.

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

To find an entry by hand: write the address in decimal, divide by 4, and keep the remainder of a division by the number of entries.

An entry of the counter table is a 2-bit counter. An entry of the target buffer holds a valid bit, a tag and a 32-bit target. The tag is every address bit above the index.

Enter every value in decimal.

EntryYour decision
ENTRY_OF_0CWhich entry does the branch at 0c use?
ENTRY_OF_1CWhich entry does the branch at 1c use?
ENTRY_OF_24Which entry does the branch at 24 use?
ENTRY_OF_2CWhich entry does the branch at 2c use?
ENTRY_OF_40Which entry does the branch at 40 use?
ENTRY_OF_5CWhich entry does the branch at 5c use?
ENTRIES_IN_USEHow many of the eight entries are used by at least one branch?
BRANCHES_THAT_ALIASHow many of the six branches share their entry with another branch?
ALIAS_WITH_16_ENTRIESWith sixteen entries, the index is bits 5 to 2. How many branches share an entry then?
TAG_BITSWith eight entries, how many bits has the tag of the target buffer?
BITS_OF_A_TARGET_ENTRYWith eight entries, how many bits has one entry of the target buffer?
BITS_OF_THE_COUNTER_TABLEHow many bits has the whole counter table of eight entries?
BITS_OF_FOUR_TARGET_ENTRIESA target buffer has only four entries. How many bits has it in all?
TAG_BITS_FOR_KA target buffer has 2 to the power of K entries, so its index has K bits. Give the number of tag bits as an expression in K.

Examples

Example 1

ENTRY OF 0C
Input
Which entry does the branch at 0c use?
Output
matches = 1

0c in hex is 12. Divided by 4 that is 3.

Example 2

ENTRY OF 1C
Input
Which entry does the branch at 1c use?
Output
matches = 1

1c in hex is 28. Divided by 4 that is 7.

Example 3

ENTRY OF 24
Input
Which entry does the branch at 24 use?
Output
matches = 1

24 in hex is 36. Divided by 4 that is 9, and 9 leaves 1 when divided by 8.

Constraints and Contract

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

Hints

Hint 1

Drop bits 1 and 0 by dividing by 4. The low bits of what is left are the entry.

Hint 2

Two branches alias when their entry numbers are equal. List the six numbers and look for pairs.

Hint 3

The index is not stored: it is the place of the entry. Everything above it 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.

14 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 1 problem 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

ENTRY OF 0C

Input
Which entry does the branch at 0c use?
Expected output
matches = 1

0c in hex is 12. Divided by 4 that is 3.

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

Icarus Verilog · server