-------------------------------------------------------------------------------
--- $Id: ComputeNetlist.hs#9 2010/09/29 15:05:17 REDMOND\\satnams $
-------------------------------------------------------------------------------

module Lava.ComputeNetlist (-- * Generating a Lava netlist
                            computeNetlist
                            )
where

import Control.Monad.State

import Lava.ApplyLayout
import Lava.Netlist

-------------------------------------------------------------------------------

computeNetlist :: String -> XilinxArchitecture -> Out () -> Netlist
computeNetlist name architecture circuit
  = if nesting /= 0 then
      error ("Final layout nesting is not zero (" ++ show nesting ++ ")")
    else
      if length l > 2 then
        error ("Currently Lava only supports one top level layout group.")
      else
        applyLayout netlist
    where
    netlist = execState 
                circuit (Netlist name [] [] 2 0 [] 0 undefined architecture [])
    nesting = layoutNesting netlist
    l = layout netlist
 
-------------------------------------------------------------------------------