Merge branch 'cλash' of http://git.stderr.nl/matthijs/projects/master-project
[matthijs/master-project/cλash.git] / VHDL.hs
diff --git a/VHDL.hs b/VHDL.hs
index 998efb476669c8518fa2b29dc904e2bd93cfc6c3..4b69df5106071bc28c5c22ec343784f0610509d9 100644 (file)
--- a/VHDL.hs
+++ b/VHDL.hs
@@ -12,6 +12,7 @@ import qualified Control.Arrow as Arrow
 import qualified Control.Monad.Trans.State as State
 import qualified Data.Monoid as Monoid
 import Data.Accessor
+import Debug.Trace
 
 -- ForSyDe
 import qualified ForSyDe.Backend.VHDL.AST as AST
@@ -298,22 +299,7 @@ mkConcSm (bndr, app@(CoreSyn.App _ _))= do
       case (Map.lookup (varToString f) globalNameTable) of
         Just (arg_count, builder) ->
           if length valargs == arg_count then
-            case builder of
-              Left funBuilder -> do
-                let sigs = map (varToVHDLExpr.exprToVar) valargs
-                func <- funBuilder bndr sigs
-                let src_wform = AST.Wform [AST.WformElem func Nothing]
-                let dst_name = AST.NSimple (mkVHDLExtId (varToString bndr))
-                let assign = dst_name AST.:<==: (AST.ConWforms [] src_wform Nothing)
-                return [AST.CSSASm assign]
-              Right genBuilder -> do
-                let sigs = map exprToVar valargs
-                let signature = Maybe.fromMaybe
-                      (error $ "Using function '" ++ (varToString (head sigs)) ++ "' without signature? This should not happen!") 
-                      (Map.lookup (head sigs) signatures)
-                let arg = tail sigs
-                genSm <- genBuilder signature (arg ++ [bndr])  
-                return [genSm]
+            builder bndr f valargs
           else
             error $ "VHDL.mkConcSm Incorrect number of arguments to builtin function: " ++ pprString f ++ " Args: " ++ pprString valargs
         Nothing -> error $ "Using function from another module that is not a known builtin: " ++ pprString f