From 5000da993e5d83bc4306a556da4ccc254145bd31 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 00:15:25 +0530 Subject: Restructured Verilator libraries --- src/maker/NgVeri.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index d26c9338..5f0e1bcb 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -252,6 +252,10 @@ class NgVeri(QtWidgets.QWidget): # This is to remove lint_off comments needed by the verilator warnings # This function writes to the lint_off.txt here in the same folder def lint_off_edit(self, text): + init_path = '../../' + if os.name == 'nt': + init_path = '' + if text == "Edit lint_off": return index = self.entry_var[2].findText(text) @@ -260,17 +264,18 @@ class NgVeri(QtWidgets.QWidget): ret = QtWidgets.QMessageBox.warning( None, "Warning", - '''Do you want to remove the lint off error:''' + + '''Do you want to remove the lint off error: ''' + text, QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel) + if ret == QtWidgets.QMessageBox.Ok: - file = open("../maker/lint_off.txt", 'r') + file = open(init_path + "library/tlv/lint_off.txt", 'r') data = file.readlines() file.close() data.remove(text + "\n") - file = open("../maker/lint_off.txt", 'w') + file = open(init_path + "library/tlv/lint_off.txt", 'w') for item in data: file.write(item) return @@ -281,11 +286,15 @@ class NgVeri(QtWidgets.QWidget): # This is to add lint_off comments needed by the verilator warnings # This function writes to the lint_off.txt here in the same folder def add_lint_off(self): + init_path = '../../' + if os.name == 'nt': + init_path = '' + text = self.entry_var[3].text() if self.entry_var[2].findText(text) == -1: self.entry_var[2].addItem(text) - file = open("../maker/lint_off.txt", 'a+') + file = open(init_path + "library/tlv/lint_off.txt", 'a+') file.write(text + "\n") file.close() self.entry_var[3].setText("") @@ -325,7 +334,12 @@ class NgVeri(QtWidgets.QWidget): self.count += 1 self.entry_var[self.count] = QtWidgets.QComboBox() self.entry_var[self.count].addItem("Edit lint_off") - self.lint_off = open("../maker/lint_off.txt", 'r') + + init_path = '../../' + if os.name == 'nt': + init_path = '' + self.lint_off = open(init_path + "library/tlv/lint_off.txt", 'r') + self.data = self.lint_off.readlines() self.lint_off.close() for item in self.data: -- cgit From faadcb72916d269aeabbaa23f799962b6b99c45c Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 00:59:17 +0530 Subject: Replaced SafeConfigParser alias with ConfigParser --- src/maker/NgVeri.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index 5f0e1bcb..4e3e37da 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -34,7 +34,6 @@ from . import ModelGeneration import os import subprocess from configuration.Appconfig import Appconfig -from configparser import SafeConfigParser from configparser import ConfigParser @@ -48,7 +47,7 @@ class NgVeri(QtWidgets.QWidget): # Maker.addverilog(self) self.obj_Appconfig = Appconfig() self.home = os.path.expanduser("~") - self.parser = SafeConfigParser() + self.parser = ConfigParser() self.parser.read(os.path.join( self.home, os.path.join('.nghdl', 'config.ini'))) self.ngspice_home = self.parser.get('NGSPICE', 'NGSPICE_HOME') -- cgit From 1b42df112e9d13afd092d9f415e7e446a2102e85 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 01:07:20 +0530 Subject: Restructured config paths and other path issues --- src/maker/NgVeri.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index 4e3e37da..496782f9 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -46,16 +46,21 @@ class NgVeri(QtWidgets.QWidget): QtWidgets.QWidget.__init__(self) # Maker.addverilog(self) self.obj_Appconfig = Appconfig() - self.home = os.path.expanduser("~") + + if os.name == 'nt': + self.home = os.path.join('library', 'config') + else: + self.home = os.path.expanduser('~') + self.parser = ConfigParser() self.parser.read(os.path.join( self.home, os.path.join('.nghdl', 'config.ini'))) - self.ngspice_home = self.parser.get('NGSPICE', 'NGSPICE_HOME') - self.release_dir = self.parser.get('NGSPICE', 'RELEASE') + self.nghdl_home = self.parser.get('NGHDL', 'NGHDL_HOME') + self.release_dir = self.parser.get('NGHDL', 'RELEASE') self.src_home = self.parser.get('SRC', 'SRC_HOME') self.licensefile = self.parser.get('SRC', 'LICENSE') - self.digital_home = self.parser.get('NGSPICE', 'DIGITAL_MODEL') - self.digital_home = self.digital_home.split("/ghdl")[0] + "/Ngveri" + self.digital_home = self.parser.get('NGHDL', 'DIGITAL_MODEL') + self.digital_home = self.digital_home + "/Ngveri" self.count = 0 self.text = "" self.entry_var = {} @@ -77,8 +82,7 @@ class NgVeri(QtWidgets.QWidget): # Adding the verilog file in Maker tab to Ngveri Tab automatically def addverilog(self): - - init_path = '../../../' + init_path = '../../' if os.name == 'nt': init_path = '' # b=Maker.Maker(self) -- cgit From 7aa5afaeb6ac078d233383663ec6f96e20420b43 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 01:15:43 +0530 Subject: Prompt ToS if Sandpiper-SaaS directly invoked --- src/maker/NgVeri.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index 496782f9..3a1cc845 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -104,6 +104,17 @@ class NgVeri(QtWidgets.QWidget): file = (os.path.basename(self.fname)).split('.')[0] if self.entry_var[1].findText(file) == -1: self.entry_var[1].addItem(file) + + if not Maker.makerchipTOSAccepted(True): + QtWidgets.QMessageBox.warning( + None, "Warning Message", + "Please accept the Makerchip Terms of Service " + "to proceed further.", + QtWidgets.QMessageBox.Ok + ) + + return + model.verilogfile() error = model.verilogParse() if error != "Error": -- cgit From c1dcf941062f7c900d6cdb3a40205f3c77d949e4 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 01:22:05 +0530 Subject: Updated Ngspice 'make' commands for Windows OS --- src/maker/NgVeri.py | 94 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 29 deletions(-) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index 3a1cc845..c3c4d07c 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -32,6 +32,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui from . import Maker from . import ModelGeneration import os +import shutil import subprocess from configuration.Appconfig import Appconfig from configparser import ConfigParser @@ -115,30 +116,53 @@ class NgVeri(QtWidgets.QWidget): return - model.verilogfile() - error = model.verilogParse() - if error != "Error": - model.getPortInfo() - model.cfuncmod() - model.ifspecwrite() - model.sim_main_header() - model.sim_main() - model.modpathlst() - model.run_verilator() - model.make_verilator() - model.copy_verilator() - model.runMake() - model.runMakeInstall() - txt = self.entry_var[0].toPlainText() - if "error" not in txt.lower(): - self.entry_var[0].append(''' -

