• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

arrays help

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic