2
2
from morpheus .Schematic import *
3
3
4
4
class maestro :
5
- def __init__ (self ,ws ,lib ,DUT ,test = None ) -> None :
5
+ def __init__ (self ,ws ,lib ,cell ,view ,DUT ,config , build = False ) -> None :
6
+ self .build = build #temp
6
7
self .DUT = DUT
7
8
self .ws = ws
8
9
self .lib = lib
9
- self .cell = DUT . cell_name + "_AUTO_TB"
10
-
10
+ self .cell = cell
11
+ self . view = view
11
12
self .equationDict = {
12
13
"DUT" : "DUT" #test.schem.DUT.name
13
14
}
14
15
15
- self .open () #TODO delete? become part of GUI Handler
16
+
17
+ #TODO MAKE SURE TO CLOSE ON ANY ERROR. Otherwise data is lost.
16
18
self .schematics = dict ()
17
- if (test ):
18
- schem = self .getSchematic (test ) #TODO should run in create test not before
19
- self .createTest (test ,schem )
20
-
19
+ self .config = config
20
+ #if(self.config):
21
+ # schem = self.getSchematic(self.config) #TODO should run in create test not before
22
+ #self.createTest(config,schem)
23
+ if (self .build ):
24
+ self .open () #TODO delete? become part of GUI Handler
25
+ self .createTests () #build everything
26
+ self .close () #TODO SAVE STATE OF OPEN/CLOSE FOR INDIVIDUAL FUNCTIONS
21
27
22
28
@staticmethod
23
29
def createMaestroView (ws ,dut_lib ,dut_cell ,tb_lib ):
@@ -28,18 +34,26 @@ def createMaestroView(ws,dut_lib,dut_cell,tb_lib):
28
34
29
35
return maestro (ws ,tb_lib ,DUT )
30
36
31
- def getSchematic (self ,test ):
32
- schem = self .schematics .get (test .schematic )
33
- if (schem is None ): #doesnt exist
34
- sconfig = config ("{filename}" .format (filename = test .schematic ),config_types .SCHEMATIC )
35
- schem = schematic (self .ws ,self .lib ,self .DUT ,sconfig ,test )
36
- schem .evaluate ()
37
- #
38
- schem .plan ()
39
- schem .build ()
40
- self .schematics .update ({test .schematic :schem })
37
+ def getSchematic (self ,testConfig ):
38
+ schem = self .schematics .get (testConfig .schematic )
39
+ if (schem is None ): #schematic doesnt already exist in dictionary
40
+ #sconfig = config("{filename}".format(filename = test.schematic),config_types.SCHEMATIC)
41
+ sconfig = config (testConfig .schematic ,config_types .SCHEMATIC )#find the config file for the schematic
42
+
43
+ #FIX!!!!!!!!!
44
+ sconfig .cell = self .cell #TODO
45
+ sconfig .name = "schematic" #MUST FIX!
46
+
47
+ schem = schematic (self .ws ,self .lib ,self .DUT ,sconfig ,testConfig )#check if exists as well
48
+ if (self .build ): #build (even if overwriting) in build mode
49
+ schem .plan ()
50
+ schem .build ()
51
+ self .schematics .update ({testConfig .schematic :schem })
41
52
return schem
42
53
54
+ #def getConfig(self,testConfig):
55
+
56
+
43
57
def createConfig (self ,Config ):
44
58
config_view = self .ws .hdb .Open (self .lib , self .cell , "config_" + Config .name , "a" , "CDBA" )
45
59
self .ws .hdb .SetTopCellViewName (config_view , self .lib , self .cell , Config .schematic )
@@ -49,20 +63,37 @@ def createConfig(self,Config):
49
63
self .ws .hdb .Save (config_view )
50
64
self .ws .hdb .Close (config_view )
51
65
52
- def createTest (self ,Config ,schem ):
53
-
54
- for test in Config .tests : #create all tests in maestro view
66
+ def createTests (self ):
67
+ #SINGLE TEST
68
+ if not hasattr (self .config , "tests" ): #TODO not this. I don't like this.
69
+ self .createDictFromSchem (self .config )
70
+ self .createTest (self .config )
71
+ else : #MULTITEST
72
+ for test in self .config .tests : #create all tests in the test config
73
+ self .createDictFromSchem (test )
74
+ createTest (test )
75
+ #add variables (TODO break into new function)
76
+ for var in self .config .variables :
77
+ self .ws .mae .SetVar (var .name .format (** self .equationDict ),var .value ,typeValue = var .test , #Attach varaibles to Maestro view
78
+ session = self .session )
79
+ #add corners
80
+ #self.createCorners()
81
+ def createTest (self ,test ):
82
+ schem = self .getSchematic (test )
55
83
setattr (test ,"schem" ,schem )
56
84
print ("create test {test}\n " .format ( test = test .name ))
57
85
self .ws .mae .CreateTest (test .name , session = self .session , # Create Test within Maestro
58
86
lib = self .lib , cell = self .cell , view = test .schem .view )
59
-
60
- self .ws .mae .SetAnalysis (test .name , test .analysis .type , #Add Test Analysis within Maestro
61
- session = self .session , options = test .analysis .options )
87
+
88
+ if not isinstance (test .analysis , list ):
89
+ test .analysis = [test .analysis ]
90
+ for analysis in test .analysis :
91
+ self .ws .mae .SetAnalysis (test .name , analysis .type , #Add Test Analysis within Maestro
92
+ session = self .session , options = analysis .options )
62
93
63
94
self .x_mainSDB = self .ws .axl .GetMainSetupDB ( self .session )
64
95
65
- self .ws .sev .AddExpression (self .session ,"ocean" ,"" ) #ocean scripts broken
96
+ # self.ws.sev.AddExpression(self.session,"ocean","") #ocean scripts broken
66
97
67
98
if (hasattr (test ,"corners" )): #add corners if present
68
99
self .createCorners (test )
@@ -73,15 +104,6 @@ def createTest(self,Config,schem):
73
104
if (hasattr (test ,"equations" )):
74
105
self .createEquations (test )
75
106
#self.addOceanScripts(test)
76
-
77
- for var in Config .variables :
78
-
79
- self .ws .mae .SetVar (var .name .format (** self .equationDict ),var .value ,typeValue = var .test , #Attach varaibles to Maestro view
80
- session = self .session )
81
-
82
-
83
-
84
- self .close ()
85
107
86
108
87
109
def createCorners (self , test ):
@@ -97,32 +119,58 @@ def createCorner(self,corner):
97
119
self .ws .axl .PutVar (newCorner , var .name , var .value )
98
120
99
121
def createEquations (self , test ):
122
+
100
123
for equation in test .equations :
101
124
self .createEquation (test , equation )
102
125
def createEquation (self , test , equation ):
103
-
104
- self .createEquDict (test ,equation )
105
- try :
106
- name = equation .name .format (** self .equationDict )
107
- expression = equation .equation .format (** self .equationDict )
108
- self .ws .mae .AddOutput (name ,test .name , session = self .session ,expr = expression )
109
- except :
110
- print ("no pins of type" , equation .type )
111
-
126
+ #creates equation for all of same type
127
+ #if hasattr(equation,"type"):
128
+ # self.createEquDict(test,equation)
129
+ #if type is an array then sweep those values but for now assume 1 sweeping pin type.
130
+ if (self .equationDict .get (equation .type ) is not None ):
131
+ for pin in self .equationDict .get (equation .type ):#TODO MOVE FOR LOOP TO CREATE EQUATIONS?!?!
132
+ tempDict = self .equationDict
133
+ tempDict .update ({equation .type :pin }) #TODO add linked varriables
134
+ expression = equation .equation .format (** tempDict )
135
+ name = equation .name .format (** tempDict )
136
+ self .ws .mae .AddOutput (name ,test .name , session = self .session ,expr = expression )#TODO CHECK IF EXISTS AND UPDATE
137
+
138
+ #def recursiveFormat():
139
+
112
140
113
141
def createSignals (self ,test ):
114
142
for signal in test .signals : #create all requred signals
115
143
self .createSignal (test , signal )
116
144
117
145
def createSignal (self , test , signal ):
146
+ if (self .equationDict .get (signal .type ) is not None ):
147
+ for pin in self .equationDict .get (signal .type ):#TODO MOVE FOR LOOP TO CREATE SIGNALS?!?!
148
+ tempDict = self .equationDict .copy () #MAKE COPY
149
+ tempDict .update ({signal .type :pin }) #TODO add linked varriables
150
+ expression = signal .signal .format (** tempDict )
151
+ name = signal .name .format (** tempDict )
152
+ signal_type = "net"
153
+ if (hasattr (signal , "signal_type" )):
154
+ signal_type = signal .signal_type
155
+ #self.ws.mae.AddOutput(name,test.name, session = self.session,expr = expression)#TODO CHECK IF EXISTS AND UPDATE
156
+ self .ws .mae .AddOutput (name ,test .name , session = self .session ,outputType = signal_type ,signalName = expression )
157
+
158
+ def createDictFromSchem (self ,test ): #auto run after loading schem
159
+ schematic = self .getSchematic (test )
160
+ #add pintypes
118
161
119
- if hasattr (signal ,"type" ):
120
- self .createEquDict (test ,signal )
121
-
122
- self .ws .mae .AddOutput (signal .name ,test .name , session = self .session ,outputType = "net" ,signalName = signal .signal .format (** self .equationDict ))
162
+ self .equationDict .update ({"DUT" :schematic .DUTinst .name }) #add linked varriables
163
+
164
+ for pin in schematic .evaluatedPins :
165
+ if pin .type is not None :
166
+ if pin .type not in self .equationDict :
167
+ self .equationDict .setdefault (pin .type , []) #initialize array
168
+ self .equationDict [pin .type ].append (pin .label ) #TODO Independent per test!
169
+
123
170
124
171
def createEquDict (self ,test , data ):#TODO add pins despite if none
125
- pins_of_type = [pin for pin in test .schem .evaluatedPins if pin .type == data .type ]
172
+ schematic = self .getSchematic (test )
173
+ pins_of_type = [pin for pin in schematic .evaluatedPins if pin .type == data .type ]
126
174
for pin in pins_of_type :
127
175
self .equationDict .update ({data .type : pin .label })
128
176
#format equation string with dict
@@ -136,7 +184,7 @@ def simulate(self):
136
184
pass
137
185
138
186
def open (self ):
139
- self .session = self .ws .mae .OpenSetup (self .lib , self .cell ,"maestro" ) #create new maestro view
187
+ self .session = self .ws .mae .OpenSetup (self .lib , self .cell ,self . view ) #create new maestro view
140
188
def close (self ):
141
189
self .ws .mae .SaveSetup (session = self .session )
142
190
self .ws .mae .CloseSession (session = self .session )
0 commit comments