diff options
-rwxr-xr-x | src/Appconfig.py | 12 | ||||
-rwxr-xr-x | src/createKicadLibrary.py | 8 | ||||
-rwxr-xr-x | src/model_generation.py | 45 | ||||
-rwxr-xr-x | src/ngspice_ghdl.py | 33 |
4 files changed, 53 insertions, 45 deletions
diff --git a/src/Appconfig.py b/src/Appconfig.py index 8cf63a2..d03dcc3 100755 --- a/src/Appconfig.py +++ b/src/Appconfig.py @@ -1,11 +1,15 @@ import os.path -from configparser import SafeConfigParser +from configparser import ConfigParser class Appconfig: - home = os.path.expanduser("~") + if os.name == 'nt': + home = os.path.join('library', 'config') + else: + home = os.path.expanduser('~') + # Reading all variables from eSim config.ini - parser_esim = SafeConfigParser() + parser_esim = ConfigParser() parser_esim.read(os.path.join(home, os.path.join('.esim', 'config.ini'))) try: src_home = parser_esim.get('eSim', 'eSim_HOME') @@ -16,7 +20,7 @@ class Appconfig: esimFlag = 0 # Reading all variables from nghdl config.ini - parser_nghdl = SafeConfigParser() + parser_nghdl = ConfigParser() parser_nghdl.read(os.path.join(home, os.path.join('.nghdl', 'config.ini'))) kicad_lib_template = { diff --git a/src/createKicadLibrary.py b/src/createKicadLibrary.py index 174668c..c78d41e 100755 --- a/src/createKicadLibrary.py +++ b/src/createKicadLibrary.py @@ -16,7 +16,7 @@ class AutoSchematic(QtWidgets.QWidget): self.lib_loc = Appconfig.lib_loc
if os.name == 'nt':
eSim_src = Appconfig.src_home
- inst_dir = eSim_src.replace('\eSim', '')
+ inst_dir = eSim_src.replace('\\eSim', '')
self.kicad_nghdl_lib = \
inst_dir + '/KiCad/share/kicad/library/eSim_Nghdl.lib'
else:
@@ -245,12 +245,14 @@ class AutoSchematic(QtWidgets.QWidget): class PortInfo:
def __init__(self, model):
self.modelname = model.modelname
- self.model_loc = model.parser.get('NGSPICE', 'DIGITAL_MODEL')
+ self.model_loc = os.path.join(
+ model.parser.get('NGHDL', 'DIGITAL_MODEL'), 'ghdl'
+ )
self.bit_list = []
self.input_len = 0
def getPortInfo(self):
- info_loc = os.path.join(self.model_loc, self.modelname+'/DUTghdl/')
+ info_loc = os.path.join(self.model_loc, self.modelname + '/DUTghdl/')
input_list = []
output_list = []
read_file = open(info_loc + 'connection_info.txt', 'r')
diff --git a/src/model_generation.py b/src/model_generation.py index ce05a7c..364c6ff 100755 --- a/src/model_generation.py +++ b/src/model_generation.py @@ -1,6 +1,6 @@ import re import os -from configparser import SafeConfigParser +from configparser import ConfigParser class ModelGeneration: @@ -11,12 +11,17 @@ class ModelGeneration: print("Arguement is : ", file) self.fname = os.path.basename(file) print("VHDL filename is : ", self.fname) - self.home = os.path.expanduser("~") - self.parser = SafeConfigParser() + + 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') @@ -157,8 +162,8 @@ class ModelGeneration: cfunc = open('cfunc.mod', 'w') print("Building content for cfunc.mod file") - comment = '''/* This is cfunc.mod file auto generated by gen_con_info.py - Developed by Fahim, Rahul at IIT Bombay */\n + comment = '''/* This is cfunc.mod file auto generated by \ + model_generation.py \nDeveloped by Fahim, Rahul at IIT Bombay */\n ''' header = ''' @@ -559,8 +564,9 @@ class ModelGeneration: cfunc.write("\t\tchar command[1024];\n") if os.name == 'nt': - self.digital_home = self.parser.get('NGSPICE', 'DIGITAL_MODEL') - self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME') + self.digital_home = self.parser.get('NGHDL', 'DIGITAL_MODEL') + self.digital_home = os.path.join(self.digital_home, "ghdl") + cmd_str2 = "/start_server.sh %d %s & read" + "\\" + "\"" + "\"" cmd_str1 = os.path.normpath( "\"" + self.digital_home + "/" + @@ -576,7 +582,7 @@ class ModelGeneration: else: cfunc.write( '\t\tsnprintf(command,1024,"' + self.home + - '/ngspice-nghdl/src/xspice/icm/ghdl/' + + '/nghdl-simulator/src/xspice/icm/ghdl/' + self.fname.split('.')[0] + '/DUTghdl/start_server.sh %d %s &", sock_port, my_ip);' ) @@ -715,16 +721,6 @@ class ModelGeneration: Vector: no no Vector_Bounds: - - Null_Allowed: yes yes - - PARAMETER_TABLE: - Parameter_Name: Sumanto - Description: "Sumanto" - Data_Type: real - Default_Value: 1.0e-9 - Limits: [1e-12 -] - Vector: no - Vector_Bounds: - - Null_Allowed: yes ''' static_table = ''' @@ -1064,14 +1060,15 @@ class ModelGeneration: def createServerScript(self): # ####### Creating and writing components in start_server.sh ####### # - self.digital_home = self.parser.get('NGSPICE', 'DIGITAL_MODEL') + self.digital_home = self.parser.get('NGHDL', 'DIGITAL_MODEL') + self.digital_home = os.path.join(self.digital_home, "ghdl") start_server = open('start_server.sh', 'w') start_server.write("#!/bin/bash\n\n") start_server.write( - "###This server run ghdl testebench for infinite time till " + - "ngspice send END signal to stop it\n\n" + "###This server run ghdl testbench for infinite time till " + + "Ngspice sends kill signal to stop it\n\n" ) if os.name == 'nt': @@ -1109,7 +1106,7 @@ class ModelGeneration: start_server.write( "gtkwave " + self.fname.split('.')[0] + - "_tb.vcd") + "_tb.vcd 2>/dev/null") start_server.close() diff --git a/src/ngspice_ghdl.py b/src/ngspice_ghdl.py index 329329f..6bc13ce 100755 --- a/src/ngspice_ghdl.py +++ b/src/ngspice_ghdl.py @@ -20,14 +20,18 @@ class Mainwindow(QtWidgets.QWidget): QtWidgets.QMainWindow.__init__(self) print("Initializing..........") - self.home = os.path.expanduser("~") + if os.name == 'nt': + self.home = os.path.join('library', 'config') + else: + self.home = os.path.expanduser('~') + # Reading all variables from config.ini 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') # Printing LICENCE file on terminal @@ -74,7 +78,7 @@ class Mainwindow(QtWidgets.QWidget): self.setLayout(grid) self.setGeometry(300, 300, 600, 600) - self.setWindowTitle("Ngspice Digital Model Creator") + self.setWindowTitle("Ngspice Digital Model Creator (from VHDL)") # self.setWindowIcon(QtGui.QIcon('logo.png')) self.show() @@ -121,7 +125,8 @@ class Mainwindow(QtWidgets.QWidget): def createModelDirectory(self): print("Create Model Directory Called") - self.digital_home = self.parser.get('NGSPICE', 'DIGITAL_MODEL') + self.digital_home = self.parser.get('NGHDL', 'DIGITAL_MODEL') + self.digital_home = os.path.join(self.digital_home, "ghdl") os.chdir(self.digital_home) print("Current Working Directory Changed to", os.getcwd()) self.modelname = os.path.basename(str(self.filename)).split('.')[0] @@ -226,12 +231,12 @@ class Mainwindow(QtWidgets.QWidget): os.chdir(path + "/DUTghdl") if os.name == 'nt': # path to msys bin directory where bash is located - self.msys_bin = self.parser.get('COMPILER', 'MSYS_HOME') - subprocess.call(self.msys_bin+"/bash.exe " + + self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME') + subprocess.call(self.msys_home + "/usr/bin/bash.exe " + path + "/DUTghdl/compile.sh", shell=True) - subprocess.call(self.msys_bin+"/bash.exe -c " + + subprocess.call(self.msys_home + "/usr/bin/bash.exe -c " + "'chmod a+x start_server.sh'", shell=True) - subprocess.call(self.msys_bin+"/bash.exe -c " + + subprocess.call(self.msys_home + "/usr/bin/bash.exe -c " + "'chmod a+x sock_pkg_create.sh'", shell=True) else: subprocess.call("bash " + path + "/DUTghdl/compile.sh", shell=True) @@ -254,15 +259,15 @@ class Mainwindow(QtWidgets.QWidget): def runMake(self): print("run Make Called") - self.release_home = self.parser.get('NGSPICE', 'RELEASE') + self.release_home = self.parser.get('NGHDL', 'RELEASE') path_icm = os.path.join(self.release_home, "src/xspice/icm") os.chdir(path_icm) try: if os.name == 'nt': # path to msys bin directory where make is located - self.msys_bin = self.parser.get('COMPILER', 'MSYS_HOME') - cmd = self.msys_bin+"\\make.exe" + self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME') + cmd = self.msys_home + "/mingw64/bin/mingw32-make.exe" else: cmd = " make" @@ -285,8 +290,8 @@ class Mainwindow(QtWidgets.QWidget): print("run Make Install Called") try: if os.name == 'nt': - self.msys_bin = self.parser.get('COMPILER', 'MSYS_HOME') - cmd = self.msys_bin+"\\make.exe install" + self.msys_home = self.parser.get('COMPILER', 'MSYS_HOME') + cmd = self.msys_home + "/mingw64/bin/mingw32-make.exe install" else: cmd = " make install" print("Running Make Install") |