Create a program in C++ which simulates a direct cache. The memory array that contains the data to be cached is byte addressable and can contain 256 single byte entries or lines. The cache has only 8 entries or lines. The Data field in each line of the cache is 8 bits. Since the data stored in each line of the cache is only 8 bits, there is no need for a line field. Only a tag field is needed which is log2(256) = 8 bits. The memory array can be filled with any values of your choice. The program should work by taking user input of a memory address (index). This input represents the memory data that should be cached. Your program will check the cache to see if the item is already cached. If it is not, your program should count a cache miss, and then replace the item currently in the cache with the data from the inputted address. Allow the user to input addresses (in a loop), until they so choose to end the program. The program should output the number of cache misses upon ending.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 19SA
icon
Related questions
Topic Video
Question

Create a program in C++ which simulates a direct cache. The memory array that contains the data to be cached is byte addressable and can contain 256 single byte entries or lines. The cache has only 8 entries or lines. The Data field in each line of the cache is 8 bits. Since the data stored in each line of the cache is only 8 bits, there is no need for a line field. Only a tag field is needed which is log2(256) = 8 bits.

The memory array can be filled with any values of your choice. The program should work by taking user input of a memory address (index). This input represents the memory data that should be cached. Your program will check the cache to see if the item is already cached. If it is not, your program should count a cache miss, and then replace the item currently in the cache with the data from the inputted address. Allow the user to input addresses (in a loop), until they so choose to end the program. The program should output the number of cache misses upon ending.

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT