class Verilator < Formula desc "Verilog simulator" homepage "https://www.veripool.org/wiki/verilator" url "https://www.veripool.org/ftp/verilator-4.014.tgz" sha256 "edf517b1b3ae0df98bd8d8189d17142c181cd50948d54a6ecb082f38804a33eb" bottle do sha256 "5f3fb635a4377204d1fa2c24a462635bff80522fb5a3660c3297a075e2f9fc57" => :mojave sha256 "660b6959c21e50f13c374b17a7777f251a1e2da8d661f8478d3a55a5dbd2a99e" => :high_sierra sha256 "3dc134e88d6c90262a18340a4556384d43d613322bf61baf1f82ffc217d99542" => :sierra end head do url "http://git.veripool.org/git/verilator", :using => :git depends_on "autoconf" => :build depends_on "automake" => :build end skip_clean "bin" # Allows perl scripts to keep their executable flag 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