- Model Created Successfully ! -

- ''') - else: - self.entry_var[0].append(''' -

+ try: + model.verilogfile() + error = model.verilogParse() + if error != "Error": + model.getPortInfo() + model.cfuncmod() + model.ifspecwrite() + model.sim_main_header() + model.sim_main() + model.modpathlst() + model.run_verilator() + model.make_verilator() + model.copy_verilator() + model.runMake() + + if os.name != 'nt': + model.runMakeInstall() + else: + try: + shutil.copy( + self.release_dir + "/src/xspice/icm/Ngveri/Ngveri.cm", + self.nghdl_home + "/lib/ngspice/" + ) + except FileNotFoundError as err: + self.entry_var[0].append( + "Error in copying Ngveri code model: " + str(err) + ) + + terminalLog = self.entry_var[0].toPlainText() + if "error" not in terminalLog.lower(): + self.entry_var[0].append(''' +

+ Model Created Successfully! +

+ ''') + + return + + except BaseException as err: + self.entry_var[0].append( + "Error in Ngspice code model generation from Verilog: " + str(err) + ) + + terminalLog = self.entry_var[0].toPlainText() + if "error" in terminalLog.lower(): + self.entry_var[0].append(''' +

There was an error during model creation,
Please rectify the error and try again ! @@ -256,12 +280,24 @@ class NgVeri(QtWidgets.QWidget): self.fname = Maker.verilogFile[self.filecount] model = ModelGeneration.ModelGeneration( self.fname, self.entry_var[0]) - model.runMake() - model.runMakeInstall() - return - # else: - # return + try: + model.runMake() + + if os.name != 'nt': + model.runMakeInstall() + else: + shutil.copy( + self.release_dir + "/src/xspice/icm/Ngveri/Ngveri.cm", + self.nghdl_home + "/lib/ngspice/" + ) + except BaseException as err: + QtWidgets.QMessageBox.critical( + None, "Error Message", + "The verilog model '" + str(text) + + "' could not be removed: " + str(err), + QtWidgets.QMessageBox.Ok) + # This is to remove lint_off comments needed by the verilator warnings # This function writes to the lint_off.txt here in the same folder -- cgit From 272bf20219595c3c541797b1045ce9c400ab02d6 Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 01:50:56 +0530 Subject: Added a note and tooltip for Makerchip requirements --- src/maker/NgVeri.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index c3c4d07c..c1fbcb4e 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -226,6 +226,10 @@ class NgVeri(QtWidgets.QWidget): self.addverilogbutton = QtWidgets.QPushButton( "Run Verilog to NgSpice Converter") + self.addverilogbutton.setToolTip( + "Requires internet connection for converting TL-Verilog models" + ) + self.addverilogbutton.setToolTipDuration(5000) self.optionsgroupbtn.addButton(self.addverilogbutton) self.addverilogbutton.clicked.connect(self.addverilog) self.optionsgrid.addWidget(self.addverilogbutton, 0, 1) -- cgit From 87bc2c82192c948ddb88c52dfcd5213920920c2f Mon Sep 17 00:00:00 2001 From: rahulp13 Date: Tue, 22 Feb 2022 02:31:30 +0530 Subject: Fixed typos and resolved flake8 issues --- src/maker/NgVeri.py | 81 +++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'src/maker/NgVeri.py') diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index c1fbcb4e..cb553a31 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -28,12 +28,11 @@ # importing the files and libraries -from PyQt5 import QtCore, QtWidgets, QtGui +from PyQt5 import QtCore, QtWidgets from . import Maker from . import ModelGeneration import os import shutil -import subprocess from configuration.Appconfig import Appconfig from configparser import ConfigParser @@ -83,9 +82,6 @@ class NgVeri(QtWidgets.QWidget): # Adding the verilog file in Maker tab to Ngveri Tab automatically def addverilog(self): - init_path = '../../' - if os.name == 'nt': - init_path = '' # b=Maker.Maker(self) print(Maker.verilogFile) if Maker.verilogFile[self.filecount] == "": @@ -93,11 +89,13 @@ class NgVeri(QtWidgets.QWidget): None, "Error Message", "Error: No Verilog File Chosen. \ - Please chose a Verilog file in Makerchip Tab", + Please choose a verilog file in Makerchip Tab
", QtWidgets.QMessageBox.Ok) if reply == QtWidgets.QMessageBox.Ok: self.obj_Appconfig.print_error( - 'No VerilogFile. Please add a File in Makerchip Tab') + 'No Verilog File Chosen. ' + 'Please choose a verilog file in Makerchip Tab' + ) return self.fname = Maker.verilogFile[self.filecount] @@ -136,7 +134,8 @@ class NgVeri(QtWidgets.QWidget): else: try: shutil.copy( - self.release_dir + "/src/xspice/icm/Ngveri/Ngveri.cm", + self.release_dir + + "/src/xspice/icm/Ngveri/Ngveri.cm", self.nghdl_home + "/lib/ngspice/" ) except FileNotFoundError as err: @@ -147,8 +146,8 @@ class NgVeri(QtWidgets.QWidget): terminalLog = self.entry_var[0].toPlainText() if "error" not in terminalLog.lower(): self.entry_var[0].append(''' -

- Model Created Successfully! +

Model Created Successfully!

''') @@ -156,35 +155,37 @@ class NgVeri(QtWidgets.QWidget): except BaseException as err: self.entry_var[0].append( - "Error in Ngspice code model generation from Verilog: " + str(err) + "Error in Ngspice code model generation " + + "from Verilog: " + str(err) ) terminalLog = self.entry_var[0].toPlainText() if "error" in terminalLog.lower(): self.entry_var[0].append(''' -

- There was an error during model creation, -
- Please rectify the error and try again ! +

There was an error during model creation, +
Please rectify the error and try again!

- ''') - - # This function is used to add additional files required by the verilog - # top module + ''') def addfile(self): + ''' + This function is used to add additional files required + by the verilog top module + ''' if len(Maker.verilogFile) < (self.filecount + 1): reply = QtWidgets.QMessageBox.critical( None, "Error Message", "Error: No Verilog File Chosen. \ - Please chose a Verilog file in Makerchip Tab", + Please choose a verilog file in Makerchip Tab
", QtWidgets.QMessageBox.Ok) if reply == QtWidgets.QMessageBox.Ok: self.obj_Appconfig.print_error( - 'No VerilogFile. Please chose\ - a Verilog File in Makerchip Tab') + 'No Verilog File Chosen. Please choose \ + a verilog file in Makerchip Tab') return + self.fname = Maker.verilogFile[self.filecount] model = ModelGeneration.ModelGeneration(self.fname, self.entry_var[0]) # model.verilogfile() @@ -198,12 +199,12 @@ class NgVeri(QtWidgets.QWidget): None, "Error Message", "Error: No Verilog File Chosen. \ - Please chose a Verilog file in Makerchip Tab", + Please choose a verilog file in Makerchip Tab", QtWidgets.QMessageBox.Ok) if reply == QtWidgets.QMessageBox.Ok: self.obj_Appconfig.print_error( - 'No VerilogFile. Please chose \ - a Verilog File in Makerchip Tab') + 'No Verilog File Chosen. Please choose \ + a verilog file in Makerchip Tab') return self.fname = Maker.verilogFile[self.filecount] model = ModelGeneration.ModelGeneration(self.fname, self.entry_var[0]) @@ -260,7 +261,7 @@ class NgVeri(QtWidgets.QWidget): return self.optionsbox # This function is used to remove models in modlst of Ngspice folder if - # the user wants to remove a model.Note: files do not get removed + # the user wants to remove a model. Note: files do not get removed def edit_modlst(self, text): if text == "Edit modlst": return @@ -268,7 +269,7 @@ class NgVeri(QtWidgets.QWidget): self.entry_var[1].removeItem(index) self.entry_var[1].setCurrentIndex(0) ret = QtWidgets.QMessageBox.warning( - None, "Warning", '''Do you want to remove model:''' + + None, "Warning", '''Do you want to remove the model: ''' + text, QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel ) @@ -297,15 +298,17 @@ class NgVeri(QtWidgets.QWidget): ) except BaseException as err: QtWidgets.QMessageBox.critical( - None, "Error Message", - "The verilog model '" + str(text) + - "' could not be removed: " + str(err), - QtWidgets.QMessageBox.Ok) - + None, "Error Message", + "The verilog model '" + str(text) + + "' could not be removed: " + str(err), + QtWidgets.QMessageBox.Ok + ) - # This is to remove lint_off comments needed by the verilator warnings - # This function writes to the lint_off.txt here in the same folder def lint_off_edit(self, text): + ''' + This is to remove lint_off comments needed by the verilator warnings. + This function writes to the lint_off.txt in the library/tlv folder. + ''' init_path = '../../' if os.name == 'nt': init_path = '' @@ -332,14 +335,12 @@ class NgVeri(QtWidgets.QWidget): file = open(init_path + "library/tlv/lint_off.txt", 'w') for item in data: file.write(item) - return - - # else: - # return - # This is to add lint_off comments needed by the verilator warnings - # This function writes to the lint_off.txt here in the same folder def add_lint_off(self): + ''' + This is to add lint_off comments needed by the verilator warnings. + This function writes to the lint_off.txt in the library/tlv folder. + ''' init_path = '../../' if os.name == 'nt': init_path = '' -- cgit