Skip to content

Latest commit

 

History

History
102 lines (84 loc) · 5.42 KB

Workflow.md

File metadata and controls

102 lines (84 loc) · 5.42 KB
  1. When nghdl button clicked in eSim it calls the ngspice_ghdl.py from nghdl installed directory
  • ngspice_ghdl.py defines the UI for nghdl, and the functionality of each button
  • When Upload clicked, it calls uploadModel function from ngspice_ghdl.py
  • Similarly functions called on each button click defined
  • uploadModel inturn calls these 5 functions sequentially =>
    • createModelDirectory()
    • addingModelInModpath()
    • createModelFiles()
    • runMake()
    • runMakeInstall()
  1. 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
  1. addingModelInModpath()
  • This adds the name of the new model created to modpath.lst file
  • modpath.lst is 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/digital which also contains a modpath.list for all the models in that folder
  • This modpath.lst is used in the GNUMakefile at ~/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
  1. createModelFiles()
  • Calls model_generation.py at the installed nghdl location under src/model_generation.py
  • Moves the generated cfunc.mod and ifspec.ifs files to ~/nghdl-simulator/src/xspice/icm/ghdl/modelName
  • Creates DUTghdl folder at ~/nghdl-simulator/src/xspice/icm/ghdl/modelName
  • Move compile.sh, uthash.sh, ghdlserver.c, ghdlserver.h, Utility_Package.vhdl, Vhpi_Package.vhdl to the DUTghdl folder
  • Copy modelName.vhdl file from source location to DUTghdl folder
  • Rum compile.sh which generates the object file for ghdlserver.c
  • Give permission to start_server.sh and sock_pkg_create.sh to execute chod a+x
  • Finally remove compile.sh and ghdlserver.c
  1. 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/modelName or DUTghdl folder inside it
  1. runMake()
  • Runs the Makefile at ~/nghdl-simulator/release
  • Executing by running make command
  1. runMakeInstall()
  • Executes make install
  • Finally calls createSchematicLib()
  1. createSchematicLib()
  • Connects with createKicadLibrary.py file at ~/nghdl/src
  • Generates the lib file for the model, to be used by KiCad
  • This is generated from a template stored at Appconfig.py
  • The generated lib is stored at ~/eSim_kicad.lib
  • Also creates xml file for the model, which is stored at eSim under eSimLoc/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/ngspice this has the binary for the ngspice,
  • And also the script at ~/nghdl-simulator/install_dir/share/ngspice/scripts/spinit = spinit has the line codemodel ... mentioning a cm file to execute at runtime
  • This has mention of ghdl.cm which makes sure that our cfunc.c file is executed at runtime
  • You can see the ghdl.cm file is located at ~/nghdl-simulator/release/src/xspice/icm/ghdl
  • Also the cfunc.c files, located at ~/nghdl-simulator/release/src/xspice/icm/ghdl/modelName
  • These have mention of the start_server.sh file at DUTghdl, hence server is started and values passed as well
  • Also you can look at ~/nghdl-simulator/release/src/xspice/icm/digital it has digital.cm and the folders inside have cfunc.c
  • Also has ifspec.c which 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 where ngspice is 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 .deb package or build it from source
  • Note that since we are using socket programming here, we require either the llvm architecture or gcc. Using mcode backend 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 .deb package
  • To check current version and architecure of ghdl use -
    • ghdl --version command, it should have llvm code generator or gcc

  • Also once ghdl is installed, to check syntax of your vhdl files use - ghdl -s <vhdl file location>