Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started classes

  • Loading branch information...
commit dfc4fc3f0a4ddc063b9aaf9097fd389a21a718c2 1 parent b4e1dfd
@pksunkara authored Siddardha G committed
View
0  INPUT
No changes.
View
4 Makefile
@@ -1,10 +1,10 @@
-CC= gcc
+CC= g++
CFLAGS= -Wall -pedantic -g
RM= rm -rf
all: sim
-sim: access.o cache.o memory.o main.c
+sim: access.o cache.o memory.o main.cpp
$(CC) $(CFLAGS) $^ -o $@
%.o: %.c
View
0  README
No changes.
View
5 access.cpp
@@ -1,8 +1,9 @@
#include <iostream>
#include <cstdlib>
+#include "access.h"
using namespace std;
-void get(int index) {
+Access::Access(void) {}
-}
+Access::~Access(void) {}
View
8 access.h
@@ -0,0 +1,8 @@
+class Access {
+ public:
+ Access(void);
+
+ ~Access(void);
+
+ private:
+};
View
28 cache.cpp
@@ -1,10 +1,32 @@
#include <iostream>
#include <cstdlib>
+#include "cache.h"
using namespace std;
-char* cache = NULL;
+Cache::Cache(int cache_size, int block_size, int assoc) {
+ this->hits = 0;
+ this->misses = 0;
-void init_cache(int size, int length, int assoc) {
- int blocks = size*1024/length;
+ // Cache size is given in KB
+ this->cache_size = cache_size*1024;
+ // Block size is given in B
+ this->block_size = block_size;
+ this->assoc = assoc;
+
+ //TODO: Introduce blocks later
+ this->memory = new int(this->cache_size/4);
+ return;
+}
+
+int Cache::get_hits(void) {
+ return this->hits;
+}
+
+int Cache::get_misses(void) {
+ return this->misses;
+}
+
+Cache::~Cache(void) {
+ delete(this->memory);
}
View
19 cache.h
@@ -0,0 +1,19 @@
+class Cache {
+ public:
+ Cache(int cache_size, int block_size, int assoc);
+
+ int get_hits(void);
+ int get_misses(void);
+
+ ~Cache(void);
+
+ private:
+ int* memory;
+
+ int cache_size;
+ int block_size;
+ int assoc;
+
+ int hits;
+ int misses;
+};
View
7 main.cpp
@@ -1,15 +1,16 @@
#include <iostream>
+#include <cstdio>
#include <cstdlib>
#include "access.h"
#include "cache.h"
#include "memory.h"
-int main(int argc, char** argv) {
+using namespace std;
+int main(int argc, char** argv) {
if(argc!=5) {
- printf("Usage: %s <cache_size_inKB> <line_length_inB> <associativity> <input_file>\n", argv[0]);
+ printf("Usage: %s <cache_size_inKB> <block_size_inB> <associativity> <input_file>\n", argv[0]);
return 1;
}
-
return 0;
}
View
11 memory.cpp
@@ -1,10 +1,15 @@
#include <iostream>
#include <cstdlib>
+#include "memory.h"
using namespace std;
-char* memory = NULL;
-
-void init_memory(int size, int** data) {
+Memory::Memory(int size) {
+ this->size = size;
+ this->memory = new int(this->size);
+ return;
+}
+Memory::~Memory(void) {
+ delete(this->memory);
}
View
10 memory.h
@@ -0,0 +1,10 @@
+class Memory {
+ public:
+ Memory(int size);
+
+ ~Memory(void);
+
+ private:
+ int* memory;
+ int size;
+};
Please sign in to comment.
Something went wrong with that request. Please try again.