-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLocks.java
More file actions
78 lines (70 loc) · 1.98 KB
/
Copy pathLocks.java
File metadata and controls
78 lines (70 loc) · 1.98 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
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
package simulator;
public class Locks
{
public static void occupyResource(int instructionNum)
{
String instruction=Simulator.memory[instructionNum][1];
if(instruction.matches("ADD.D") || instruction.matches("SUB.D"))
{
if(Simulator.isFPadderPipe)
Simulator.FPadder--;
else
Simulator.FPadder = 0;
}
else if(instruction.matches("MUL.D"))
{
if(Simulator.isFPmultiplierPipe)
Simulator.FPmultiplier--;
else
Simulator.FPmultiplier = 0;
}
else if(instruction.matches("DIV.D"))
{
if(Simulator.isFPdividerPipe)
Simulator.FPdivider--;
else
Simulator.FPdivider = 0;
}
else if(instruction.matches("HLT")||instruction.matches("BNE")
||instruction.matches("BEQ")||instruction.matches("J"))
{
}
else
{
Simulator.integerUnit--;
}
}
public static void releaseResource(int instructionNum)
{
String instruction=Simulator.memory[instructionNum][1];
if(instruction.matches("ADD.D") || instruction.matches("SUB.D"))
{
if(Simulator.isFPadderPipe)
Simulator.FPadderInc++;
else
Simulator.FPadderInc = Simulator.FPadd;
}
else if(instruction.matches("MUL.D"))
{
if(Simulator.isFPmultiplierPipe)
Simulator.FPmultiplierInc++;
else
Simulator.FPmultiplierInc = Simulator.FPmult;
}
else if(instruction.matches("DIV.D"))
{
if(Simulator.isFPdividerPipe)
Simulator.FPdividerInc++;
else
Simulator.FPdividerInc = Simulator.FPdiv;
}
else if(instruction.matches("HLT")||instruction.matches("BNE")
||instruction.matches("BEQ")||instruction.matches("J"))
{
}
else
{
Simulator.integerUnitInc++;
}
}
}