Results 1 to 7 of 7
  1. #1
    RobSon is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default Help with the coursework

    Hello guys, im new in java and new in this forum.
    I have this quite complicated, i think its complicated coursework that i have to finish in couple more days. Help pls.
    Specification:
    You are to construct a program that manages a 0.25 KB cache.
    (That is,data upto 256 Bytes can be stored in the cache.)
    Cache is organised in:

    Direct Mapped, and
    Fully associative.

    The program takes address references in the range 0 .. 1023
    and determines whether a given address reference is a hit or miss.
    It also computes the Miss rate every time a miss is encountered
    and at the end displays the overall Miss rate and the contents of the cache.

    For displaying the cache contents, you may represent the memory
    content at address A simply as M(A). You should assume that a cache block
    holds 8 Bytes and, where necessary, employ the LRU scheme for block replacement.

    I already have the scanner class that reads Text file with random elements.
    all i need right know is to make direct mapped casche.
    at the moment i have this
    Java Code:
    public class direct
    {    
        final int n = 8;
        final int m = 3;
        final int i = 5;
        private int hitCount;
        
        public final synchronized void addElements(int m, int n)
        {
            int index;
        }
    }
    It's far from finish, please help. Im not quite good in cache at all.
    If you want to check scanner class just write in this topic and i will post it.
    How to make hit and miss count?
    How to check it if its miss or hit?

  2. #2
    RobSon is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    i know how to get the Index and Tag, fore that i need to convert address into group address, thats okey, but how do i convert this address to groupd address?
    I know that i have to divide address from 2m which is A/8
    so somehow i have to get this address into my cache class
    and then make this A/8 to become GA.
    From there its easy. When i get my GA i can simple get Index by doing GA%32
    and tag GA/32 but how do i get address?

  3. #3
    RobSon is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    This is the scanner class
    Java Code:
    public class scanner
    {    
        public static void main(String[] args)
        {
            File file = null;
            Scanner sc = null;
            
            try 
            {
                file = new File ("TestDataRC.txt");
                sc = new Scanner(file);
                
                while (sc.hasNextLine())
                {
                    String line = sc.nextLine();
                    System.out.println(line);
                }
                
            }   catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            
            sc.close(); 
        }
    }
    It read elements from the TestDataRC txt file, but how to get address into my direct class?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    how to get address into my direct class?
    Call a method in the direct class and pass the address as an argument.

  5. #5
    RobSon is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    i know that argument is wrtiten like this
    Java Code:
        public static void main(String[] args)
        {
           
        }
    but how i pass address in it?
    sry for stupid questions im still new in java

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    The main() method is normally called by the JVM to start your class. You don't call it except for special cases.

    If you have a class called direct and it has a method: setAddress then this is a way to pass the address to the direct class:
    Java Code:
      direct drtClass = new direct(); // create instance of the direct class
        ...
    
      drtClass.setAddress(theAddress);  // pass the address to the direct class

  7. #7
    RobSon is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Football Roster coursework help needed!
    By yannick_bba in forum New To Java
    Replies: 2
    Last Post: 05-13-2011, 10:10 AM
  2. Help Java Coursework Help!!!!
    By miahj in forum New To Java
    Replies: 2
    Last Post: 11-29-2007, 04:37 AM
  3. Someone please help with my coursework....
    By budgie69@hotmail.co.uk in forum Eclipse
    Replies: 1
    Last Post: 08-09-2007, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •