Phi is a hardware description language that aims to succeed Verilog using concepts from modern programming languages.
It is our goal to design a well-defined language with:
- No behavioral ambiguity
- A clear definition and meta-definition divide
It's basically a mix of Swift/C++'s syntax with Verilog's semantics.
Phi supports Linux, macOS, and Windows with MSYS2.
- LLVM 6.0-8.0
- Ruby 2.3+
All running dependencies, plus:
- A POSIX environment
- A C++17 compiler that supports standard C++17
- No GCC or Clang specific extensions are used. Any used by accident are a bug we are interested in fixing.
- We still recommend Clang + LLDB for debugging.
- Git
- GNU Make 3.8.1+
- GNU Bison 3.0.4+
Install Xcode 9.0 or higher from the App Store.
For the other dependencies, we recommend Homebrew. Install it using the command in the link provided, then invoke:
brew install ruby bison llvmThis will take some time, llvm is big.
You will need to add bison to PATH, as brew won't. Do this however you want: a suggestion is to add this to your shell's profile:
export BISON="/usr/local/opt/bison/bin/bison"You will also need to expose LLVM Config to the compiler, as brew also won't. Again, it is suggested to add this to your shell's profile:
export LLVM_CONFIG="/usr/local/opt/llvm/bin/llvm-config"(For the default shells, that's ~/.bash_profile on Mojave and below, and ~/.zprofile on Catalina and above.)
Install git, gcc, make and bison using your package manager.
If you have Clang and you want to use it, you can export and set the CC and CXX environment variables to clang and clang++ respectively.
Phi has been tested and is working on Ubuntu 18.04, 19.04 and their derivatives.
Using apt...
sudo apt-get install git build-essential bison llvm ruby-devIf you're into clang...
sudo apt-get install clang lldbFirst, get MSYS2-x86_64 if you haven't already.
pacman -S git make mingw-w64-x86_64-gcc bison mingw-w64-x86_64-llvm rubyYou can still also use Clang and lldb if you're into that:
pacman -S mingw-w64-x86_64-clang lldbWe are interested in supporting Visual Studio in the future.
Run git submodule update --init --recursive --depth 1.
We use open source libraries for various functions, and they're all imported using git submodules.
You can then invoke either make or make release. The former produces a debug binary, which is slower but packs more features. It is more suitable for doing dev work on the actual compiler. If you intend on using the Phi compiler itself, we recommend make release.
There are two invocation options here: ./phic and ./phi.
./phic is the actual compiler for Phi. It's a plain binary. You can write ./phi --help for more information, but the short story is, to invoke it write ./phi <phi file name>. If there are no errors returned, it creates a file with the same name as the filename given with ".sv" appended.
The former is a ruby script with certain capabilities including the ability to load .sv files and simulate them instantly: bypassing the .out file as a middle step. It also processes a special extension to SystemVerilog, `phi. Tick phi allows you to include Phi files from SystemVerilog files, where the script will automatically invoke the Phi compiler on them.
To invoke it, simply write ./phi <.phi or .sv file>. In case of a phi file, it acts like the compiler itself, but some options (especially the debug only ones) are not available.
Both executables comply with BSD-style system exits, and you can write ./phi(c) --help for more info.
Phi is available under the Apache 2.0 license, available at the root of this project as 'License'.
Please try to keep any copyleft code out of the final binary, and that includes LGPL libraries.