Skip to content

Instantly share code, notes, and snippets.

@LeventErkok
LeventErkok / LSB.hs
Created September 18, 2011 23:38
Prove that Edward Kmett's lsb implementation is correct
module LSB(main) where
import Data.Word
import Data.Array.Unboxed
import Data.Bits
import Data.SBV
-- Kmett's implementation of finding the least significant bit set in a 64 bit word
-- Adapted from the original implementation at:
-- http://github.com/ekmett/algebra/blob/master/Numeric/Coalgebra/Geometric.hs#L72
@LeventErkok
LeventErkok / CircuitSynthesizer.hs
Created August 11, 2011 09:15
Circuit Synthesizer
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.SBV
import Control.Exception as E
-- Node indexes, support upto 2^16 entries (no of inputs + no of AND gates)
type Node = SWord16
-- Values that flow through the AND gates