class Verilator < Formula desc "Verilog simulator" homepage "https://www.veripool.org/wiki/verilator" url "https://www.veripool.org/ftp/verilator-3.922.tgz" sha256 "8fba8da6d4fc0044180a1d75ea671b11a5c7757683dadfbca38bd7c143433beb" bottle do sha256 "5cf38077dfed94e44ecf909edcaf0fcf6d271ac57ffc81b485f213b07b9e960f" => :high_sierra sha256 "c3afd25d8d253a9c2ad6faa6178e17ed3b04317a8cc12e5ef1a0c715e671b024" => :sierra sha256 "ed552e3268d2160cc5f1210cf9ddcc225ad6ef9a7ef3ee999b98ee65a8b57613" => :el_capitan end head do url "http://git.veripool.org/git/verilator", :using => :git depends_on "automake" => :build depends_on "autoconf" => :build end skip_clean "bin" # Allows perl scripts to keep their executable flag # Needs a newer flex on Lion (and presumably below) # https://www.veripool.org/issues/720-Verilator-verilator-not-building-on-Mac-OS-X-Lion-10-7- depends_on "flex" if MacOS.version <= :lion def install system "autoconf" if build.head? system "./configure", "--prefix=#{prefix}" # `make` and `make install` need to be separate for parallel builds system "make" system "make", "install" end test do (testpath/"test.v").write <<~EOS module test; initial begin $display("Hello World"); $finish; end endmodule EOS (testpath/"test.cpp").write <<~EOS #include "Vtest.h" #include "verilated.h" int main(int argc, char **argv, char **env) { Verilated::commandArgs(argc, argv); Vtest* top = new Vtest; while (!Verilated::gotFinish()) { top->eval(); } delete top; exit(0); } EOS system "/usr/bin/perl", bin/"verilator", "-Wall", "--cc", "test.v", "--exe", "test.cpp" cd "obj_dir" do system "make", "-j", "-f", "Vtest.mk", "Vtest" expected = <<~EOS Hello World - test.v:2: Verilog $finish EOS assert_equal expected, shell_output("./Vtest") end end end