im trying to write a program to represent a memory and a cache
i have written a class for the memory containing a 2d array holding random integers - i will post the code for this below for you to gain an understanding
i now wish to write a cache class which contains 4 2d arrays
32x1 for validity bit (0 if the corresponding cache block is empty, 1 if it has stuff in) 32x1 for index 32x1 for tag 32x8 for the actual cache blocks
however, i am unsure of how to go about doing this if anybody could offer any help or psuedo code id appreciate it very much
the code for the memory class is as follows:
posted 8 years ago
You obviously know how to create arrays, so what problem are you having ?
Having said that though, rather than having four arrays to handle the different elements of a cache entry, you should create a new class called CacheEntry which contains fields to represent each of the elements. Your Cache class will then contain a one dimensional array of CacheEntry objects.
Have a go at implementing that and if you have any problems, come back with your code and we'll try and help.