Skip to content

Commit cd56777

Browse files
authored
Add files via upload
1 parent b36b0cf commit cd56777

File tree

7 files changed

+451
-0
lines changed

7 files changed

+451
-0
lines changed

1Level.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
import numpy as np
4+
import os
5+
root= tk.Tk()
6+
root.withdraw()
7+
filepath =filedialog.askopenfilename(filetypes = (("trace files","*.trace"),("out files",".out")))
8+
file=open(filepath)
9+
file_path = file.name
10+
ext= os.path.splitext(file_path)
11+
readData=file.readlines()
12+
pht = []
13+
list1=[]
14+
nbit=int(2)
15+
nbit=pow(2,nbit)
16+
nbitLength=int(nbit/2)
17+
n=int(nbitLength/2)
18+
print(nbitLength)
19+
20+
misprediction=0
21+
goodprediction=0
22+
for i in range(len(readData)):
23+
split= readData[i].split(' ')
24+
pc=split[0]
25+
pc=pc[-3:]
26+
data=split[1]
27+
if pc in list1:
28+
list1_index = list1.index(pc)
29+
if 'T' in data:
30+
pht[list1_index][0]=pht[list1_index][0]+1
31+
if pht[list1_index][0]>=nbit:
32+
pht[list1_index][0]=nbit
33+
34+
if 'N' in data:
35+
pht[list1_index][0]=pht[list1_index][0]-1
36+
37+
if pht[list1_index][0]<nbitLength-n:
38+
misprediction+=1
39+
if pht[list1_index][0]<=0:
40+
pht[list1_index][0]=0
41+
else:
42+
list1.append(pc)
43+
pht.insert(list1.index(pc),[1,pc])
44+
# misprediction+=1
45+
if len(pht)>1024:
46+
del pht[0]
47+
48+
print("Misprediction:",misprediction)
49+
print("Total",len(readData))
50+
51+
52+
53+
54+

global.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
import numpy as np
4+
import os
5+
root= tk.Tk()
6+
root.withdraw()
7+
filepath =filedialog.askopenfilename(filetypes = (("trace files","*.trace"),("out files",".out")))
8+
file=open(filepath)
9+
file_path = file.name
10+
ext= os.path.splitext(file_path)
11+
readData=file.readlines()
12+
nbit=int(2)
13+
nbit=pow(2,nbit)
14+
nbitLength=int(nbit/2)
15+
n=int(nbitLength/2)
16+
print(nbitLength)
17+
pht = []
18+
list1=[]
19+
gtr=0
20+
misprediction=0
21+
goodprediction=0
22+
for i in range(len(readData)):
23+
split= readData[i].split(' ')
24+
data=split[1]
25+
if gtr in list1:
26+
list1_index = list1.index(gtr)
27+
if 'T' in data:
28+
gtr=gtr&0xffffffffff
29+
gtr=gtr<<1
30+
gtr=gtr+1
31+
gtr=gtr&0xffffffffff
32+
gtr=gtr&0x0000003ff0
33+
gtr=gtr>>4
34+
pht[list1_index][0]=pht[list1_index][0]+1
35+
if pht[list1_index][0]>=nbit:
36+
pht[list1_index][0]=nbit
37+
38+
if 'N' in data:
39+
gtr=gtr&0xffffffffff
40+
gtr=gtr<<1
41+
gtr=gtr+0
42+
gtr=gtr&0xffffffffff
43+
gtr=gtr&0x0000003ff0
44+
gtr=gtr>>4
45+
pht[list1_index][0]=pht[list1_index][0]-1
46+
if pht[list1_index][0]<nbitLength-n:
47+
misprediction+=1
48+
if pht[list1_index][0]<=0:
49+
pht[list1_index][0]=0
50+
51+
else:
52+
list1.append(gtr)
53+
misprediction+=1
54+
pht.insert(list1.index(gtr),[1,gtr])
55+
if len(pht)>1024:
56+
del pht[0]
57+
58+
print("Misprediction:",misprediction)
59+
print("Total",len(readData))

