67 lines
2.1 KiB
Ruby
67 lines
2.1 KiB
Ruby
class Verilator < Formula
|
|
desc "Verilog simulator"
|
|
homepage "https://www.veripool.org/wiki/verilator"
|
|
url "https://www.veripool.org/ftp/verilator-4.110.tgz"
|
|
sha256 "4716fe0058661a29d6b59caf8e7471b2eddbded6ed44ede78dc1c65094ecfecc"
|
|
license any_of: ["LGPL-3.0-only", "Artistic-2.0"]
|
|
|
|
livecheck do
|
|
url "https://github.com/verilator/verilator.git"
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_big_sur: "21fca68551c495dfb52540ebf1aec6f6b43d7e9af6e41cf3407aa9c350083f69"
|
|
sha256 big_sur: "65503e49d92c3be042c5cdf51a020d512f26c089a5fd3d68930fefbfa39a938f"
|
|
sha256 catalina: "348d8bce800188559ff7e1e01cfc58345c30438ea3b00c6c4d1eb386851c64b9"
|
|
sha256 mojave: "3fe387a52d1ae9763bf681dfd4f0fe3e43a39f2ffa93f3dc9a30a4b2bad8d9ec"
|
|
end
|
|
|
|
head do
|
|
url "https://git.veripool.org/git/verilator", using: :git
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
end
|
|
|
|
depends_on "python@3.9" => :build
|
|
uses_from_macos "perl"
|
|
|
|
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
|