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
| Signal | Width | Role |
|---|---|---|
question | 8 | input 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.
| Entry | Your decision |
|---|---|
| ENTRY_OF_0C | Which entry does the branch at 0c use? |
| ENTRY_OF_1C | Which entry does the branch at 1c use? |
| ENTRY_OF_24 | Which entry does the branch at 24 use? |
| ENTRY_OF_2C | Which entry does the branch at 2c use? |
| ENTRY_OF_40 | Which entry does the branch at 40 use? |
| ENTRY_OF_5C | Which entry does the branch at 5c use? |
| ENTRIES_IN_USE | How many of the eight entries are used by at least one branch? |
| BRANCHES_THAT_ALIAS | How many of the six branches share their entry with another branch? |
| ALIAS_WITH_16_ENTRIES | With sixteen entries, the index is bits 5 to 2. How many branches share an entry then? |
| TAG_BITS | With eight entries, how many bits has the tag of the target buffer? |
| BITS_OF_A_TARGET_ENTRY | With eight entries, how many bits has one entry of the target buffer? |
| BITS_OF_THE_COUNTER_TABLE | How many bits has the whole counter table of eight entries? |
| BITS_OF_FOUR_TARGET_ENTRIES | A target buffer has only four entries. How many bits has it in all? |
| TAG_BITS_FOR_K | A 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