gshare.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
import numpy as np
4+
import os
5+
root= tk.Tk()
6+
root.withdraw()
7+
filepath =filedialog.askopenfilename(filetypes = (("trace files","*.trace"),("out files",".out")))
8+
file=open(filepath)
9+
file_path = file.name
10+
ext= os.path.splitext(file_path)
11+
readData=file.readlines()
12+
pht = []
13+
list1=[]
14+
nbit=int(2)
15+
nbit=pow(2,nbit)
16+
nbitLength=int(nbit/2)
17+
n=int(nbitLength/2)
18+
print(nbitLength)
19+
gtr=0
20+
addr=0
21+
misprediction=0
22+
goodprediction=0
23+
for i in range(len(readData)):
24+
split= readData[i].split(' ')
25+
pc=split[0]
26+
pc=pc[-3:]
27+
pc=int(pc)
28+
data=split[1]
29+
if addr in list1:
30+
list1_index = list1.index(addr)
31+
if 'T' in data:
32+
gtr=gtr&0xffffffffff
33+
gtr=gtr<<1
34+
gtr=gtr+1
35+
gtr=gtr&0xffffffffff
36+
gtr=gtr&0x0000003ff0
37+
gtr=gtr>>4
38+
addr=gtr^pc
39+
pht[list1_index][0]=pht[list1_index][0]+1
40+
if pht[list1_index][0]>=nbit:
41+
pht[list1_index][0]=nbit
42+
43+
if 'N' in data:
44+
gtr=gtr&0xffffffffff
45+
gtr=gtr<<1
46+
gtr=gtr+0
47+
gtr=gtr&0xffffffffff
48+
gtr=gtr&0x0000003ff0
49+
gtr=gtr>>4
50+
addr=gtr^pc
51+
pht[list1_index][0]=pht[list1_index][0]-1
52+
if pht[list1_index][0]<nbitLength-n:
53+
misprediction+=1
54+
if pht[list1_index][0]<=0:
55+
pht[list1_index][0]=0
56+
57+
else:
58+
list1.append(addr)
59+
misprediction+=1
60+
pht.insert(list1.index(addr),[1,addr])
61+
if len(pht)>1024:
62+
del pht[0]
63+
64+
print("Misprediction:",misprediction)
65+
print("Total",len(readData))

hybrid.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
import numpy as np
4+
import sys
5+
import os
6+
root= tk.Tk()
7+
root.withdraw()
8+
filepath =filedialog.askopenfilename(filetypes = (("trace files","*.trace"),("out files",".out")))
9+
file=open(filepath)
10+
file_path = file.name
11+
ext= os.path.splitext(file_path)
12+
readData=file.readline()
13+
LHT=[0]*1024
14+
LPT=[1]*1024
15+
GHR=0
16+
GPT=[1]*1024
17+
misprediction=0
18+
total=0
19+
20+
21+
while readData:
22+
total+=1
23+
pc,data=readData.split(' ')
24+
pc=pc[-3:]
25+
if pc in LHT:
26+
pc1=pc[-2:]
27+
pc1=int(pc1)
28+
if 'T' in data or '1' in data:
29+
LPT[pc1]=LPT[pc1]+1
30+
GHR=GHR<<1
31+
GHR=GHR+1
32+
GHR=str(GHR)
33+
GHR=GHR[-1:]
34+
GHR = int(GHR)
35+
GHR=pc1^GHR
36+
GPT[GHR]=GPT[GHR]+1
37+
if GPT[GHR]<=0 or LPT[pc1]<=0:
38+
misprediction+=1
39+
if GPT[GHR]<=0:
40+
GPT[GHR]=0
41+
GPT[GHR]=0
42+
if LPT[pc1]<=0:
43+
LPT[pc1]=0
44+
if GPT[GHR]>=3:
45+
GPT[GHR]=3
46+
if LPT[pc1]>=3:
47+
LPT[pc1]=3
48+
49+
50+
if 'N' in data or '0' in data:
51+
LPT[pc1]=LPT[pc1]-1
52+
GHR=GHR<<1
53+
GHR=GHR+0
54+
GHR=str(GHR)
55+
GHR=GHR[-1:]
56+
GHR= int(GHR)
57+
GHR=pc1^GHR
58+
GPT[GHR]=GPT[GHR]+1
59+
if GPT[GHR]<=0 or LPT[pc1]<=0:
60+
misprediction+=1
61+
GPT[GHR]=0
62+
LPT[pc1]=0
63+
if GPT[GHR]>=3:
64+
GPT[GHR]=3
65+
if LPT[pc1]>=3:
66+
LPT[pc1]=3
67+
68+
69+
else:
70+
LHT.append(pc)
71+
if len(LHT)>=1024:
72+
del LHT[0]
73+
74+
75+
76+
77+
78+
readData=file.readline()
79+
80+
print("Misprediction:",misprediction)
81+
print("Total Accesses:",total)

