64 lines
2.0 KiB
Ruby
64 lines
2.0 KiB
Ruby
class Verilator < Formula
|
|
desc "Verilog simulator"
|
|
homepage "https://www.veripool.org/wiki/verilator"
|
|
url "https://www.veripool.org/ftp/verilator-4.104.tgz"
|
|
sha256 "3c65e11b6dbd8f3119ee580f404b6db733f57f7ba167e7140ba03371e489dd72"
|
|
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 "ea8c9caf40da955aa8065aa4534a11e08dc9d15e8259641c80957892f436773c" => :big_sur
|
|
sha256 "153467ee24bd576ec7718de5ea1057cb10d15cf5686d1b8ff70f7cfb2691b17a" => :catalina
|
|
sha256 "f0962c5147a546b2849ae1bd16aa1e572c8f5c99cf84ba741f015920092c6291" => :mojave
|
|
sha256 "e11bc7fdd33209a6dfbb9d86cbee60569178a876fc690fa02a01013a51e841d7" => :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
|