-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
133 lines (115 loc) · 3.04 KB
/
main.py
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
128
129
130
131
132
133
# main.py
# This program plots the conductance distribution of multiple MRAM cells on a
# bit-line based on:
# [1] Rp (resistance-parallel) mean and variance
# [2] Rap (resistance-anti-parallel) mean and variance
# [3] number of MRAM cells on a bit-line
# note that we assume the random variables of each MRAM have the same
# but independent distribution
import GenSampling as gs
INSTLIST = ('[1] Start a new analysis\n'
'[2] Sample and plot with the current settings\n'
'[3] Sameple with the current settings\n'
'[4] Plot the distribition\n'
'[5] Change R\n'
'[6] Print the current settings\n'
'[7] Plot mean vs Cells\n'
'[8] Plot variance vs Cells\n'
'[9] Plot SNR vs Cells\n'
'[0] Plot SNR vs Number of Cells\n'
'[I] Print instrcutions\n'
'[E] Exit the program\n')
target = gs.GenSampling(None, None, None, None, None, None)
def newAyalsis():
print('Staring a new analysis...\n')
global target
target = gs.GenSampling(0, 0, 0, 0, 0, 0)
changeR()
changeNCell()
changeNTest()
printGs()
def changeR():
while(1):
inp = input('Please enter new RpMean RapMean RpStd RapStd: (No leading'
'space) Ex: 6000 12000 350 700\n')
ints = list(map(int, inp.split(' ')))
if len(ints) is 4:
break
else:
print('Enter Error')
target.changeR(ints[0], ints[1], ints[2], ints[3])
def changeNCell():
while(1):
inp = input('Please enter new number of MRAM cell: ')
inp = int(inp)
if inp > 0:
break
else:
print('Enter Error')
target.changeNCell(inp)
def changeNTest():
while(1):
inp = input('Please enter new number of samples: ')
inp = int(inp)
if inp > 0:
break
else:
print('Enter Error')
target.changeNTest(inp)
def sampleplot():
target.samplePlot()
def sample():
target.sample()
def plot():
target.mplot()
def printGs():
target.printSetting()
def meanPlot():
target.meanPlot()
def variancePlot():
target.variancePlot()
def snrPlot():
target.snrPlot()
def snrNcellPlot(times):
target.snrNcellPlot(times)
print('\n\n'
'********************************************************************\n'
'* Welcome to the equaivalent conductance analyzer for MRAM cells *\n'
'********************************************************************\n\n')
print(INSTLIST)
while(1):
inp = input('Please enter an instruction or help for the instrcution list: ')
if inp == 'help' or inp =='I':
print('\n'+INSTLIST)
elif inp == 'E':
break
try:
inp2 = int(inp)
except ValueError:
print('Please enter a correct instrcution')
continue
if (inp2 >=0 and inp2 <= 9):
if inp2 is 1:
newAyalsis()
elif inp2 is 2:
sampleplot()
elif inp2 is 3:
sample()
elif inp2 is 4:
plot()
elif inp2 is 5:
changeR()
elif inp2 is 6:
printGs()
elif inp2 is 7:
meanPlot()
elif inp2 is 8:
variancePlot()
elif inp2 is 9:
snrPlot()
elif inp2 is 0:
times = input('Up to how many cells?')
times = int(times)
snrNcellPlot(times)
else:
print('Please enter a correct instrcution')