-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV.java
127 lines (105 loc) · 2.56 KB
/
V.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import java.io.*;
import java.util.ArrayList;
public class V {
int ID; // Only used for sink nodes. Top sink node = 0, Bottom sink node = -1
String operation; // Operation of the vertex (+, *, /, etc.)
String varName; // The variable being operated on. ie: h = a * b... h is the varName
ArrayList<V> successors; // Array of successors
int delay; // Cycle delay. Multipliers = 2, divider/modulo = 3, all others = 1
boolean isScheduled; // True if scheduled, false otherwise
int timing; // Timing for ALAP
int initialTime; // Initial time from CDFG
int final_time; // Timing for list_r
ArrayList<V> predecessors;
// Constructor
public V(int id, String operation, String varName) {
this.ID = id;
this.operation = operation;
this.varName = varName;
successors = new ArrayList<V>();
predecessors = new ArrayList<V>();
delay = calculateDelay(operation);
isScheduled = false;
timing = -1;
initialTime = 1;
final_time = -1;
}
// Sets the delay
public void setDelay(int delay) {
this.delay = delay;
}
public void setFinalTime(int time) {
this.final_time = time;
}
public int getFinalTime() {
return this.final_time;
}
public String getOperation() {
return this.operation;
}
// Gets delay
public int getDelay() {
return this.delay;
}
// Adds a successor
public void addSuccessor(V vertex) {
this.successors.add(vertex);
}
// Returns successor array
public ArrayList<V> getSuccessors() {
return this.successors;
}
// Adds a successor
public void addPredecessors(V vertex) {
this.predecessors.add(vertex);
}
// Returns successor array
public ArrayList<V> getPredecessors() {
return this.predecessors;
}
public void setScheduled(boolean set) {
this.isScheduled = set;
}
// Returns size of successor array
public int getSuccessorSize() {
return this.successors.size();
}
public void setTiming(int time) {
this.timing = time;
}
public int getTiming() {
return this.timing;
}
public int getID() {
return this.ID;
}
public String getName() {
return this.varName;
}
public boolean getIsScheduled() {
return this.isScheduled;
}
public void setInitialTime(int time) {
this.initialTime = time;
}
public int getInitialTime() {
return this.initialTime;
}
/*
* Sets the delay for specified operator
* Multipliers = 2
* Divider/modulo = 3
* All others = 1
*/
public int calculateDelay(String operator) {
if(operator == "*") {
return 2;
}
else if(operator == "/" || operator == "%") {
return 3;
}
else {
return 1;
}
}
}