Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include csim.h /* Sets the following fields in cache acache acache->numways : The number of ways acache->blocksize: The size of one block,

#include

#include

#include

#include "csim.h"

/*

Sets the following fields in cache "acache"

acache->numways : The number of ways

acache->blocksize: The size of one block, in bytes

acache->numsets: The number of sets in the cache

acache->BO: The number of bits of block offset

acache->TO: The number of bits of tag offset (i.e. the number of bits to shift the tag so that its lowest bit is at position 0)

acache->VAImask: An andmask the size of the index field

acache->VATmask: An andmask the size of the tag field

*/

void setSizesOffsetsAndMaskFields(cache* acache, unsigned int size, unsigned int assoc, unsigned int blocksize);

// returns the set index, given an address

unsigned long long getindex(cache* acache, unsigned long long address);

// returns the tag, given an address

unsigned long long gettag(cache* acache, unsigned long long address);

// writes back the entire cache line at index, waynum into the next level of cache (e.g. L1->L2 or L2->Mem, etc.)

void writeback(cache* acache, unsigned int index, unsigned int waynum);

// fills (i.e. reads) the entire cache line that contains address "address" from the next level of cache/memory and places the read values into the current level of cache at index, waynum

void fill(cache* acache, unsigned int index, unsigned int waynum, unsigned long long address);

#include "YOURCODEHERE.h"

void setSizesOffsetsAndMaskFields(cache* acache, unsigned int size, unsigned int assoc, unsigned int blocksize){

unsigned int localVAbits=8*sizeof(uint64_t*);

if (localVAbits!=64){

fprintf(stderr,"Running non-portable code on unsupported platform, terminating. Please use designated machines. ");

exit(-1);

}

// YOUR CODE GOES HERE

}

unsigned long long getindex(cache* acache, unsigned long long address){

return 0; //Replace with correct value

}

unsigned long long gettag(cache* acache, unsigned long long address){

return 0; //Replace with correct value

}

void writeback(cache* acache, unsigned int index, unsigned int oldestway){

// YOUR CODE GOES HERE

}

void fill(cache * acache, unsigned int index, unsigned int oldestway, unsigned long long address){

// YOUR CODE GOES HERE

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

Students also viewed these Databases questions