// Do not edit this file #ifndef MEMORY_H #define MEMORY_H // Return values #define OK 0 #define FAIL -1 // Simulation parameters #define MEM_DEBUG 0 #define NUM_BLOCK_OFFSET_BITS 2 #define MAX_SIZE 1000 /** * Computes the number of blocks given the number of addressable bits and block * offset bits. * * For example (from README), * if the number of addresses is 256 and the number of block offset bits is 2, * then the block size is 2^2=4. Thus, the address space can be divided into 64 * blocks of 4 addresses each. * * Parameters: * addr_bits: number of addressable bits * num_block_offset_bits: number of block offset bits * Return: * number of blocks (success) | FAIL (error) */ int number_of_blocks(unsigned int addr_bits, unsigned int num_block_offset_bits); /** * Reads the bytes in memory.txt to initialize the phy_memory array * * Parameters: * file_name: name of the file to read * Return: * number of addressable bits (no error) | FAIL (error) */ int read_memory_file(char* file_name); /** * Identifies the starting physical memory address location for each block. * * Parameters: * num_blocks: number of blocks * num_block_offset_bits: number of block offset bits * Return: * void */ void initialize_block_pointers(unsigned int num_blocks, unsigned int num_block_offset_bits); #endif // MEMORY_H