-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
46 lines (45 loc) · 1.52 KB
/
test.cpp
File metadata and controls
46 lines (45 loc) · 1.52 KB
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
41
42
43
44
45
46
#include <iostream>
#include "mesi.h"
#include "msi.h"
#include "mosi.h"
#include "moesi.h"
#include "mesif.h"
#include <vector>
using namespace std;
int main(int argc, char ** argv){
cerr<<"test"<<endl;
vector<char> states = {'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i'};
Protocol * mesif_protocol;
mesif_protocol = new mesif();
vector<char> temp_states = {'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i'};
int operation;
int temp_operation;
for(int i=0; i<20; i++){
operation = rand()% 16;//even = read, odd = write, operations/2 = processor number
cerr << "operation: " << operation << endl;
for(int j=0; j<8; j++){
if(operation/2 == j){
if(operation%2 == 0){
temp_operation = 2; // pro read
}
else{
temp_operation = 3; // pro write
}
}
else{
if(operation%2 == 0){
temp_operation = 0; // bus read
}
else{
temp_operation = 1; // bus write
}
}
temp_states[j] = mesif_protocol -> next_state(temp_operation, states[j], states);
}
for(int k=0; k<8; k++){
states[k] = temp_states[k];
}
cerr << "states: " << states[0] << " " << states[1] << " " << states[2] << " " << states[3] << " " << states[4] << " " << states[5] << " " << states[6] << " " << states[7] << endl;
}
return 0;
}