CCirc MLIR Dialect - gt-tinker/qwerty GitHub Wiki
This document describes our CCirc
MLIR dialect aimed to replace mockturtle's XAG.
There are three type:
-
WireType
: A one-bit wire -
WireBundleType
: (Jaehun, refer toBitBundle
in the Qwerty dialect)- Has a
uint64_t
parameter calleddim
- Has a
-
CircuitType
: The type of aCircuit
op (see below)- Has two
uint64_t
parameters,in_dim
andout_dim
- Has two
We choose not to use the existing i1
type in MLIR because a circuit wire
should not be usable as an scf.if
condition or an operand to an arith
op.
-
AndOp
: Bitwise AND- Inputs:
-
left
(of typeWire
) -
right
(of typeWire
)
-
- Output:
-
result
(of typeWire
)
-
- Inputs:
-
OrOp
: Bitwise OR- Inputs:
-
left
(of typeWire
) -
right
(of typeWire
)
-
- Output:
-
result
(of typeWire
)
-
- Inputs:
-
XorOp
: Bitwise XOR- Inputs:
-
left
(of typeWire
) -
right
(of typeWire
)
-
- Output:
-
result
(of typeWire
)
-
- Inputs:
-
NotOp
: Bitwise NOT (Jaehun, this is a good one to start with)- Inputs:
-
operand
(of typeWire
)
-
- Output:
-
result
(of typeWire
)
-
- Inputs:
-
RotrOp
: Right bit rotation- Inputs:
-
val
(of typeWireBundle
) -
amt
(of typeWireBundle
)
-
- Output:
-
result
(of typeWireBundle
)
-
- Verification:
val
andresult
should have the same type.
- Inputs:
-
RotlOp
: Left bit rotation- Inputs:
-
val
(of typeWireBundle
) -
amt
(of typeWireBundle
)
-
- Output:
-
result
(of typeWireBundle
)
-
- Verification:
val
andresult
should have the same type.
- Inputs:
-
WireBundlePackOp
: Create aWireBundle
fromWire
s (Jaehun, refer to theBitBundlePackOp
in the Qwerty dialect)- Inputs:
-
wires
(of typeVariadic<Wire>
)
-
- Output:
-
bundle
(of typeWireBundle
)
-
- Inputs:
-
WireBundleUnpackOp
: Unpack aWireBundle
intoWire
s (Jaehun, refer to theBitBundleUnpackOp
in the Qwerty dialect)- Inputs:
-
bundle
(of typeWireBundle
)
-
- Output:
-
wires
(of typeVariadic<Wire>
)
-
- Inputs:
-
CircuitOp
: A top-level circuit with inputs and outputs (Jaehun, I will handle this one and model it after theFuncOp
in the Qwerty dialect)- Traits:
IsolatedFromAbove
,Callable
- Interfaces:
CallableOpInterface
,FunctionOpInterface
- Attributes: symbol name, symbol visiblity, and a
CircuitType
type - Regions: One-block body. Block has one argument (a
WireBundle
) and yields one value (aWireBundle
) - Verifier: Checks that the body only contains ops from this dialect and that
the function type is from
WireBundle
toWireBundle
- Traits: