Struct SimpleAigOpt

Source
pub struct SimpleAigOpt;
Expand description

Implements simple AIG optimizations.

The following transformations are done:

  • multi-bit And, Or, Xor, Not are bitblasted
  • single-bit And, Or are transformed into Aig
  • Not cells on Aig inputs are merged into the Aig
  • Not cells on Xor inputs are pushed onto the output
  • const folding:
    • ~0 -> 1
    • ~1 -> 0
    • ~X -> X
    • a & 0 -> 0
    • a & 1 -> a
    • a ^ 0 -> a
    • a ^ 1 -> ~a
    • a ^ X -> X
  • idempotence:
    • a & a -> a
    • (a & b) & a -> a
    • (a & b) & (a & c) -> (a & b) & c
  • contradiction:
    • a & ~a -> 0
    • (a & b) & ~a -> 0
    • (a & b) & (~a & c) -> 0
  • subsumption:
    • (a | b) & a -> a
    • (a | b) & (a & c) -> a & c
  • resolution:
    • (a | b) & (~a | b) -> b
  • substitution:
    • (a | b) & ~b -> a & ~b
    • (a | b) & (~b & c) -> a & (~b & c)
    • (a ^ b) & ~b -> a & ~b
    • (a ^ b) & b -> ~a & b
    • ~(a ^ b) & ~b -> ~a & ~b
    • ~(a ^ b) & b -> a & b
    • (a ^ b) & (~b & c) -> a & (~b & c)
    • (a ^ b) & (b & c) -> ~a & (b & c)
    • ~(a ^ b) & (~b & c) -> ~a & (~b & c)
    • ~(a ^ b) & (b & c) -> a & (b & c)
  • XOR folding:
    • a ^ a -> 0
    • (a ^ b) ^ a -> b
    • (a ^ b) ^ (a ^ c) -> b ^ c
  • AND-XOR optimization:
    • (a & b) ^ a -> a & ~b
    • (a & b) ^ ~a -> ~(a & ~b)
  • XOR recognition:
    • ~(a & b) & ~(~a & ~b) -> a ^ b

All rules above are replicated for any commutation of operands, and any negation of inputs.

This ruleset ensures that any fragment of the netlist including only Not, And, Or, Xor, Aig cells will be transformed into a fragment containing only Aig, single-bit Xor, and single-bit Not cells, with the single-bit Not cells only present when required by non-Aig non-Xor cell inputs.

The optimizations performed here are mostly borrowed from https://fmv.jku.at/papers/BrummayerBiere-MEMICS06.pdf and have an important property described in the paper: they will never create more than one new cell (Not cells don’t count), and they will not increase the logic level. Thus, they can never make the netlist “worse”.

Trait Implementations§

Source§

impl RewriteRuleset for SimpleAigOpt

Source§

fn rewrite<'a>( &self, cell: &Cell, meta: MetaItemRef<'a>, _output: Option<&Value>, rewriter: &Rewriter<'a>, ) -> RewriteResult<'a>

Source§

fn cell_added(&self, design: &Design, cell: &Cell, output: &Value)

Source§

fn net_replaced(&self, design: &Design, from: Net, to: Net)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.