From 1c8b70b006a44dfd4931ab726a0859b79029544d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 29 Jan 2009 17:55:24 +0100 Subject: [PATCH] Allow multiple functions to be translated in the same session. --- Translator.hs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Translator.hs b/Translator.hs index 705b552..ef46be9 100644 --- a/Translator.hs +++ b/Translator.hs @@ -44,23 +44,20 @@ main = --core <- GHC.compileToCoreSimplified "Adders.hs" core <- GHC.compileToCoreSimplified "Adders.hs" liftIO $ printBinds (cm_binds core) - let bind = Maybe.fromJust $ findBind (cm_binds core) "full_adder" - let NonRec var expr = bind + let binds = Maybe.mapMaybe (findBind (cm_binds core)) ["full_adder", "half_adder"] -- Turn bind into VHDL - let vhdl = State.evalState (mkVHDL bind) (VHDLSession 0 builtin_funcs) - liftIO $ putStr $ showSDoc $ ppr expr - liftIO $ putStr "\n\n" - liftIO $ putStr $ render $ ForSyDe.Backend.Ppr.ppr $ vhdl - return expr + let vhdl = State.evalState (mkVHDL binds) (VHDLSession 0 builtin_funcs) + liftIO $ putStr $ concat $ map (render . ForSyDe.Backend.Ppr.ppr) vhdl + return () where -- Turns the given bind into VHDL - mkVHDL bind = do - -- Get the function signature - (name, f) <- mkHWFunction bind - -- Add it to the session - addFunc name f - arch <- getArchitecture bind - return arch + mkVHDL binds = do + -- Get the function signatures + funcs <- mapM mkHWFunction binds + -- Add them to the session + mapM (uncurry addFunc) funcs + -- Create architectures for them + mapM getArchitecture binds printTarget (Target (TargetFile file (Just x)) obj Nothing) = print $ show file -- 2.30.2