sequencer / chisel-panama-standalone-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An experimental example of MLIR pass plugin for CIRCT dialect

This is an experimental example based on https://github.com/llvm/llvm-project/tree/main/mlir/examples/standalone for implementing pass pipeline for CIRCT dialects.

standalone-switch-bar-foo implements a tranformation to replace a wire bar with foo.

Building - Component Build

DIR=<install path of CIRCT>
cd build
cmake .. -GNinja -DCMAKE_CXX_COMPILER=clang++ \
        -DCMAKE_C_COMPILER=clang \
        -DCIRCT_DIR=$DIR/lib/cmake/circt \
        -DMLIR_DIR=$DIR/lib/cmake/mlir \ 
        -DLLVM_DIR=$DIR/lib/cmake/llvm \ 
        -DLLVM_ENABLE_ZSTD=Off
ninja check-standalone
ls build/StandalonePlugin.so

firtool must be built on https://github.com/llvm/circt/tree/dev/hidetou/load-pass

$ cat foo.fir
circuit Bar: %[[
  { "target": "~Bar|Bar>bar", "class": "firrtl.transforms.DontTouchAnnotation"}
]]
  module Bar:
    input w: UInt<1>
    wire bar:UInt<1>
    
    bar <= w

$ firtool foo.fir
// Generated by CIRCT firtool-1.56.1-118-g195ae0749
module Bar(
  input w
);

  wire bar = w;
endmodule

$ firtool foo.fir -load-pass-plugin=$PWD/build/lib/StandalonePlugin.so -low-firrtl-pass-plugin='firrtl.circuit(standalone-switch-bar-foo)'
// Generated by CIRCT firtool-1.56.1-118-g195ae0749
module Bar(
  input w
);

  wire foo = w;
endmodule

About

License:Other


Languages

Language:C++ 55.4%Language:Nix 21.5%Language:CMake 19.0%Language:C 4.1%