homebrew-core/Formula/verilator.rb
2019-12-01 14:34:37 -05:00

56 lines
1.8 KiB
Ruby

class Verilator < Formula
desc "Verilog simulator"
homepage "https://www.veripool.org/wiki/verilator"
url "https://www.veripool.org/ftp/verilator-4.022.tgz"
sha256 "3745611e83bfb35f24a626c803960dc0d4c1cae85a8f189f17f41e34e8c740ea"
bottle do
sha256 "b2c95ed4a46716d7a90928b3b03593fbcc8106be013d41bff8f7d783332775c0" => :catalina
sha256 "b5c97e50fd6590119afe09d4b6bc23a6ec57db69dea35681c5f4a44fa747798a" => :mojave
sha256 "035e91fe184fa5aaa46ec7e8be3357704cc64ed859a5bc1717c10319d0b7836b" => :high_sierra
end
head do
url "https://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