#include <stdlib.h> /* declare global var's */ /* define structure of dynamic cache and initialize var */ /* define dynamic array for main memory */ /**********************************************************************/ void set_params() { /* declare local var's */ /* Prompt for main memory size, cache size, block size */ /* allocate and initialize main memory--value at index i = size of main memory-i*/ /* allocate memory for cache */ return; } /**********************************************************************/ void read_addr() { /* declare local var's */ /* Prompt for main memory address to read from */ /* Translate main mem addr to cache addr fields*/ /* MISS--BLOCK NOT ALLOCATED */ /* Allocate cache block based on block size */ /* MISS--NON-MATCHING TAG */ /* Print message of Read miss */ /* Overwrite tag */ /* Transfer equivalent block of main memory to cache--one word at a time */ /* HIT--read cache word */ /* Print message of word, block, tag, data value */ return; } /**********************************************************************/ void write_addr() { /* declare local var's *//* Prompt for main memory address to write from, and data value to write */ /* Translate main mem addr to cache addr fields*/ /* MISS--BLOCK NOT ALLOCATED */ /* Allocate cache block based on block size */ /* MISS--NON-MATCHING TAG */ /* Print message of write miss */ /* Overwrite tag */ /* Transfer equivalent block of main memory to cache--one word at a time */ /* HIT--read cache word */ /* Copy data value to appropriate word in cache */ /* Print message of word, block, tag, data value */ return; } /**********************************************************************/ void delete_cache() { /* declare local var's */ /* free each allocated block */ /* free top level cache var */ /* free main meory if allocated */ return; } /**********************************************************************/ int main() { /* declare local var's */ /* until program exits, print menu, select choice via switch statement and call appropriate function*/ return 0;
View Full Document