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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
|
from PyQt5 import QtWidgets, QtCore
import os
from xml.etree import ElementTree as ET
from . import TrackWidget
class DeviceModel(QtWidgets.QWidget):
"""
- This class creates Device Library Tab in KicadtoNgspice Window
It dynamically creates the widget for device like diode,mosfet,
transistor and jfet.
- Same function as the subCircuit file, except for
this takes different parameters in the if block
- q TRANSISTOR
- d DIODE
- j JFET
- m MOSFET
- Other 2 functions same as the ones in subCircuit
- trackLibrary
- trackLibraryWithoutButton
"""
def __init__(self, schematicInfo, clarg1):
self.clarg1 = clarg1
kicadFile = self.clarg1
(projpath, filename) = os.path.split(kicadFile)
project_name = os.path.basename(projpath)
self.root = []
try:
f = open(
os.path.join(
projpath,
project_name +
"_Previous_Values.xml"),
'r')
tree = ET.parse(f)
parent_self = tree.getroot()
for child in parent_self:
if child.tag == "devicemodel":
self.root = child
except BaseException:
print("Device Model Previous XML is Empty")
QtWidgets.QWidget.__init__(self)
# Creating track widget object
self.obj_trac = TrackWidget.TrackWidget()
# Row and column count
self.row = 0
self.count = 1 # Entry count
self.entry_var = {}
# For MOSFET
self.widthLabel = {}
self.lengthLabel = {}
self.parameterLabel = {}
self.multifactorLable = {}
self.devicemodel_dict_beg = {}
self.devicemodel_dict_end = {}
# List to hold information about device
self.deviceDetail = {}
# Set Layout
self.grid = QtWidgets.QGridLayout()
self.setLayout(self.grid)
# print("Reading Device model details from Schematic")
if "sky130" in " ".join(schematicInfo):
self.eSim_sky130(schematicInfo)
else:
self.eSim_general_libs(schematicInfo)
def eSim_sky130(self, schematicInfo):
sky130box = QtWidgets.QGroupBox()
sky130grid = QtWidgets.QGridLayout()
self.count = self.count+1
self.row = self.row + 1
self.devicemodel_dict_beg["scmode1"] = self.count
beg = self.count
self.deviceDetail[self.count] = "scmode1"
sky130box.setTitle("Add parameters of SKY130 library ")
# +
# " : " +
# words[6])
self.parameterLabel[self.count] = QtWidgets.QLabel("Enter the path ")
self.row = self.row + 1
sky130grid.addWidget(self.parameterLabel[self.count], self.row, 0)
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setReadOnly(True)
for child in self.root:
if child.tag == "scmode1":
if child[0].text \
and os.path.exists(child[0].text):
self.entry_var[self.count] \
.setText(child[0].text)
path_name = child[0].text
else:
if os.name == 'nt':
path_name = os.path.abspath(
"library/" +
"sky130_fd_pr/models/sky130.lib.spice"
)
else:
path_name = os.path.abspath(
"/usr/share/local/" +
"sky130_fd_pr/models/sky130.lib.spice"
)
self.entry_var[self.count].setText(path_name)
# self.trackLibraryWithoutButton(self.count, path_name)
sky130grid.addWidget(self.entry_var[self.count], self.row, 1)
self.addbtn = QtWidgets.QPushButton("Add")
self.addbtn.setObjectName("%d" % beg)
self.addbtn.clicked.connect(self.trackLibrary)
sky130grid.addWidget(self.addbtn, self.row, 2)
# self.count = self.count + 1
self.adddefaultbtn = QtWidgets.QPushButton("Add Default")
self.adddefaultbtn.setObjectName("%d" % beg)
self.adddefaultbtn.clicked.connect(self.trackDefaultLib)
sky130grid.addWidget(self.adddefaultbtn, self.row, 3)
self.count = self.count + 1
self.parameterLabel[self.count] = QtWidgets.QLabel(
"Enter the corner e.g. tt")
self.row = self.row + 1
sky130grid.addWidget(self.parameterLabel[self.count], self.row, 0)
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setMaximumWidth(150)
self.entry_var[self.count].setObjectName("%d" % beg)
path_name = ''
for child in self.root:
if child.tag == "scmode1":
if child[1].text:
self.entry_var[self.count] \
.setText(child[1].text)
path_name = child[0].text
else:
self.entry_var[self.count].setText("")
sky130grid.addWidget(self.entry_var[self.count], self.row, 1)
self.entry_var[self.count].textChanged.connect(self.textChange)
self.trackLibraryWithoutButton(beg, path_name)
sky130box.setLayout(sky130grid)
sky130box.setStyleSheet(" \
QGroupBox { border: 1px solid gray; border-radius:\
9px; margin-top: 0.5em; } \
QGroupBox::title { subcontrol-origin: margin; left:\
10px; padding: 0 3px 0 3px; } \
")
self.grid.addWidget(sky130box)
# if self.entry_var[self.count-3].text() == "":
# pass
# else:
# self.trackLibraryWithoutButton(self.count-3, path_name)
self.row = self.row + 1
self.devicemodel_dict_end["scmode1"] = self.count
self.count = self.count + 1
for eachline in schematicInfo:
print("=========================================")
print(eachline)
words = eachline.split()
# supporteddesignator = ['sc', 'u', 'x', 'v', 'i', 'a']
if eachline[0:2] != 'sc' and eachline[0] != 'u' \
and eachline[0] != 'x' and eachline[0] != '*'\
and eachline[0] != 'v' and eachline[0] != 'i'\
and eachline[0] != 'a':
print("Only components with designators 'sc', 'u', \
'x', 'v', 'i', 'a'\
can be used with SKY130 mode")
print("Please remove other components")
self.msg = QtWidgets.QErrorMessage()
self.msg.setModal(True)
self.msg.setWindowTitle("Invalid components")
self.content = "Only components with designators " + \
"'sc', 'u' and 'x' can be used \
with SKY130 mode. " + \
"Please edit the schematic and \
generate netlist again"
self.msg.showMessage(self.content)
self.msg.exec_()
return
elif eachline[0:2] == 'sc' and eachline[0:6] != 'scmode':
self.devicemodel_dict_beg[words[0]] = self.count
self.deviceDetail[self.count] = words[0]
sky130box = QtWidgets.QGroupBox()
sky130grid = QtWidgets.QGridLayout()
beg = self.count
sky130box.setTitle(
"Add parameters for " +
words[0] + " : " + words[-1])
path_name = ''
# Adding to get SKY130 dimension
self.parameterLabel[self.count] = QtWidgets.QLabel(
"Enter the parameters of SKY130 component " + words[0])
sky130grid.addWidget(
self.parameterLabel[self.count], self.row, 0)
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setMaximumWidth(1000)
self.entry_var[self.count].setObjectName("%d" % beg)
sky130grid.addWidget(self.entry_var[self.count], self.row, 1)
self.entry_var[self.count].textChanged.connect(self.textChange)
sky130box.setLayout(sky130grid)
sky130box.setStyleSheet(" \
QGroupBox { border: 1px solid gray; border-radius: \
9px; margin-top: 0.5em; } \
QGroupBox::title { subcontrol-origin: margin; left:\
10px; padding: 0 3px 0 3px; } \
")
try:
for child in self.root:
if child.tag == words[0]:
# print("DEVICE MODEL MATCHING---", \
# child.tag, words[0])
try:
if child[0].text:
self.entry_var[self.count] \
.setText(child[0].text)
path_name = child[0].text
else:
self.entry_var[self.count].setText("")
path_name = ""
except BaseException as e:
print("Error when set text of Device " +
"SKY130 Component :", str(e))
except BaseException:
pass
self.trackLibraryWithoutButton(self.count, path_name)
self.grid.addWidget(sky130box)
# Adding Device Details #
# Increment row and widget count
self.row = self.row + 1
self.devicemodel_dict_end[words[0]] = self.count
self.count = self.count + 1
self.show()
def eSim_general_libs(self, schematicInfo):
for eachline in schematicInfo:
print("=========================================")
print(eachline)
words = eachline.split()
if eachline[0] == 'q':
# print("Device Model Transistor: ", words[0])
self.devicemodel_dict_beg[words[0]] = self.count
transbox = QtWidgets.QGroupBox()
transgrid = QtWidgets.QGridLayout()
transbox.setTitle(
"Add library for Transistor " +
words[0] +
" : " +
words[4])
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setReadOnly(True)
global path_name
try:
for child in self.root:
if child.tag == words[0]:
# print("DEVICE MODEL MATCHING---", \
# child.tag, words[0])
try:
if child[0].text \
and os.path.exists(child[0].text):
self.entry_var[self.count] \
.setText(child[0].text)
path_name = child[0].text
else:
self.entry_var[self.count].setText("")
except BaseException as e:
print("Error when set text of device " +
"model transistor :", str(e))
except BaseException:
pass
transgrid.addWidget(self.entry_var[self.count], self.row, 1)
self.addbtn = QtWidgets.QPushButton("Add")
self.addbtn.setObjectName("%d" % self.count)
self.addbtn.clicked.connect(self.trackLibrary)
self.deviceDetail[self.count] = words[0]
if self.entry_var[self.count].text() == "":
pass
else:
self.trackLibraryWithoutButton(self.count, path_name)
transgrid.addWidget(self.addbtn, self.row, 2)
transbox.setLayout(transgrid)
# CSS
transbox.setStyleSheet(" \
QGroupBox { border: 1px solid gray; border-radius: \
9px; margin-top: 0.5em; } \
QGroupBox::title { subcontrol-origin: margin; left:\
10px; padding: 0 3px 0 3px; } \
")
self.grid.addWidget(transbox)
# Adding Device Details #
# Increment row and widget count
self.row = self.row + 1
self.devicemodel_dict_end[words[0]] = self.count
self.count = self.count + 1
elif eachline[0] == 'd':
# print("Device Model Diode:", words[0])
self.devicemodel_dict_beg[words[0]] = self.count
diodebox = QtWidgets.QGroupBox()
diodegrid = QtWidgets.QGridLayout()
diodebox.setTitle(
"Add library for Diode " +
words[0] +
" : " +
words[3])
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setReadOnly(True)
# global path_name
try:
for child in self.root:
if child.tag == words[0]:
# print("DEVICE MODEL MATCHING---", \
# child.tag, words[0])
try:
if child[0].text \
and os.path.exists(child[0].text):
path_name = child[0].text
self.entry_var[self.count] \
.setText(child[0].text)
else:
self.entry_var[self.count].setText("")
except BaseException as e:
print("Error when set text of device " +
"model diode :", str(e))
except BaseException:
pass
diodegrid.addWidget(self.entry_var[self.count], self.row, 1)
self.addbtn = QtWidgets.QPushButton("Add")
self.addbtn.setObjectName("%d" % self.count)
self.addbtn.clicked.connect(self.trackLibrary)
self.deviceDetail[self.count] = words[0]
if self.entry_var[self.count].text() == "":
pass
else:
self.trackLibraryWithoutButton(self.count, path_name)
diodegrid.addWidget(self.addbtn, self.row, 2)
diodebox.setLayout(diodegrid)
# CSS
diodebox.setStyleSheet(" \
QGroupBox { border: 1px solid gray; border-radius: \
9px; margin-top: 0.5em; } \
QGroupBox::title { subcontrol-origin: margin; left:\
10px; padding: 0 3px 0 3px; } \
")
self.grid.addWidget(diodebox)
# Adding Device Details #
# Increment row and widget count
self.row = self.row + 1
self.devicemodel_dict_end[words[0]] = self.count
self.count = self.count + 1
elif eachline[0] == 'j':
# print("Device Model JFET:", words[0])
self.devicemodel_dict_beg[words[0]] = self.count
jfetbox = QtWidgets.QGroupBox()
jfetgrid = QtWidgets.QGridLayout()
jfetbox.setTitle(
"Add library for JFET " +
words[0] +
" : " +
words[4])
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setReadOnly(True)
# global path_name
try:
for child in self.root:
if child.tag == words[0]:
# print("DEVICE MODEL MATCHING---", \
# child.tag, words[0])
try:
if child[0].text \
and os.path.exists(child[0].text):
self.entry_var[self.count] \
.setText(child[0].text)
path_name = child[0].text
else:
self.entry_var[self.count].setText("")
except BaseException as e:
print("Error when set text of Device " +
"Model JFET :", str(e))
except BaseException:
pass
jfetgrid.addWidget(self.entry_var[self.count], self.row, 1)
self.addbtn = QtWidgets.QPushButton("Add")
self.addbtn.setObjectName("%d" % self.count)
self.addbtn.clicked.connect(self.trackLibrary)
self.deviceDetail[self.count] = words[0]
if self.entry_var[self.count].text() == "":
pass
else:
self.trackLibraryWithoutButton(self.count, path_name)
jfetgrid.addWidget(self.addbtn, self.row, 2)
jfetbox.setLayout(jfetgrid)
# CSS
jfetbox.setStyleSheet(" \
QGroupBox { border: 1px solid gray; border-radius:\
9px; margin-top: 0.5em; } \
QGroupBox::title { subcontrol-origin: margin; left:\
10px; padding: 0 3px 0 3px; } \
")
self.grid.addWidget(jfetbox)
# Adding Device Details #
# Increment row and widget count
self.row = self.row + 1
self.devicemodel_dict_end[words[0]] = self.count
self.count = self.count + 1
elif eachline[0] == 'm':
self.devicemodel_dict_beg[words[0]] = self.count
mosfetbox = QtWidgets.QGroupBox()
mosfetgrid = QtWidgets.QGridLayout()
i = self.count
beg = self.count
mosfetbox.setTitle(
"Add library for MOSFET " +
words[0] +
" : " +
words[5])
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setReadOnly(True)
mosfetgrid.addWidget(self.entry_var[self.count], self.row, 1)
self.addbtn = QtWidgets.QPushButton("Add")
self.addbtn.setObjectName("%d" % self.count)
self.addbtn.clicked.connect(self.trackLibrary)
mosfetgrid.addWidget(self.addbtn, self.row, 2)
# Adding Device Details
self.deviceDetail[self.count] = words[0]
# Increment row and widget count
self.row = self.row + 1
self.count = self.count + 1
# Adding to get MOSFET dimension
self.widthLabel[self.count] = QtWidgets.QLabel(
"Enter width of MOSFET " + words[0] + "(default=100u):")
mosfetgrid.addWidget(self.widthLabel[self.count], self.row, 0)
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setMaximumWidth(150)
mosfetgrid.addWidget(self.entry_var[self.count], self.row, 1)
self.row = self.row + 1
self.count = self.count + 1
self.lengthLabel[self.count] = QtWidgets.QLabel(
"Enter length of MOSFET " + words[0] + "(default=100u):")
mosfetgrid.addWidget(self.lengthLabel[self.count], self.row, 0)
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
self.entry_var[self.count].setMaximumWidth(150)
mosfetgrid.addWidget(self.entry_var[self.count], self.row, 1)
self.row = self.row + 1
self.count = self.count + 1
self.multifactorLable[self.count] = QtWidgets.QLabel(
"Enter multiplicative factor of MOSFET " +
words[0] + "(default=1):")
mosfetgrid.addWidget(
self.multifactorLable[self.count], self.row, 0)
self.entry_var[self.count] = QtWidgets.QLineEdit()
self.entry_var[self.count].setText("")
end = self.count
self.entry_var[self.count].setMaximumWidth(150)
mosfetgrid.addWidget(self.entry_var[self.count], self.row, 1)
self.row = self.row + 1
self.devicemodel_dict_end[words[0]] = self.count
self.count = self.count + 1
mosfetbox.setLayout(mosfetgrid)
# global path_name
try:
for child in self.root:
if child.tag == words[0]:
# print("DEVICE MODEL MATCHING---", \
# child.tag, words[0])
while i <= end:
self.entry_var[i].setText(child[i-beg].text)
if (i - beg) == 0:
if os.path.exists(child[0].text):
self.entry_var[i] \
.setText(child[i-beg].text)
path_name = child[i-beg].text
else:
self.entry_var[i].setText("")
i = i + 1
except BaseException:
pass
# CSS
mosfetbox.setStyleSheet(" \
QGroupBox { border: 1px solid gray; border-radius:\
9px; margin-top: 0.5em; } \
QGroupBox::title { subcontrol-origin: margin; left: \
10px; padding: 0 3px 0 3px; } \
")
if self.entry_var[beg].text() == "":
pass
else:
self.trackLibraryWithoutButton(beg, path_name)
self.grid.addWidget(mosfetbox)
self.show()
def trackDefaultLib(self):
sending_btn = self.sender()
self.widgetObjCount = int(sending_btn.objectName())
if os.name == 'nt':
path_name = os.path.abspath(
"library/" +
"sky130_fd_pr/models/sky130.lib.spice"
)
else:
path_name = os.path.abspath(
"/usr/share/local/" +
"sky130_fd_pr/models/sky130.lib.spice"
)
self.entry_var[self.widgetObjCount].setText(path_name)
self.trackLibraryWithoutButton(self.widgetObjCount, path_name)
def textChange(self):
sending_btn = self.sender()
self.widgetObjCount = int(sending_btn.objectName())
self.deviceName = self.deviceDetail[self.widgetObjCount]
# self.widgetObjCount = self.count_beg
# if self.deviceName[0] == 'm':
# width = str(self.entry_var[self.widgetObjCount + 1].text())
# length = str(self.entry_var[self.widgetObjCount + 2].text())
# multifactor = str(self.entry_var[self.widgetObjCount + 3].text())
# if width == "":
# width = "100u"
# if length == "":
# length = "100u"
# if multifactor == "":
# multifactor = "1"
# self.obj_trac.deviceModelTrack[self.deviceName] =\
# str(self.entry_var[self.widgetObjCount].text()) + \
# ":" + "W=" + width + " L=" + length + " M=" + multifactor
if self.deviceName[0:6] == 'scmode':
self.obj_trac.deviceModelTrack[self.deviceName] = \
self.entry_var[self.widgetObjCount].text() + \
":" + str(self.entry_var[self.widgetObjCount + 1].text())
print(self.obj_trac.deviceModelTrack[self.deviceName])
elif self.deviceName[0:2] == 'sc':
self.obj_trac.deviceModelTrack[self.deviceName] = str(
self.entry_var[self.widgetObjCount].text())
print(self.obj_trac.deviceModelTrack[self.deviceName])
else:
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile
def trackLibrary(self):
"""
This function is use to keep track of all Device Model widget
"""
print("Calling Track Device Model Library funtion")
sending_btn = self.sender()
self.widgetObjCount = int(sending_btn.objectName())
init_path = '../../'
if os.name == 'nt':
init_path = ''
self.libfile = QtCore.QDir.toNativeSeparators(
QtWidgets.QFileDialog.getOpenFileName(
self, "Open Library Directory",
init_path + "library/deviceModelLibrary", "*.lib"
)[0]
)
if not self.libfile:
return
# Setting Library to Text Edit Line
self.entry_var[self.widgetObjCount].setText(self.libfile)
self.deviceName = self.deviceDetail[self.widgetObjCount]
# Storing to track it during conversion
if self.deviceName[0] == 'm':
width = str(self.entry_var[self.widgetObjCount + 1].text())
length = str(self.entry_var[self.widgetObjCount + 2].text())
multifactor = str(self.entry_var[self.widgetObjCount + 3].text())
if width == "":
width = "100u"
if length == "":
length = "100u"
if multifactor == "":
multifactor = "1"
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile + \
":" + "W=" + width + " L=" + length + " M=" + multifactor
elif self.deviceName[0:6] == 'scmode':
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile + \
":" + str(self.entry_var[self.widgetObjCount + 1].text())
print(self.obj_trac.deviceModelTrack[self.deviceName])
elif self.deviceName[0:2] == 'sc':
self.obj_trac.deviceModelTrack[self.deviceName] = str(
self.entry_var[self.widgetObjCount].text())
print(self.obj_trac.deviceModelTrack[self.deviceName])
else:
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile
def trackLibraryWithoutButton(self, iter_value, path_value):
"""
This function is use to keep track of all Device Model widget
"""
print("Calling Track Library function Without Button")
self.widgetObjCount = iter_value
print("self.widgetObjCount-----", self.widgetObjCount)
self.libfile = path_value
print("PATH VALUE", path_value)
# Setting Library to Text Edit Line
self.entry_var[self.widgetObjCount].setText(self.libfile)
self.deviceName = self.deviceDetail[self.widgetObjCount]
# Storing to track it during conversion
if self.deviceName[0] == 'm':
width = str(self.entry_var[self.widgetObjCount + 1].text())
length = str(self.entry_var[self.widgetObjCount + 2].text())
multifactor = str(self.entry_var[self.widgetObjCount + 3].text())
if width == "":
width = "100u"
if length == "":
length = "100u"
if multifactor == "":
multifactor = "1"
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile + \
":" + "W=" + width + " L=" + length + " M=" + multifactor
elif self.deviceName[0:6] == 'scmode':
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile + \
":" + str(self.entry_var[self.widgetObjCount + 1].text())
print(self.obj_trac.deviceModelTrack[self.deviceName])
elif self.deviceName[0:2] == 'sc':
self.obj_trac.deviceModelTrack[self.deviceName] = str(
self.entry_var[self.widgetObjCount].text())
print(self.obj_trac.deviceModelTrack[self.deviceName])
else:
self.obj_trac.deviceModelTrack[self.deviceName] = self.libfile
def GenerateSOCbutton(self):
#############################################################
# ***************** SPICE to Verilog Converter **************
# The development is under progress and may not be accurate
# Developed by:
# Sumanto Kar, sumantokar@iitb.ac.in
# Nagesh Karmali, nags@cse.iitb.ac.in
# Firuza Karmali, firuza@cse.iitb.ac.in
# Rahul Paknikar, rahulp@iitb.ac.in
# GUIDED BY:
# Kunal Ghosh, VLSI System Design Corp.Pvt.Ltd
# Anagha Ghosh, VLSI System Design Corp.Pvt.Ltd
# Philipp Gühring
# ***********************************************************
kicadFile = self.clarg1
(projpath, filename) = os.path.split(kicadFile)
analysisfile = open(os.path.join(projpath, filename))
# analysisfile = open(os.path.join(projpath, 'analysis'))
content = analysisfile.read()
contentlines = content.split("\n")
parsedfile = open(os.path.join(projpath, filename+'.parsed.v'), 'w')
parsedfile.write("")
# print("module "+filename)
i = 1
inputlist = []
realinputlist = []
outputlist = []
realoutputlist = []
wirelist = []
realwirelist = []
uutlist = []
filelist = []
parsedcontent = []
for contentlist in contentlines:
if "IPDD" in contentlist or "IPAD" in contentlist:
# if len(contentlist)>1 and ( contentlist[0:1]=='U'\
# or contentlist[0:1]=='X') and not 'plot_' in contentlist :
# print(contentlist)
netnames = contentlist.split()
net = ' '.join(map(str, netnames[1:-1]))
netnames[-1] = netnames[-1].replace("IPAD", '')
netnames[-1] = netnames[-1].replace("IPDD", '')
# net=net.replace(netnames[-1],'')
# net=net.replace('BI_','')
# net=net.replace('BO_','')
net2 = []
for j in net.split():
# print(j)
secondpart = j
if '_' in j:
secondpart = j.split('_')[1]
if secondpart in net2:
continue
if net.count(secondpart)-1 > 0:
k = "["+str(net.count(secondpart)-1) + \
":0"+"] "+secondpart
else:
k = secondpart
net2.append(secondpart)
if '_I_' in str(j):
inputlist.append(k)
if '_IR_' in str(j):
inputlist.append(k)
if '_O_' in str(j):
outputlist.append(k)
if '_OR_' in str(j):
realoutputlist.append(k)
if '_W_' in str(j) and not (k in wirelist):
wirelist.append(k)
if '_WR_' in str(j) and not (k in realwirelist):
realwirelist.append(k)
netnames[-1] = netnames[-1].replace("IPAD", '')
netnames[-1] = netnames[-1].replace("IPDD", '')
uutlist.append(netnames[-1]+" uut" +
str(i)+" ("+', '.join(net2)+');')
filelist.append(netnames[-1])
i = i+1
# print(inputlist)
# print(outputlist)
# print(wirelist)
parsedcontent.append(
"\\\\Generated from SPICE to Verilog. \
Converter developed at FOSSEE, IIT Bombay\n")
parsedcontent.append(
"\\\\The development is under progress and may not be accurate.\n")
for j in filelist:
parsedcontent.append('''`include "'''+j+'''.v"''')
parsedcontent.append(
"module "+filename+"("+', '.join(inputlist # noqa
+ realinputlist + outputlist + realoutputlist)+");") # noqa
if inputlist:
parsedcontent.append("input "+', '.join(inputlist)+";")
if realinputlist:
parsedcontent.append("input real "+', '.join(inputlist)+";")
if outputlist:
parsedcontent.append("output "+', '.join(outputlist)+";")
if realoutputlist:
parsedcontent.append("output real "+', '.join(realoutputlist)+";")
if wirelist:
parsedcontent.append("wire "+', '.join(wirelist)+";")
if realwirelist:
parsedcontent.append("wire real"+', '.join(realwirelist)+";")
for j in uutlist:
parsedcontent.append(j)
parsedcontent.append("endmodule;")
print('\n**************Generated Verilog File: ' +
filename + '.parsed.v***************\n')
for j in parsedcontent:
print(j)
parsedfile.write(j+"\n")
print(
'\n*************************************\
************************************\n')
self.msg = QtWidgets.QErrorMessage()
self.msg.setModal(True)
self.msg.setWindowTitle("Verilog File Generated")
self.content = "The Verilog file has been successfully \
generated from the SPICE netlist"
self.msg.showMessage(self.content)
self.msg.exec_()
return
|