Package: playhdl
playhdlYou can think aboutplayhdlasEdaPlayground, but which is CLI-based and uses simulators on your local machine.It gives you ability to simulate tiny snippets of HDL code in several commands without any headache related to vast tool guides, command-line arguments and etc.:playhdlinitsv
playhdlrunmodelsimFeaturesplayhdlis written in pure Python without any external dependencies, so it is easy to use it in any environment (laptop, server, etc.), where Python 3.8+ is available.It supports various project types (HDL languages + libraries) and many simulators:verilogsvsv_uvm12vhdlmodelsim:heavy_check_mark::heavy_check_mark:xcelium:heavy_check_mark::heavy_check_mark:verilator:heavy_check_mark::heavy_check_mark:icarus:heavy_check_mark::heavy_check_mark:vcs:heavy_check_mark::heavy_check_mark::heavy_check_mark:vivado:heavy_check_mark::heavy_check_mark::heavy_check_mark:Quick startInstall the latest stable release (Python 3.8+ is required):python-mpipinstall-UplayhdlSetup settings file$HOME/.playhdl/settings.jsonwith a list of all automatically-discoverd simulators. Edit file manually to add undiscovered ones. This have to be done only once.playhdlsetupInitialize project fileplayhdl.jsonand template testbench in the current directory. Project file contains specific commands to be executed for compilation and simulation processes. Edit it manually to tweak tool arguments if required.playhdlinitsv# this will create ready-to-simulate tb.svRun simulation in one of the supported simulators for this project (language):playhdlrunicarus# to open waves after simulationplayhdlrunicarus--wavesTool command guideTo get general help and command list:playhdl-hTo get help about specific commandplayhdl<command>-hsetupcommandSettings of the tool are stored in the JSON file under$HOME/.playhdldirectory.To create$HOME/.playhdl/settings.jsonrunplayhdlsetupIt will try to find all supported simulators and fill the json. If you have multiple versions of simulators or some of them were not found, add them manually to your settings file.Settings file structure:{"tools":{"<tool_uid>":{"kind":"<tool_kind>","bin_dir":"<path_to_bin>","env":{},"extras":{}}}}All tools settings are located in a dictionary under"tools"key.Every tool has it is owntool_uid, which is just a string with any unique name, e.g."modelsim","verilator5","my_secret_simulator".Valid"kind"must be provided:"modelsim""xcelium""verilator""icarus""vcs""vivado"Other fields:"bin_dir"- a string with a path to a directory with executable files"env"- a dictionary with additional enviroment variables (keys and values are strings)"extras"- a dictionary with extra values for a specific simulator kindExtras for"vcs"kind:"gui"-"verdi"or"dve"select default GUI for VCSinitcommandThis command creates JSON project fileplayhdl.jsonand HDL testbench in the current directory.playhdlinit<mode>Where<mode>is one of the supported project modes:verilog- Verilog-2001sv- SystemVerilog-2017sv_uvm12- SystemVerilog-2017 + UVM 1.2vhdl- VHDL-93Project file is filled with scripts for all suitable simulators for the selected mode. It's internal structure:{"tools":{"<tool_uid>":{"build":["<cmd0>","<cmd1>","<cmd2>"],"sim":["<cmd>"],"waves":["<cmd>"]}}}There are three categories of commands:"build"- commands needed to compile and elaborate sources"sim"- commands needed to run simulation"waves"- commands needed to open waves for analysisAny command can be customized for specific needs.runcommandThis command runs CLI-mode simulation in a specific simulator according to project fileplayhdlrun<tool_uid>Argument--wavescan be added to open waves for analysis after simulation endsplayhdlrun<tool_uid>--wavesinfocommandThis command just prints some useful information:all tools specified in your settings filecurrent compatibility table between project mode and simulatorplayhdlinfoDeveloper guideInstallpoetrypython-mpipinstall-UpoetrySetup virtual environmentmakesetup-devYou can specify Python version to usemakesetup-devPYTHON_VERSION=3.9To runplayhdlfrom sourcespoetryrunplayhdl<args>Makefileprovides additional ways to interact with project:make format- auto-format all sourcesmake check-format- check current formatting of sourcesmake lint- perform lintingmake type- perform type checkingmake test- run all testsmake pre-commit- shorthand for combination ofcheck-format,lint,type,testMiscellaneousOffline installFor an offline install you have several options of how to getwheel:build locally usingpoetrypython-mpipinstall-Upoetry
poetrybuilddownload.whlfromPyPipython-mpipdownloadplayhdlThen you can use pip to install it on an offline machine:python-mpipinstall<wheel_file_name>.whl