From 454503106eef8deb32481d4f67a3d510950118e5 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 16 Feb 2009 13:01:43 +0100 Subject: [PATCH] Add Entities for builtin functions. --- Translator.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Translator.hs b/Translator.hs index 37a812b..cccac4c 100644 --- a/Translator.hs +++ b/Translator.hs @@ -37,6 +37,7 @@ import HsValueMap import Pretty import Flatten import FlattenTypes +import VHDLTypes import qualified VHDL main = @@ -211,13 +212,20 @@ type PortMap = HsValueMap (String, AST.TypeMark) -- | A consise representation of a builtin function data BuiltIn = BuiltIn String [PortMap] PortMap +-- | Map a port specification of a builtin function to a VHDL Signal to put in +-- a VHDLSignalMap +toVHDLSignalMap :: HsValueMap (String, AST.TypeMark) -> VHDLSignalMap +toVHDLSignalMap = fmap (\(name, ty) -> (VHDL.mkVHDLId name, ty)) + -- | Translate a concise representation of a builtin function to something -- that can be put into FuncMap directly. addBuiltIn :: BuiltIn -> VHDLState () addBuiltIn (BuiltIn name args res) = do addFunc hsfunc + setEntity hsfunc entity where hsfunc = HsFunction name (map useAsPort args) (useAsPort res) + entity = Entity (VHDL.mkVHDLId name) (map toVHDLSignalMap args) (toVHDLSignalMap res) Nothing builtin_funcs = [ -- 2.30.2