homebrew-core/Formula/verilator.rb

71 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
rebuild 1
sha256 arm64_big_sur: "42901384ef7092b0039c505d2ebbd7586024f25d5578eb2be31b9793a8c92fb0"
sha256 big_sur: "88161464bfe85fa5e711272374a7ff363d56b577ca490eac61165bde531c5543"
sha256 catalina: "a89df25c889c4e7c8333c4ac2072c7e309dd43d93c1405242644cee644041de3"
sha256 mojave: "a2ce7f0df7764dd771586ca7c0ebdb360e1834147c2d7737a5d7ec7adb3a0095"
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 "bison"
uses_from_macos "flex"
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