Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
The Quine-McCluskey Algorithm for Minimization of Boolean Functions.
Ported to Haskell from the Python qm Package (http://pypi.python.org/pypi/qm) and its improved version (including Petrick's method) by George Prekas (http://github.com/prekageo/optistate).
- type BitVector = Word64
- newtype QmTerm = QmTerm (BitVector, BitVector)
- getTerm :: QmTerm -> BitVector
- getMask :: QmTerm -> BitVector
- getMaskedTerm :: QmTerm -> BitVector
- fromString :: String -> QmTerm
- qm :: [BitVector] -> [BitVector] -> [BitVector] -> [QmTerm]
- compute_primes :: Set BitVector -> Set QmTerm
- bitcount :: Bits a => Bool -> a -> Int
- merge :: QmTerm -> QmTerm -> Maybe QmTerm
- unate_cover :: [QmTerm] -> [BitVector] -> (Int, Set QmTerm)
Documentation
getMaskedTerm :: QmTerm -> BitVector Source
Extract the variables BitVector
, with all masked positions set to 0.
fromString :: String -> QmTerm Source
:: [BitVector] | Ones, i.e. the set of min/maxterms that must be covered. |
-> [BitVector] | Zeros, i.e. the set of min/maxterms that must not be covered. |
-> [BitVector] | "Don't-care"-terms. These may be covered or not, whichever yields smaller subset of primes. |
-> [QmTerm] | The minimum set of prime terms, covering all ones. |
The Quine-McCluskey algorithm. Calculates the minimum cover of prime terms for a list of ones, zeros and "don't care" terms. All three can be non-empty, but at least either the ones or zeros must be non-empty. Based on that, the rest will be determined automatically.
:: Set BitVector | Min/maxterms that must be covered. |
-> Set QmTerm | The set of prime terms covering all min/maxterms. |
Calculates the (generally not minimum) set of prime terms covering a set of min/maxterms.
Counts the number of 1s (or 0s) in a BitVector
.