- When
nghdlbutton clicked ineSimit calls thengspice_ghdl.pyfromnghdlinstalled directory
ngspice_ghdl.pydefines the UI for nghdl, and the functionality of each button- When
Uploadclicked, it callsuploadModelfunction fromngspice_ghdl.py - Similarly functions called on each button click defined
uploadModelinturn calls these 5 functions sequentially =>-
- createModelDirectory()
-
- addingModelInModpath()
-
- createModelFiles()
-
- runMake()
-
- runMakeInstall()
createModelDirectory()
- Create directory for the specified file name at
~/nghdl-simulator/src/xspice/icm/ghdl/ - The location where the directory is created in mentioned at
~/.nghdl/config.ini, this config file is inside a hidden folder.ngdhl, created when nghdl is installed - If a folder of the same name exists, it asks to overwrite, then removes earlier folder, and writes new one
addingModelInModpath()
- This adds the name of the new model created to
modpath.lstfile modpath.lstis located at~/nghdl-simulator/src/xspice/icm/ghdl, this should contain name of all the models that the folder has- Similarly you can look at
~/nghdl-simulator/src/xspice/icm/digitalwhich also contains amodpath.listfor all the models in that folder - This
modpath.lstis used in theGNUMakefileat~/nghdl-simulator/release/src/xspice/icm - This file used to keep a track of all components created
- If model already there it isn't added to the list
createModelFiles()
- Calls
model_generation.pyat the installed nghdl location undersrc/model_generation.py - Moves the generated
cfunc.modandifspec.ifsfiles to~/nghdl-simulator/src/xspice/icm/ghdl/modelName - Creates
DUTghdlfolder at~/nghdl-simulator/src/xspice/icm/ghdl/modelName - Move
compile.sh,uthash.sh,ghdlserver.c,ghdlserver.h,Utility_Package.vhdl,Vhpi_Package.vhdlto theDUTghdlfolder - Copy
modelName.vhdlfile from source location toDUTghdlfolder - Rum
compile.shwhich generates the object file forghdlserver.c - Give permission to
start_server.shandsock_pkg_create.shto execute chod a+x - Finally remove
compile.shandghdlserver.c
model_generation.py
- Creates the following files =>
-
connection_info.txt
-
cfunc.mod
-
ifspec.ifs
-
modelName_tb.vhdl=> testbench file for the model
-
start_server.sh
-
sock_pkg_create.sh
- The above files can be found either at
~/nghdl-simulator/src/xspice/icm/ghdl/modelNameorDUTghdlfolder inside it
runMake()
- Runs the
Makefileat~/nghdl-simulator/release - Executing by running
makecommand
runMakeInstall()
- Executes
make install - Finally calls
createSchematicLib()
createSchematicLib()
- Connects with
createKicadLibrary.pyfile at~/nghdl/src - Generates the
libfile for the model, to be used byKiCad - This is generated from a template stored at
Appconfig.py - The generated
libis stored at~/eSim_kicad.lib - Also creates
xmlfile for the model, which is stored at eSim undereSimLoc/src/modelParamXML/Nghdl
Finally all the relevant files are generated, now while executing ngspice, we need to make sure to run the ngspice, which is located at -
~/nghdl-simulator/install_dir/bin/ngspicethis has the binary for the ngspice,- And also the script at
~/nghdl-simulator/install_dir/share/ngspice/scripts/spinit=spinithas the linecodemodel ...mentioning acmfile to execute at runtime - This has mention of
ghdl.cmwhich makes sure that ourcfunc.cfile is executed at runtime - You can see the
ghdl.cmfile is located at~/nghdl-simulator/release/src/xspice/icm/ghdl - Also the
cfunc.cfiles, located at~/nghdl-simulator/release/src/xspice/icm/ghdl/modelName - These have mention of the
start_server.shfile atDUTghdl, hence server is started and values passed as well - Also you can look at
~/nghdl-simulator/release/src/xspice/icm/digitalit hasdigital.cmand the folders inside havecfunc.c - Also has
ifspec.cwhich defines the interface
- If you have ngspice currently installed remove it and genearate a softlink or command for the ngspice installed at -
~/nghdl-simulator/install_dir/bin/ngspice whereis ngspice, run this to get the location from wherengspiceis being executed currently
-
To generate softlink refer - Creating softlinki
-
Exeecute
ln -s ~/nghdl-simulator/install_dir/bin/ngspice /usr/bin/ngspice -
Note that all the paths mentioned here are specific to a Linux machine.
- Also the installation script doesn't install ghdl, you will have to do it manually, either through a
.debpackage or build it from source - Note that since we are using socket programming here, we require either the
llvmarchitecture orgcc. Usingmcodebackend won't work here
- To install ghdl from source, this Github issue might be helpful, the steps are -
-
sudo ./configure --with-llvm-config
-
- sudo make
-
- sudo make install
- Check this Github issue for those building from
.debpackage - To check current version and architecure of ghdl use -
-
ghdl --versioncommand, it should havellvmcode generator orgcc
- Also once ghdl is installed, to check syntax of your vhdl files use -
ghdl -s <vhdl file location>