arrays help
hi,
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
thanks
the code for the memory class is as follows:
import java.util.Random;
publicclass Memory
{
publicstaticvoid main(String args[])
{
int[][] memoryArray=newint[50][8];
Random randnum =new Random();
for(int i=0;i<50;i++)
{
for(int j=0;j<8;j++)
{
memoryArray[i][j]=randnum.nextInt(99);
}
}
for(int i=0;i<50;i++)
{
System.out.print("["+i+"] ");
for(int j=0;j<8;j++)
{
System.out.print(memoryArray[i][j] +" ");
}
System.out.println();
}
}
}

