summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xinstall-nghdl.sh200
-rw-r--r--ngspice-26.tar.gzbin7037364 -> 0 bytes
-rw-r--r--ngspice-nghdl.tar.gzbin0 -> 7019178 bytes
-rw-r--r--readme.md4
-rw-r--r--src/Appconfig.py35
-rw-r--r--src/createKicadLibrary.py229
-rw-r--r--src/model_generation.py4
-rwxr-xr-xsrc/ngspice_ghdl.py130
9 files changed, 455 insertions, 148 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0d20b64
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/install-nghdl.sh b/install-nghdl.sh
index af73fe8..ab0a1eb 100755
--- a/install-nghdl.sh
+++ b/install-nghdl.sh
@@ -17,10 +17,10 @@
# REVISION: ---
#===============================================================================
-ngspice="ngspice-26"
-src_loc=".esim-nghdl"
+ngspice="ngspice-nghdl"
+config_dir="$HOME/.nghdl"
config_file="config.ini"
-cur_dir=`pwd`
+src_dir=`pwd`
#Will be used to take backup of any file
sysdate="$(date)"
@@ -30,9 +30,17 @@ timestamp=`echo $sysdate|awk '{print $3"_"$2"_"$6"_"$4 }'`
#All functions goes here
function addghdlPPA
{
- echo "Adding ghdl PPA to install latest ghdl version"
- sudo add-apt-repository ppa:pgavin/ghdl
- sudo apt-get update
+ ghdlppa="pgavin/ghdl"
+ #Checking if ghdl ppa is already exist
+ grep -h "^deb.*$ghdlppa*" /etc/apt/sources.list.d/* > /dev/null 2>&1
+ if [ $? -ne 0 ]
+ then
+ echo "Adding ghdl PPA to install latest ghdl version"
+ sudo add-apt-repository -y ppa:pgavin/ghdl
+ sudo apt-get update
+ else
+ echo "ghdl is available in synaptic"
+ fi
}
function installDependency
@@ -45,6 +53,93 @@ function installDependency
sudo apt-get install -y bison
}
+
+function installNgspice
+{
+ echo "Installing ngspice..................................."
+ #Checking if ngspice-nghdl directory is already present in Home directory
+ if [ -d $HOME/$ngspice ];then
+ echo "$ngspice directory already exist"
+ echo "Leaving ngspice installation"
+
+
+ else
+
+ #Extracting Ngspice to Home Directory
+ tar -xzvf $ngspice.tar.gz -C $HOME
+
+ if [ "$?" == 0 ];then
+ echo "Ngspice extracted sucessfuly to $HOME "
+ #change to ngspice-nghdl directory
+ cd $HOME/$ngspice
+ #Make local install directory
+ mkdir -p install_dir
+ #Make release directory for build
+ mkdir -p release
+ #Change to release directory
+ cd release
+ echo "Installing Ngspice....."
+ echo "------------------------------------"
+ sleep 5
+ ../configure --enable-xspice --disable-debug --prefix=$HOME/$ngspice/install_dir/ --exec-prefix=$HOME/$ngspice/install_dir/
+ make
+ make install
+ if [ "$?" == 0 ];then
+ echo "Ngspice Installed sucessfully"
+ else
+ echo "There was some error in installing ngspice"
+ fi
+
+ else
+ echo "Unable to extract ngspice tar file"
+ exit 1;
+ fi
+
+ fi
+}
+
+function createConfigFile
+{
+ #Creating config.ini file and adding configuration information
+ #Check if config file is present
+ if [ -d $config_dir ];then
+ rm $config_dir/$config_file && touch $config_dir/$config_file
+ else
+ mkdir $config_dir && touch $config_dir/$config_file
+
+ fi
+
+ echo "[NGSPICE]" >> $config_dir/$config_file
+ echo "NGSPICE_HOME = $HOME/$ngspice" >> $config_dir/$config_file
+ echo "DIGITAL_MODEL = %(NGSPICE_HOME)s/src/xspice/icm/ghdl" >> $config_dir/$config_file
+ echo "RELEASE = %(NGSPICE_HOME)s/release" >> $config_dir/$config_file
+ echo "[SRC]" >> $config_dir/$config_file
+ echo "SRC_HOME = $src_dir" >> $config_dir/$config_file
+ echo "LICENSE = %(SRC_HOME)s/LICENSE" >> $config_dir/$config_file
+
+}
+
+function createSoftLink
+{
+
+ ## Creating softlink
+ cd /usr/local/bin
+ if [[ -L nghdl ]];then
+ echo "Symlink was already present"
+ sudo unlink nghdl
+ sudo ln -sf $src_dir/src/ngspice_ghdl.py nghdl
+
+ else
+ echo "Creating synmlink"
+ sudo ln -sf $src_dir/src/ngspice_ghdl.py nghdl
+ fi
+ cd $pwd
+
+}
+
+#####################################################################
+# Script start from here #
+#####################################################################
echo "Enter proxy details if you are connected to internet thorugh proxy"
echo -n "Is your internet connection behind proxy? (y/n): "
@@ -80,6 +175,13 @@ if [ $getProxy == "y" -o $getProxy == "Y" ];then
#Calling functions
addghdlPPA
installDependency
+ if [ $? -ne 0 ];then
+ echo -e "\n\n\nERROR: Unable to install required packages. Please check your internet connection.\n\n"
+ exit 0
+ fi
+ installNgspice
+ createConfigFile
+ createSoftLink
elif [ $getProxy == "n" -o $getProxy == "N" ];then
echo "Install without proxy"
@@ -87,11 +189,14 @@ elif [ $getProxy == "n" -o $getProxy == "N" ];then
#Calling functions
addghdlPPA
installDependency
-
if [ $? -ne 0 ];then
- echo -e "\n\n\nERROR: Unable to install required packages. Please check your internet connection.\n\n"
- exit 0
+ echo -e "\n\n\nERROR: Unable to install required packages. Please check your internet connection.\n\n"
+ exit 0
fi
+ installNgspice
+ createConfigFile
+ createSoftLink
+
else
echo "Please select the right option"
@@ -99,83 +204,6 @@ else
fi
-#Checking if ngspice-26 directory is already present in Home directory
-if [ -d $HOME/$ngspice ];then
- echo "$ngspice directory already exist taking its backup"
- mv $HOME/$ngspice $HOME/$ngspice.$timestamp
-fi
-
-
-#Extracting Ngspice to Home Directory
-tar -xzvf $ngspice.tar.gz -C $HOME
-
-if [ "$?" == 0 ];then
- echo "Ngspice extracted sucessfuly to $HOME "
- #change to ngspice-26 directory
- cd $HOME/$ngspice
- #Make local install directory
- mkdir -p install_dir
- #Make release directory for build
- mkdir -p release
- #Change to release directory
- cd release
- echo "Installing Ngspice....."
- echo "------------------------------------"
- sleep 5
- ../configure --enable-xspice --disable-debug --prefix=$HOME/$ngspice/install_dir/ --exec-prefix=$HOME/$ngspice/install_dir/
- make
- make install
- if [ "$?" == 0 ];then
- echo "Ngspice Installed sucessfully"
- else
- echo "There was some error in installing ngspice"
- fi
-
-else
- echo "Unable to extract ngspice tar file"
- exit 1;
-fi
-
-#Creating directory to put source
-if [ -d "$HOME/$src_loc" ];then
- echo "(.)esim-nghdl directory already in $HOME,removing it and copying new code"
- rm -rf ~/$src_loc
- mkdir -p ~/$src_loc
-else
- mkdir -p ~/$src_loc
-fi
-
-#Change to current directory
-cd $cur_dir
-cp -rv src/* ~/$src_loc/
-
-#Copying LICENSE file
-cp LICENSE ~/$src_loc/
-
-#Creating config.ini file and adding configuration information
-
-cd ~/$src_loc/
-touch $config_file
-
-echo "[NGSPICE]" >> $config_file
-echo "NGSPICE_HOME = $HOME/$ngspice" >> $config_file
-echo "DIGITAL_MODEL = %(NGSPICE_HOME)s/src/xspice/icm/ghdl" >> $config_file
-echo "RELEASE = %(NGSPICE_HOME)s/release" >> $config_file
-
-
-## Creating softlink
-cd /usr/local/bin
-if [[ -L nghdl ]];then
- echo "Symlink was already present"
- sudo unlink nghdl
- sudo ln -sf ~/$src_loc/ngspice_ghdl.py nghdl
-
-else
- echo "Creating synmlink"
- sudo ln -sf ~/$src_loc/ngspice_ghdl.py nghdl
-fi
-
-
diff --git a/ngspice-26.tar.gz b/ngspice-26.tar.gz
deleted file mode 100644
index 9803580..0000000
--- a/ngspice-26.tar.gz
+++ /dev/null
Binary files differ
diff --git a/ngspice-nghdl.tar.gz b/ngspice-nghdl.tar.gz
new file mode 100644
index 0000000..4996cdc
--- /dev/null
+++ b/ngspice-nghdl.tar.gz
Binary files differ
diff --git a/readme.md b/readme.md
index df4764d..f2e9a02 100644
--- a/readme.md
+++ b/readme.md
@@ -21,12 +21,12 @@ for that model it will actually call the ghdl to get the result.
1. Ubuntu 12.04 (You can try it on other version and let us know)
2. Python 2.7
3. PyQt4
-4. ghdl
+
##How to install?
1. Clone this repository.
2. Run `./install-nghdl.sh` It will install ngspice from source code and put it in $HOME.
-
+3. Set ngspice path in `.bashrc` file. Add `export PATH=/home/{your-username}/ngspice-26/install_dir/bin:$PATH` line in .bashrc
##Few words about installed code structure.
1. Ngspice will be installed in home directory $HOME. If you already have ngspice-26 directory there it will take its backup.
diff --git a/src/Appconfig.py b/src/Appconfig.py
index 51bd7c1..6909c53 100644
--- a/src/Appconfig.py
+++ b/src/Appconfig.py
@@ -1,2 +1,35 @@
+import os.path
+from ConfigParser import SafeConfigParser
+
+
+class Appconfig:
+ home = os.path.expanduser("~")
+ #Reading all varibale from eSim config.ini
+ parser_esim = SafeConfigParser()
+ parser_esim.read(os.path.join(home, os.path.join('.esim','config.ini')))
+ try:
+ src_home = parser_esim.get('eSim','eSim_HOME')
+ xml_loc = os.path.join(src_home,'src/modelParamXML')
+ lib_loc = os.path.expanduser('~')
+ except:
+ pass
+ esimFlag = 0
+
+ #Reading all variable from nghdl config.ini
+ parser_nghdl = SafeConfigParser()
+ parser_nghdl.read(os.path.join(home,os.path.join('.nghdl','config.ini')))
+
+ kicad_lib_template = {
+ "start_def":"DEF comp_name U 0 40 Y Y 1 F N",
+ "U_field":"F0 \"U\" 2850 1800 60 H V C CNN",
+ "comp_name_field":"F1 \"comp_name\" 2850 2000 60 H V C CNN",
+ "blank_field":["F2 blank_quotes 2850 1950 60 H V C CNN","F3 blank_quotes 2850 1950 60 H V C CNN"],
+ "start_draw":"DRAW",
+ "draw_pos":"S 2550 2100 3150 1800 0 1 0 N",
+ "input_port":"X in 1 2350 2000 200 R 50 50 1 1 I",
+ "output_port":"X out 2 3350 2000 200 L 50 50 1 1 O",
+ "end_draw":"ENDDRAW",
+ "end_def":"ENDDEF"
+ }
+
-nghdl_src_loc = ".esim-nghdl"
diff --git a/src/createKicadLibrary.py b/src/createKicadLibrary.py
new file mode 100644
index 0000000..bf520d1
--- /dev/null
+++ b/src/createKicadLibrary.py
@@ -0,0 +1,229 @@
+from Appconfig import Appconfig
+import re
+import os
+import xml.etree.cElementTree as ET
+from PyQt4 import QtGui, QtCore
+
+
+class AutoSchematic(QtGui.QWidget):
+
+ def __init__(self, modelname):
+ QtGui.QWidget.__init__(self)
+ self.modelname = modelname.split('.')[0]
+ self.template = Appconfig.kicad_lib_template
+ self.xml_loc = Appconfig.xml_loc
+ self.lib_loc = Appconfig.lib_loc
+ self.kicad_nghdl_lib = 'eSim_kicad.lib'
+ self.parser = Appconfig.parser_nghdl
+
+ def createKicadLibrary(self):
+ xmlFound = None
+ for root, dirs, files in os.walk(self.xml_loc):
+ if (str(self.modelname) + '.xml') in files:
+ xmlFound = root
+ if (xmlFound == None):
+ self.getPortInformation()
+ self.createXML()
+ self.createLib()
+ elif (xmlFound == self.xml_loc + 'Nghdl'):
+ print 'Library already exists...'
+ ret = QtGui.QMessageBox.critical(self, "Critical",'''<b>The Libraries of this model already exist.Do you want to overwrite it?</b><br/>
+ <b>If yes press ok else cancel it and change the name of your vhdl file</b>''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel)
+ if ret == QtGui.QMessageBox.Ok:
+ print "Overwriting existing libraries"
+ self.getPortInformation()
+ self.createXML()
+ self.removeOldLibrary() #Removes the exisitng library
+ self.createLib()
+ else:
+ print "Exiting Nghdl"
+ quit()
+ else:
+ print 'Pre existing library...'
+ ret = QtGui.QMessageBox.critical(self, "Error",'''<b>A standard library already exists in this name.</b><br/>
+ <b>Please change the name of your vhdl file and upload it again</b>''', QtGui.QMessageBox.Ok)
+
+ quit()
+
+ def getPortInformation(self):
+ portInformation = PortInfo(self)
+ portInformation.getPortInfo()
+ self.portInfo = portInformation.bit_list
+ self.input_length = portInformation.input_len
+
+ def createXML(self):
+ cwd = os.getcwd()
+ xmlDestination = os.path.join(self.xml_loc, 'Nghdl')
+ self.splitText = ""
+ for bit in self.portInfo[:-1]:
+ self.splitText += bit + "-V:"
+ self.splitText += self.portInfo[-1] + "-V"
+
+ print "changing directory to ", (xmlDestination)
+ os.chdir(xmlDestination)
+
+ root = ET.Element("model")
+ ET.SubElement(root, "name").text = self.modelname
+ ET.SubElement(root, "type").text = "Nghdl"
+ ET.SubElement(root, "node_number").text = str(len(self.portInfo))
+ ET.SubElement(root, "title").text = "Add parameters for " + str(self.modelname)
+ ET.SubElement(root, "split").text = self.splitText
+ param = ET.SubElement(root, "param")
+ ET.SubElement(param, "rise_delay", default = "1.0e-9").text = "Enter Rise Delay (default=1.0e-9)"
+ ET.SubElement(param ,"fall_delay", default ="1.0e-9").text = "Enter Fall Delay (default=1.0e-9)"
+ ET.SubElement(param ,"input_load", default ="1.0e-12").text = "Enter Input Load (default=1.0e-12)"
+ ET.SubElement(param ,"instance_id", default ="1").text = "Enter Instance ID (Between 0-99)"
+ ET.SubElement(param ,"stop_time", default ="90e-9").text = "Enter the stop time to end the simulation (default=90e-9)"
+ tree = ET.ElementTree(root)
+ tree.write(str(self.modelname) + '.xml')
+ print "Leaving the directory ", (xmlDestination)
+ os.chdir(cwd)
+
+ #Calculates the maximum between input and output ports
+ def findBlockSize(self):
+ ind = self.input_length
+ return max(self.char_sum(self.portInfo[:ind]), self.char_sum(self.portInfo[ind:]))
+
+ def char_sum(self, ls):
+ return sum([int(x) for x in ls])
+
+ def removeOldLibrary(self):
+ cwd = os.getcwd()
+ os.chdir(self.lib_loc)
+ print "Changing directory to ", self.lib_loc
+ f = open(self.kicad_nghdl_lib)
+ lines = f.readlines()
+ f.close()
+
+ output = []
+ line_reading_flag = False
+
+ for line in lines:
+ if line.startswith("DEF"):
+ if line.split()[1] == self.modelname:
+ line_reading_flag = True
+ if not line_reading_flag:
+ output.append(line)
+ if line.startswith("ENDDEF"):
+ line_reading_flag = False
+
+ f = open(self.kicad_nghdl_lib, 'w')
+ for line in output:
+ f.write(line)
+
+ os.chdir(cwd)
+ print "Leaving directory, ", self.lib_loc
+
+ def createLib(self):
+ self.dist_port = 100 #distance between two ports
+ self.inc_size = 100 #Increment size of a block
+ cwd = os.getcwd()
+ os.chdir(self.lib_loc)
+ print "Changing directory to ", self.lib_loc
+
+ lib_file = open(self.kicad_nghdl_lib,"a")
+ line1 = self.template["start_def"]
+ line1 = line1.split()
+ line1 = [w.replace('comp_name', self.modelname) for w in line1]
+ self.template["start_def"] = ' '.join(line1)
+ if os.stat(self.kicad_nghdl_lib).st_size == 0:
+ lib_file.write("EESchema-LIBRARY Version 2.3"+ "\n\n")
+ #lib_file.write("#encoding utf-8"+ "\n"+ "#"+ "\n" + "#test_compo" + "\n"+ "#"+ "\n")
+ lib_file.write(self.template["start_def"]+ "\n"+self.template["U_field"]+"\n")
+
+ line3 = self.template["comp_name_field"]
+ line3 = line3.split()
+ line3 = [w.replace('comp_name', self.modelname) for w in line3]
+ self.template["comp_name_field"] = ' '.join(line3)
+
+ lib_file.write(self.template["comp_name_field"]+ "\n")
+
+ line4 = self.template["blank_field"]
+ line4_1 = line4[0]
+ line4_2 = line4[1]
+ line4_1 = line4_1.split()
+ line4_1 = [w.replace('blank_quotes','""') for w in line4_1]
+ line4_2 = line4_2.split()
+ line4_2 = [w.replace('blank_quotes','""') for w in line4_2]
+ line4[0] = ' '.join(line4_1)
+ line4[1] = ' '.join(line4_2)
+ self.template["blank_qoutes"] = line4
+
+ lib_file.write(line4[0]+"\n" + line4[1]+"\n"+ self.template["start_draw"]+ "\n")
+
+ draw_pos = self.template["draw_pos"]
+ draw_pos = draw_pos.split()
+ draw_pos[4] = str(int(draw_pos[4])- self.findBlockSize() * self.inc_size)
+ self.template["draw_pos"] = ' '.join(draw_pos)
+
+ lib_file.write(self.template["draw_pos"]+"\n")
+
+ input_port = self.template["input_port"]
+ input_port = input_port.split()
+ output_port = self.template["output_port"]
+ output_port = output_port.split()
+ inputs = self.portInfo[0: self.input_length]
+ outputs = self.portInfo[self.input_length:]
+ inputs = self.char_sum(inputs)
+ outputs= self.char_sum(outputs)
+ total = inputs+outputs
+
+ port_list = []
+
+ for i in xrange(total):
+ if (i < inputs):
+ input_port[1] = "in"+str(i+1)
+ input_port[2] = str(i+1)
+ input_port[4] = str(int(input_port[4])-self.dist_port)
+ input_list = ' '.join(input_port)
+ port_list.append(input_list)
+
+ else:
+ output_port[1] = "out"+str(i- inputs+1)
+ output_port[2] = str(i+1)
+ output_port[4] = str(int(output_port[4])-self.dist_port)
+ output_list = ' '.join(output_port)
+ port_list.append(output_list)
+
+ for ports in port_list:
+ lib_file.write(ports+"\n")
+ lib_file.write(self.template["end_draw"]+"\n"+ self.template["end_def"] + "\n\n\n")
+
+ os.chdir(cwd)
+ print 'Leaving directory, ', self.lib_loc
+ QtGui.QMessageBox.information(self, "Library added", '''Library details for this model is added to the <b>eSim-kicad.lib</b> in the home directory''', QtGui.QMessageBox.Ok)
+
+
+class PortInfo:
+ def __init__(self, model):
+ self.modelname = model.modelname
+ self.model_loc = model.parser.get('NGSPICE', 'DIGITAL_MODEL')
+ self.bit_list = []
+ self.input_len = 0
+
+ def getPortInfo(self):
+ info_loc = os.path.join(self.model_loc, self.modelname+'/DUTghdl/')
+ input_list = []
+ output_list = []
+ read_file=open(info_loc + 'connection_info.txt','r')
+ data=read_file.readlines()
+ read_file.close()
+
+ for line in data:
+ if re.match(r'^\s*$', line):
+ pass
+ else:
+ in_items=re.findall("IN",line,re.MULTILINE|re.IGNORECASE)
+ out_items=re.findall("OUT",line,re.MULTILINE|re.IGNORECASE)
+ if in_items:
+ input_list.append(line.split())
+ if out_items:
+ output_list.append(line.split())
+
+ for in_list in input_list:
+ self.bit_list.append(in_list[2])
+ self.input_len = len(self.bit_list)
+ for out_list in output_list:
+ self.bit_list.append(out_list[2])
+
+
diff --git a/src/model_generation.py b/src/model_generation.py
index c520708..4f2d7dd 100644
--- a/src/model_generation.py
+++ b/src/model_generation.py
@@ -464,7 +464,7 @@ for item in cm_event_get_ptr:
cfunc.write(systime_info)
cfunc.write("\n")
cfunc.write("\t\tchar command[1024];")
-cfunc.write('\t\tsnprintf(command,1024,"'+home+'/ngspice-26/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/start_server.sh %d &",sock_port);\n')
+cfunc.write('\t\tsnprintf(command,1024,"'+home+'/ngspice-nghdl/src/xspice/icm/ghdl/'+fname.split('.')[0]+'/DUTghdl/start_server.sh %d &",sock_port);\n')
cfunc.write('\t\tsystem(command);')
cfunc.write("\t}")
cfunc.write("\n")
@@ -767,7 +767,7 @@ start_server.write("###This server run ghdl testebench for infinite time till ng
start_server.write("#gcc -c ghdlserver.c\n")
start_server.write("#ghdl -a Utility_Package.vhdl &&\n")
start_server.write("#ghdl -a Vhpi_Package.vhdl &&\n")
-start_server.write("cd "+home+"/ngspice-26/src/xspice/icm/ghdl/"+fname.split('.')[0]+"/DUTghdl/\n")
+start_server.write("cd "+home+"/ngspice-nghdl/src/xspice/icm/ghdl/"+fname.split('.')[0]+"/DUTghdl/\n")
start_server.write("chmod 775 sock_pkg_create.sh &&\n")
start_server.write("./sock_pkg_create.sh $1 &&\n")
start_server.write("ghdl -a sock_pkg.vhdl &&\n")
diff --git a/src/ngspice_ghdl.py b/src/ngspice_ghdl.py
index 3f4990b..0a9e88c 100755
--- a/src/ngspice_ghdl.py
+++ b/src/ngspice_ghdl.py
@@ -12,7 +12,8 @@ import subprocess
from PyQt4 import QtGui
from PyQt4 import QtCore
from ConfigParser import SafeConfigParser
-from Appconfig import nghdl_src_loc
+from Appconfig import Appconfig
+from createKicadLibrary import AutoSchematic
class Mainwindow(QtGui.QWidget):
def __init__(self):
@@ -20,11 +21,16 @@ class Mainwindow(QtGui.QWidget):
QtGui.QMainWindow.__init__(self)
print "Initializing.........."
self.home = os.path.expanduser("~")
- licensefile = os.path.join(os.path.join(self.home,nghdl_src_loc), "LICENSE")
- fileopen = open(licensefile, 'r')
- print fileopen.read()
+ #Reading all varibale from config.ini
self.parser = SafeConfigParser()
- self.parser.read(os.path.join(self.home,nghdl_src_loc+'/config.ini'))
+ 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.src_home = self.parser.get('SRC','SRC_HOME')
+ self.licensefile = self.parser.get('SRC','LICENSE')
+ #Printing LICENCE file on terminal
+ fileopen = open(self.licensefile, 'r')
+ print fileopen.read()
self.file_list = [] #to keep the supporting files
self.initUI()
@@ -42,9 +48,13 @@ class Mainwindow(QtGui.QWidget):
self.ledit = QtGui.QLineEdit(self)
self.sedit = QtGui.QTextEdit(self)
self.process = QtCore.QProcess(self)
- self.terminal = QtGui.QWidget(self)
-
- self.process.start('xterm',['-into', str(self.terminal.winId())])
+ self.termedit = QtGui.QTextEdit(self)
+ self.termedit.setReadOnly(1)
+ pal = QtGui.QPalette()
+ bgc = QtGui.QColor(0, 0, 0)
+ pal.setColor(QtGui.QPalette.Base, bgc)
+ self.termedit.setPalette(pal)
+ self.termedit.setStyleSheet("QTextEdit {color:white}")
#Creating gridlayout
grid = QtGui.QGridLayout()
@@ -54,7 +64,7 @@ class Mainwindow(QtGui.QWidget):
grid.addWidget(self.sedit, 2, 0, 4, 1)
grid.addWidget(self.addbtn, 2, 1)
grid.addWidget(self.removebtn, 3, 1)
- grid.addWidget(self.terminal, 6, 0,10,1)
+ grid.addWidget(self.termedit, 6, 0, 10, 1)
grid.addWidget(self.uploadbtn, 17, 0)
grid.addWidget(self.exitbtn,17, 1)
@@ -77,16 +87,16 @@ class Mainwindow(QtGui.QWidget):
def browseFile(self):
print "Browse button clicked"
self.filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '.')
- print "Path file :", self.filename
self.ledit.setText(self.filename)
+ print "Vhdl file uploaded to process :", self.filename
def addFiles(self):
- print "Add Files button clicked"
+ print "Starts adding supporting files"
title = self.addbtn.text()
for file in QtGui.QFileDialog.getOpenFileNames(self, title):
- print "Supporting file :", file
self.sedit.append(str(file))
self.file_list.append(file)
+ print "Supporting Files are :",self.file_list
def removeFiles(self):
@@ -103,24 +113,23 @@ class Mainwindow(QtGui.QWidget):
self.file_list.remove(file)
if nonvhdl_count > 0:
- QtGui.QMessageBox.about(self,'Message','''<b>Important Message.</b><br/><br/>This accepts only <b>.vhdl</b> file ''')
+ QtGui.QMessageBox.about(self,'Message','''<b>Important Message.</b><br/><br/>Supporting files should be <b>.vhdl</b> file ''')
def createModelDirectory(self):
print "Create Model Directory Called"
self.digital_home=self.parser.get('NGSPICE','DIGITAL_MODEL')
- print "Digital Home",self.digital_home
os.chdir(self.digital_home)
print "Current Working Directory Changed to",os.getcwd()
self.modelname = os.path.basename(str(self.filename)).split('.')[0]
- print "Model name is :",self.modelname
+ print "Model to be created :",self.modelname
# Looking if model directory is present or not
if os.path.isdir(self.modelname):
print "Model Already present"
ret = QtGui.QMessageBox.critical(self, "Critical",'''<b>The Model already exist.Do you want to overwrite it?</b><br/>
<b>If yes press ok else cancel it and change the name of you vhdl file</b>''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel)
if ret == QtGui.QMessageBox.Ok:
- print "Overwriting existing model"
+ print "Overwriting existing model "+self.modelname
cmd="rm -rf "+self.modelname
#process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
subprocess.call(cmd, shell=True)
@@ -132,25 +141,25 @@ class Mainwindow(QtGui.QWidget):
else:
- print "Creating new model directory"
+ print "Creating model "+self.modelname+" directory"
os.mkdir(self.modelname)
def addingModelInModpath(self):
- print "Adding Model in Modpath file",self.modelname,self.digital_home
+ print "Adding Model "+self.modelname+" in Modpath file "+self.digital_home
#Adding name of model in the modpath file
#Check if the string is already in the file
with open(self.digital_home+"/modpath.lst",'a+') as f:
flag = 0
for line in f:
if line.strip() == self.modelname:
- print "Found model"
+ print "Found model "+self.modelname+" in the modpath.lst"
flag = 1
break
else:
pass
if flag == 0:
- print "Adding model name into modpath.lst"
+ print "Adding model name "+self.modelname+" into modpath.lst"
f.write(self.modelname+"\n")
else:
print "Model name is already into modpath.lst"
@@ -159,29 +168,31 @@ class Mainwindow(QtGui.QWidget):
def createModelFiles(self):
print "Create Model Files Called"
os.chdir(self.cur_dir)
- print "Current Working directory changed to ",self.cur_dir
- cmd = "python ~/"+nghdl_src_loc+"/model_generation.py "+str(self.ledit.text())
+ print "Current Working directory changed to "+self.cur_dir
+ cmd = "python "+self.src_home+"/src/model_generation.py "+str(self.ledit.text())
stdouterr = os.popen4(cmd)[1].read()
print stdouterr
#Moving file to model directory
- path=self.digital_home+"/"+self.modelname
+ path=os.path.join(self.digital_home,self.modelname)
shutil.move("cfunc.mod",path)
shutil.move("ifspec.ifs",path)
#Creating directory inside model directoy
+ print "Creating DUT directory at "+os.path.join(path,"DUTghdl")
os.mkdir(path+"/DUTghdl/")
+ print "Copying required file to DUTghdl directory"
shutil.move("connection_info.txt",path+"/DUTghdl/")
shutil.move("start_server.sh",path+"/DUTghdl/")
shutil.move("sock_pkg_create.sh",path+"/DUTghdl/")
shutil.move(self.modelname+"_tb.vhdl",path+"/DUTghdl/")
shutil.copy(str(self.filename),path+"/DUTghdl/")
- shutil.copy(os.path.join(self.home,nghdl_src_loc)+"/ghdlserver/compile.sh",path+"/DUTghdl/")
- shutil.copy(os.path.join(self.home,nghdl_src_loc)+"/ghdlserver/uthash.h",path+"/DUTghdl/")
- shutil.copy(os.path.join(self.home,nghdl_src_loc)+"/ghdlserver/ghdlserver.c",path+"/DUTghdl/")
- shutil.copy(os.path.join(self.home,nghdl_src_loc)+"/ghdlserver/ghdlserver.h",path+"/DUTghdl/")
- shutil.copy(os.path.join(self.home,nghdl_src_loc)+"/ghdlserver/Utility_Package.vhdl",path+"/DUTghdl/")
- shutil.copy(os.path.join(self.home,nghdl_src_loc)+"/ghdlserver/Vhpi_Package.vhdl",path+"/DUTghdl/")
+ shutil.copy(os.path.join(self.home, self.src_home)+"/src/ghdlserver/compile.sh",path+"/DUTghdl/")
+ shutil.copy(os.path.join(self.home, self.src_home)+"/src/ghdlserver/uthash.h",path+"/DUTghdl/")
+ shutil.copy(os.path.join(self.home, self.src_home)+"/src/ghdlserver/ghdlserver.c",path+"/DUTghdl/")
+ shutil.copy(os.path.join(self.home, self.src_home)+"/src/ghdlserver/ghdlserver.h",path+"/DUTghdl/")
+ shutil.copy(os.path.join(self.home, self.src_home)+"/src/ghdlserver/Utility_Package.vhdl",path+"/DUTghdl/")
+ shutil.copy(os.path.join(self.home, self.src_home)+"/src/ghdlserver/Vhpi_Package.vhdl",path+"/DUTghdl/")
for file in self.file_list:
shutil.copy(str(file), path+"/DUTghdl/")
@@ -196,30 +207,26 @@ class Mainwindow(QtGui.QWidget):
#os.remove("Utility_Package.vhdl")
#os.remove("Vhpi_Package.vhdl")
-
-
-
+
+ #slot to redirect stdout to window console
+ @QtCore.pyqtSlot()
+ def readStdOutput(self):
+ self.termedit.append(QtCore.QString(self.process.readAllStandardOutput()))
-
def runMake(self):
print "run Make Called"
self.release_home=self.parser.get('NGSPICE','RELEASE')
os.chdir(self.release_home)
try:
cmd = " make"
- print "Running Make"
+ print "Running Make command in "+self.release_home
path = os.getcwd()
- #subprocess.call(cmd,shell=True)
- command = "cd "+path +";"+cmd +";"+"make install"
- #command = "cd "+path +";"+cmd
- self.args = ['-into', str(self.terminal.winId()),'-hold','+s','-e', command]
- self.process.start('xterm', self.args)
-
- print "pid ------ >",self.process.pid()
+ self.process.start(cmd)
+ self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
+ QtCore.QObject.connect(self.process, QtCore.SIGNAL("readyReadStandardOutput()"), self, QtCore.SLOT("readStdOutput()"))
+ print "make command process pid ---------- >",self.process.pid()
- #stdouterr = os.popen4(cmd)[1].read()
- #self.tedit.append(stdouterr)
except:
print "There is error in 'make' "
quit()
@@ -230,19 +237,26 @@ class Mainwindow(QtGui.QWidget):
cmd = " make install"
print "Running Make Install"
path = os.getcwd()
- print "cwd------------>", path
- #subprocess.call(cmd,shell=True)
- command = "cd "+path+ ";"+cmd
- self.args = ['-into', str(self.terminal.winId()),'-hold','-e', command]
- #self.process.start('xterm', self.args)
- #self.process.waitForFinished(-1)
- #stdouterr = os.popen4(cmd)[1].read()
- #self.tedit.append(stdouterr)
+ try:
+ self.process.close()
+ except:
+ pass
+ self.process.finished.connect(self.createSchematicLib)
+ self.process.start(cmd)
+ self.process.setProcessChannelMode(QtCore.QProcess.MergedChannels)
+ QtCore.QObject.connect(self.process, QtCore.SIGNAL("readyReadStandardOutput()"), self, QtCore.SLOT("readStdOutput()"))
+ os.chdir(self.cur_dir)
+
except:
print "There is error during in 'make install' "
quit()
-
+ def createSchematicLib(self):
+ if Appconfig.esimFlag == 1:
+ print 'Creating library files.................................'
+ self.schematicLib = AutoSchematic(self.modelname)
+ self.schematicLib.createKicadLibrary()
+
def uploadModle(self):
print "Upload button clicked"
try:
@@ -251,17 +265,16 @@ class Mainwindow(QtGui.QWidget):
pass
try:
self.file_extension = os.path.splitext(str(self.filename))[1]
- print "File extension",self.file_extension
- print "Parser Content:",self.parser.get('NGSPICE', 'NGSPICE_HOME')
+ print "Uploaded File extension :"+self.file_extension
self.cur_dir = os.getcwd()
- print "My Current Working Directory",self.cur_dir
+ print "Current Working Directory :"+self.cur_dir
self.checkSupportFiles()
if self.file_extension == ".vhdl":
self.createModelDirectory()
self.addingModelInModpath()
self.createModelFiles()
self.runMake()
- #self.runMakeInstall()
+ self.runMakeInstall()
else:
QtGui.QMessageBox.about(self,'Message','''<b>Important Message.</b><br/><br/>This accepts only <b>.vhdl</b> file ''')
except:
@@ -327,7 +340,7 @@ class FileRemover(QtGui.QWidget):
def removeFiles(self):
for path in self.marked_list:
- print path, "is removed"
+ print path +" is removed"
self.sedit.append(path + " removed")
self.files.remove(path)
@@ -343,6 +356,9 @@ class FileRemover(QtGui.QWidget):
def main():
app = QtGui.QApplication(sys.argv)
+ if len(sys.argv) > 1:
+ if sys.argv[1] == '-e':
+ Appconfig.esimFlag = 1
w = Mainwindow()
sys.exit(app.exec_())