projects
/
matthijs
/
master-project
/
cλash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ac4f2be
)
Allow multiple functions to be translated in the same session.
author
Matthijs Kooijman
<m.kooijman@student.utwente.nl>
Thu, 29 Jan 2009 16:55:24 +0000
(17:55 +0100)
committer
Matthijs Kooijman
<m.kooijman@student.utwente.nl>
Thu, 29 Jan 2009 16:55:24 +0000
(17:55 +0100)
Translator.hs
patch
|
blob
|
history
diff --git
a/Translator.hs
b/Translator.hs
index 705b552c876b1e2703a63855f819e5848d1a4233..ef46be9f90f6d2e153e04a3459b654cc57d58070 100644
(file)
--- 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)
--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
-- 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
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 bind
s
= do
+ -- Get the function signature
s
+ 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
printTarget (Target (TargetFile file (Just x)) obj Nothing) =
print $ show file