moonbit-rtl

    A practical Verilog RTL parser and rule checker written in MoonBit.

    verilog
    rtl
    fpga
    linter
    parser
    Download zip
    Version
    0.1.5
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    55

    #moonbit-rtl

    moonbit-rtl is a MoonBit Verilog-2001 front end for practical RTL analysis. It turns HDL text into a source-spanned model and produces diagnostics, simulation traces, timing/coverage evidence, and machine-readable reports for hardware review, editor tooling, and reproducible CI.

    #Project positioning

    The package is a deterministic analysis and verification toolkit. It is not a synthesizer and does not claim to replace a complete IEEE Verilog implementation. The supported subset is intentionally explicit and designed for reusable tooling and small-to-medium RTL review workflows.

    #Core capabilities

    • source-positioned lexical analysis and practical module parsing;
    • ANSI ports, packed widths, parameters, expressions, instances, procedural blocks, and common case forms;
    • configurable declaration, driver, width, reference, dataflow, contract, naming, clock/reset, and advanced rule-pack checks;
    • preprocessor, four-state bit vectors, fixed-point simulation, hierarchy, timing, coverage, intermediate IR, LSP, query, and netlist APIs;
    • verification vectors, trace capture/replay, release evidence, and text, JSON, SARIF, Markdown, GitHub annotation, and summary reports;
    • native CLI with file input, token output, rule controls, and benchmarks.

    #Quick start

    moon update moon check --deny-warn moon test --deny-warn moon run cmd --target native -- --summary

    Check a source file with the CLI:

    moon run cmd --target native -- --file examples/basic.v --json moon run cmd --target native -- --benchmark=100 --benchmark-fixture=large

    Library usage:

    let result = @yzfyzf12345678/moonbit-rtl/src.run_default_pipeline(source)
    println(result.status_line())

    #CLI

    --file PATH read a Verilog source file --json emit JSON diagnostics --sarif emit SARIF 2.1.0 --markdown emit a Markdown diagnostic table --summary print counts and rule IDs --tokens print tokens with source positions --disable=RTLxxx disable one rule --max-diagnostics N cap emitted findings --benchmark[=N] run the deterministic benchmark

    #Architecture

    source -> preprocessor -> lexer/parser -> enriched AST -> checker/width/dataflow/hierarchy/timing/coverage -> simulation/IR/query/netlist/verification -> reports, CLI, editor, CI, and release evidence

    The implementation is organized into cohesive MoonBit modules. Generated interfaces are refreshed by moon info and are not edited by hand.

    #Benchmarks

    Run the deterministic local benchmark:

    moon run cmd --target native -- --benchmark=1000

    The measured command, fixture sizes, toolchain, and machine context are recorded in BENCHMARKS.md. The latest run observed 21, 36, and 26 tokens/ms for the small, medium, and large fixtures respectively. Measurements are environment-specific observations.

    The recorded native run uses 100 rounds per fixture on the documented machine; fixture sizes, token counts, diagnostics, and elapsed times are listed in BENCHMARKS.md.

    #Tests and CI

    The suite contains 61 passing tests covering lexer and parser boundaries, preprocessing, four-state vectors, simulation, advanced rules, queries, netlists, verification vectors, trace replay, source maps, dataflow, contracts, reports, snapshots, and benchmark fixtures.

    moon fmt moon info moon check --target all --deny-warn moon test --target all --deny-warn

    GitHub Actions repeats formatting, generated-interface, all-target check/test, native smoke, coverage, and CLI example checks on Ubuntu, macOS, and Windows.

    The separate publish workflow validates the package and runs moon publish when manually dispatched or when a version tag is pushed. It reads the repository's Mooncakes credentials secret only during that step and removes the temporary credentials afterwards.

    #License

    Apache-2.0. See LICENSE.