summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfahim-oscad2016-04-25 14:18:48 +0530
committerfahim-oscad2016-04-25 14:18:48 +0530
commitbbc4735bafa85adc9d838fc6b8d5a06de735a13f (patch)
tree153e6613a68925943f2fea4e50419b9df1dcf014 /src
parenta815ce722770e1e8271f5a5987b3d1ad88ff61e0 (diff)
downloadeSim-bbc4735bafa85adc9d838fc6b8d5a06de735a13f.tar.gz
eSim-bbc4735bafa85adc9d838fc6b8d5a06de735a13f.tar.bz2
eSim-bbc4735bafa85adc9d838fc6b8d5a06de735a13f.zip
Subject: Major changes for mapping the parameters of Devices
Description: Now the parameters are written in Mapping.json and any new parameter and device can be eaily added and removed.
Diffstat (limited to 'src')
-rw-r--r--src/ngspicetoModelica/Mapping.json55
-rw-r--r--src/ngspicetoModelica/NgspicetoModelica.py95
2 files changed, 107 insertions, 43 deletions
diff --git a/src/ngspicetoModelica/Mapping.json b/src/ngspicetoModelica/Mapping.json
index 47743535..ce493eab 100644
--- a/src/ngspicetoModelica/Mapping.json
+++ b/src/ngspicetoModelica/Mapping.json
@@ -30,6 +30,53 @@
"R":"1e12"
}
+ },
+
+ "m":{
+ "import":"BondLib.Electrical.Analog.Spice",
+ "mapping":{
+ "tnom":"TNOM",
+ "vto":"VTO",
+ "gamma":"GAMMA",
+ "phi":"PHI",
+ "ld":"LD",
+ "uo":"U0",
+ "lambda":"LAMBDA",
+ "tox":"TOX",
+ "pb":"PB",
+ "cj":"CJ",
+ "cjsw":"CJSW",
+ "mj":"MJ",
+ "mjsw":"MJSW",
+ "cgdo":"CGDO",
+ "js":"JS",
+ "cgbo":"CGB0",
+ "cgso":"CGS0"
+
+
+ },
+ "default":{
+ "TNOM":"300",
+ "VTO":"0",
+ "GAMMA":"0",
+ "PHI":"0",
+ "LD":"0",
+ "U0":"0",
+ "LAMBDA":"0",
+ "TOX":"3e-9",
+ "PB":"0.8",
+ "CJ":"0",
+ "CJSW":"1e-9",
+ "MJ":"0.33",
+ "MJSW":"0.33",
+ "CGDO":"0",
+ "JS":"0",
+ "CGB0":"0",
+ "CGS0":"0"
+
+
+ }
+
},
"q":{
"import":"Analog.Semiconductors",
@@ -65,13 +112,11 @@
}
- },
+ },
"a" : "Analog.Semiconductors.Diode",
"b" : "Analog.Semiconductors.Diode",
- "M" :"BondLib.Electrical.Analog.Spice",
- "m" : "BondLib.Electrical.Analog.Spice",
- "Qs": "Analog.Semiconductors",
- "qs": "Analog.Semiconductors"
+ "M" :"BondLib.Electrical.Analog.Spice"
+
},
diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py
index 9985b8f0..93eac1f5 100644
--- a/src/ngspicetoModelica/NgspicetoModelica.py
+++ b/src/ngspicetoModelica/NgspicetoModelica.py
@@ -364,13 +364,13 @@ class NgMoConverter:
elif trans == 'pnp':
start = self.mappingData["Devices"][deviceName]["import"]+".PNP"
else:
- print "Transistor "+trans+" does not support"
+ print "Transistor "+trans+" Not found"
sys.exit(1)
stat = start+" "+words[0]+"("
tempstatList=[]
userDeviceParamList=[]
- refName = words[-1]
+ refName = words[4]
for key in modelInfo[refName]:
#If parameter is not mapped then it will just pass
try:
@@ -409,49 +409,75 @@ class NgMoConverter:
each = each.split('=')
mosInfo[words[0]][each[0]] = each[1]
trans = transInfo[words[5]]
- print "trans------------>",trans
+
if trans == 'nmos':
- start = 'BondLib.Electrical.Analog.Spice.Mn '
+ start = self.mappingData["Devices"][deviceName]["import"]+".Mn"
+ elif trans=='pmos' :
+ start = self.mappingData["Devices"][deviceName]["import"]+".Mp"
else:
- start = 'BondLib.Electrical.Analog.Spice.Mp '
- vto = self.tryExists(modelInfo,words,5,'vto',0)
- gam = self.tryExists(modelInfo,words,5,'gamma',0)
- phi = self.tryExists(modelInfo,words,5, 'phi', 0)
- ld = self.tryExists(modelInfo,words,5,'ld',0)
- uo = self.tryExists(modelInfo,words,5,'uo',0)
- lam = self.tryExists(modelInfo,words,5,'lambda',0)
- tox = self.tryExists(modelInfo,words,5,'tox',3e-9)
- pb = self.tryExists(modelInfo,words,5, 'pb',0.8)
- cj = self.tryExists(modelInfo,words,5, 'cj',0)
- cjsw = self.tryExists(modelInfo,words,5, 'cjsw',1e-9)
- mj = self.tryExists(modelInfo,words,5, 'mj',0.33)
- mjsw = self.tryExists(modelInfo,words,5, 'mjsw',0.33)
- cgdo = self.tryExists(modelInfo,words,5, 'cgdo',0)
- js = self.tryExists(modelInfo,words,5, 'js',0)
- cgbo = self.tryExists(modelInfo,words,5, 'cgbo',0)
- cgso = self.tryExists(modelInfo,words,5,'cgso',0)
+ print "MOSFET "+trans+" not found"
+ sys.exit(1)
+
+
+ stat = start+" "+words[0]+"("
+ tempstatList=[]
+ userDeviceParamList=[]
+ refName = words[5]
+
+ for key in modelInfo[refName]:
+ #If parameter is not mapped then it will just pass
+ try:
+ if key=="uo":
+ U0 = str(float(self.getUnitVal(modelInfo[refName][key]))*0.0001)
+ tempstatList.append("U0="+U0+" ")
+ userDeviceParamList.append(str("U0"))
+ else:
+ actualModelicaParam = self.mappingData["Devices"][deviceName]["mapping"][key]
+ tempstatList.append(actualModelicaParam+"="+self.getUnitVal(modelInfo[refName][key])+" ")
+ userDeviceParamList.append(str(actualModelicaParam))
+ except Exception as err:
+ print str(err)
+
+ #Running loop over default parameter of OpenModelica
+ for default in self.mappingData["Devices"][deviceName]["default"]:
+ if default in userDeviceParamList:
+ continue
+ else:
+ defaultValue = self.mappingData["Devices"][deviceName]["default"][default]
+ tempstatList.append(default+"="+self.getUnitVal(defaultValue)+" ")
+
+
+ #Adding LEVEL(This is constant not the device levele)
+ tempstatList.append("LEVEL=1"+" ")
+
try:
l = mosInfo[words[0]]['l']
+ tempstatList.append("L="+self.getUnitVal(l)+" ")
except KeyError:
- l = '1e-6'
+ tempstatList.append("L=1e-6"+" ")
try:
w = mosInfo[words[0]]['w']
+ tempstatList.append("W="+self.getUnitVal(w)+" ")
except KeyError:
- w = '100e-6'
+ tempstatList.append("W=100e-6"+" ")
try:
As = mosInfo[words[0]]['as']
ad = mosInfo[words[0]]['ad']
+ tempstatList.append("AS="+self.getUnitVal(As)+" ")
+ tempstatList.append("AD="+self.getUnitVal(ad)+" ")
except KeyError:
- As = '0'
- ad = '0'
+ tempstatList.append("AS=0"+" ")
+ tempstatList.append("AD=0"+" ")
try:
ps = mosInfo[words[0]]['ps']
pd = mosInfo[words[0]]['pd']
+ tempstatList.append("PS="+self.getUnitVal(ps)+" ")
+ tempstatList.append("PD="+self.getUnitVal(pd)+" ")
except KeyError:
- ps = '0'
- pd = '0'
- stat = start + words[0] + '(Tnom = 300, VT0 = ' + vto + ', GAMMA = ' + gam + ', PHI = ' + phi + ', LD = ' +ld+ ', U0 = ' + str(float(uo)*0.0001) + ', LAMBDA = ' + lam + ', TOX = ' +tox+ ', PB = ' + pb + ', CJ = ' +cj+ ', CJSW = ' +cjsw+ ', MJ = ' + mj + ', MJSW = ' + mjsw + ', CGD0 = ' +cgdo+ ', JS = ' +js+ ', CGB0 = ' +cgbo+ ', CGS0 = ' +cgso+ ', L = ' +l+ ', W = ' + w + ', Level = 1' + ', AD = ' + ad + ', AS = ' + As + ', PD = ' + pd + ', PS = ' + ps + ');'
- #stat = stat.translate(maketrans('{}', ' ')) #Not required
+ tempstatList.append("PS=0"+" ")
+ tempstatList.append("PD=0"+" ")
+
+ stat += ",".join(str(item) for item in tempstatList)+");"
modelicaCompInit.append(stat)
#Lets start for inbuilt model of ngspice
@@ -459,14 +485,12 @@ class NgMoConverter:
words=eachline.split()
userModelParamList = []
refName = words[-1]
- print "Reference Model Name------->",refName
actualModelName = self.inbuiltModelDict[refName]
- print "Actual Model Name------->",actualModelName
+
start = self.mappingData["Models"][actualModelName]["import"]
- print "Import Statement-------->",start
stat = start +" "+ words[0]+"("
tempstatList=[]
- print "Start of Stat-------->",stat
+
for key in modelInfo[refName]:
#If parameter is not mapped then it will just pass
try:
@@ -476,8 +500,6 @@ class NgMoConverter:
except:
pass
- print "User Model Parameter list---->",userModelParamList
-
#Running loop over default parameter of OpenModelica
for default in self.mappingData["Models"][actualModelName]["default"]:
if default in userModelParamList:
@@ -486,10 +508,7 @@ class NgMoConverter:
defaultValue = self.mappingData["Models"][actualModelName]["default"][default]
tempstatList.append(default+"="+self.getUnitVal(defaultValue)+" ")
- #print "My Stat------------>",stat
- #print "Temp Stat List--------->",tempstatList
stat += ",".join(str(item) for item in tempstatList)+");"
- print "End Stat---------->",stat
modelicaCompInit.append(stat)