local.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
import numpy as np
4+
import os
5+
root= tk.Tk()
6+
root.withdraw()
7+
filepath =filedialog.askopenfilename(filetypes = (("trace files","*.trace"),("out files",".out")))
8+
file=open(filepath)
9+
file_path = file.name
10+
ext= os.path.splitext(file_path)
11+
readData=file.readlines()
12+
pht=[]
13+
local=[0]*128
14+
list1=[]
15+
nbit=int(2)
16+
nbit=pow(2,nbit)
17+
nbitLength=int(nbit/2)
18+
n=int(nbitLength/2)
19+
print(nbitLength)
20+
addr=0
21+
addr1=0
22+
misprediction=0
23+
24+
for i in range(len(readData)):
25+
split= readData[i].split(' ')
26+
pc=split[0]
27+
pc=int(pc)
28+
pc=pc&0x000007f0
29+
pc=pc>>4
30+
data=split[1]
31+
addr1=local[pc]
32+
addr1=addr1&0xffffffffff
33+
addr=addr<<1
34+
if addr in list1:
35+
list1_index = list1.index(addr)
36+
if 'T' in data:
37+
local[pc]=addr
38+
addr=local[pc]&0x00003ff0
39+
addr=addr>>4
40+
pht[list1_index][0]=pht[list1_index][0]+1
41+
if pht[list1_index][0]>=3:
42+
pht[list1_index][0]=3
43+
44+
if 'N' in data:
45+
local[pc]=pht[list1_index][1]
46+
addr=local[pc]&0x00003ff0
47+
addr=addr>>4
48+
pht[list1_index][0]=pht[list1_index][0]-1
49+
if pht[list1_index][0]<=0:
50+
misprediction+=1
51+
pht[list1_index][0]=0
52+
53+
54+
else:
55+
list1.append(addr)
56+
pht.insert(list1.index(addr),[1,addr])
57+
if len(pht)>1024:
58+
del pht[0]
59+
print("Misprediction:",misprediction)
60+
print("Total",len(readData))
61+
62+

n-bitGshare.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
import numpy as np
4+
import sys
5+
import os
6+
root= tk.Tk()
7+
root.withdraw()
8+
filepath =filedialog.askopenfilename(filetypes = (("trace files","*.trace"),("out files",".out")))
9+
file=open(filepath)
10+
file_path = file.name
11+
ext= os.path.splitext(file_path)
12+
readData=file.readlines()
13+
pht = []
14+
list1=[]
15+
nbit=int(sys.argv[1])
16+
nbit=pow(2,nbit)
17+
nbitLength=int(nbit/2)
18+
n=int(nbitLength/2)
19+
print(nbitLength)
20+
gtr=0
21+
addr=0
22+
misprediction=0
23+
goodprediction=0
24+
for i in range(len(readData)):
25+
split= readData[i].split(' ')
26+
pc=split[0]
27+
pc=pc[-3:]
28+
pc=int(pc)
29+
data=split[1]
30+
if addr in list1:
31+
list1_index = list1.index(addr)
32+
if 'T' in data or '1' in data:
33+
gtr=gtr&0xffffffffff
34+
gtr=gtr<<1
35+
gtr=gtr+1
36+
gtr=gtr&0xffffffffff
37+
gtr=gtr&0x0000003ff0
38+
gtr=gtr>>4
39+
addr=gtr^pc
40+
pht[list1_index][0]=pht[list1_index][0]+1
41+
if pht[list1_index][0]>=nbit:
42+
pht[list1_index][0]=nbit
43+
44+
if 'N' in data or '0' in data:
45+
gtr=gtr&0xffffffffff
46+
gtr=gtr<<1
47+
gtr=gtr+0
48+
gtr=gtr&0xffffffffff
49+
gtr=gtr&0x0000003ff0
50+
gtr=gtr>>4
51+
addr=gtr^pc
52+
pht[list1_index][0]=pht[list1_index][0]-1
53+
if pht[list1_index][0]<nbitLength-n:
54+
misprediction+=1
55+
if pht[list1_index][0]<=0:
56+
pht[list1_index][0]=0
57+
58+
else:
59+
list1.append(addr)
60+
misprediction+=1
61+
pht.insert(list1.index(addr),[1,addr])
62+
if len(pht)>1024:
63+
del pht[0]
64+
65+
print("Misprediction:",misprediction)
66+
print("Total",len(readData))

0 commit comments

Comments
 (0)