Integration with ABC optimizer

Hi there,

I came across CIRCT while researching MLIR. I work on a project that currently uses Yosys for circuit optimization. We have been considering switching to MLIR in some fashion, and I was wondering to what extent the CIRCT project intends to integrate with tools like Yosys or specifically the ABC optimizer.

Right now we basically convert our existing (XLS) IR to Verilog, pass it through Yosys/ABC (with a custom liberty file), and use the output for our fun cryptography stuff. I am curious about the potential to use CIRCT as our IR, and convert to and from Verilog so that we can still use the ABC optimizer. Or better yet, if somehow the ABC optimizer could be integrated into CIRCT as an optimizing pass.

Is this in the right ballpark of CIRCT’s capabilities or roadmap?

It is very much in scope. We don’t have much of a roadmap since various companies and individuals have different needs. I was just in an internal meeting earlier today where we were discussing using ABC (as a library) to map and optimize the comb dialect operations to a netlist of FPGA primitives (LUTs) which would be represented as CIRCT ops in a hypothetical “fpga primitives” dialect.

We do have tests wherein we output SystemVerilog and run yosys on it do to… something? I think SiFive uses yosys for things. @darthscsi ?

We don’t have a Verilog “import” currently, though it is being worked on for simulation. Not clear to me if we intend to map that back into one of our “core” dialects.

Either way, ABC is a library so we can skip Verilog and just do an in-memory conversion from the CIRCT core dialects to ABC in-memory format, run the optimizations/mapping there, then convert back to CIRCT IR. (I don’t really know more than a little about ABC, but they seem to support use in this manner.)

1 Like

I just want to echo that this is in scope, and I personally would love to see things go in this direction.

Depending on the specific needs, it might be worthwhile considering mockturtle for synthesizing and optimizing combinational logic. This library should be easier to integrate than ABC (since it is a header-only, C++17 library) and provides a broader range of data structures to represent combinational logic, e.g., AIGs, XAGs, MIGs, kLUTs, and a couple of others. Its design allows almost all optimization algorithms to work with all different data structures, enabling greater design space exploration.

@j2kun Seeing you are using ABC for cryptography fun, I think you might be interested in mockturtle’s XAG optimizations techniques, specifically the one tailored for multiplicative complexity minimization.