-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRam.cpp
40 lines (33 loc) · 799 Bytes
/
Ram.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Created by Eshin Griffith on 9/26/17.
//
#include <vector>
#include "Ram.h"
#include <mutex>
#include <cstdlib>
#include <iostream>
std::string Ram::read(int address) {
std::string rd = ram_data[address];
return rd;
}
void Ram::write(int address, std::string data) {
if (address >= SIZE || address < 0)
std::cout << "Using Ram INcorretly " << address<< "\n ";
ram_data[address] = data;
}
void Ram::write(int address, std::vector<std::string> data) {
if (data[0] == "0")
ram_used -= data.size();
else
ram_used += data.size();
for (int i = 0; i < data.size(); i++) {
this->ram_data[i + address] = data[i];
}
}
Ram::Ram() {
for (int i = 0; i < SIZE; i++)
ram_data[i] = "0";
ram_used = 0;
}
Ram::~Ram() {
}