Additionally, make the SignatureMap indexed by CoreBndr instead of String.
This was previously not possible, because the builtin function also needed
to be in the signature map. This is no longer the case.
-- There must be a let at top level
let (CoreSyn.Let binds (CoreSyn.Var res)) = letexpr
res' <- mkMap res
-- There must be a let at top level
let (CoreSyn.Let binds (CoreSyn.Var res)) = letexpr
res' <- mkMap res
- let ent_decl' = createEntityAST fname args' res'
+ let vhdl_id = mkVHDLBasicId $ bndrToString fname
+ let ent_decl' = createEntityAST vhdl_id args' res'
let AST.EntityDec entity_id _ = ent_decl'
let signature = Entity entity_id args' res'
let AST.EntityDec entity_id _ = ent_decl'
let signature = Entity entity_id args' res'
- modA vsSignatures (Map.insert (bndrToString fname) signature)
+ modA vsSignatures (Map.insert fname signature)
--[(SignalId, SignalInfo)]
CoreSyn.CoreBndr
-> VHDLState VHDLSignalMapElement
--[(SignalId, SignalInfo)]
CoreSyn.CoreBndr
-> VHDLState VHDLSignalMapElement
-- | Create the VHDL AST for an entity
createEntityAST ::
-- | Create the VHDL AST for an entity
createEntityAST ::
- CoreSyn.CoreBndr -- | The name of the function
+ AST.VHDLId -- | The name of the function
-> [VHDLSignalMapElement] -- | The entity's arguments
-> VHDLSignalMapElement -- | The entity's result
-> AST.EntityDec -- | The entity with the ent_decl filled in as well
-> [VHDLSignalMapElement] -- | The entity's arguments
-> VHDLSignalMapElement -- | The entity's result
-> AST.EntityDec -- | The entity with the ent_decl filled in as well
-createEntityAST name args res =
+createEntityAST vhdl_id args res =
AST.EntityDec vhdl_id ports
where
-- Create a basic Id, since VHDL doesn't grok filenames with extended Ids.
AST.EntityDec vhdl_id ports
where
-- Create a basic Id, since VHDL doesn't grok filenames with extended Ids.
- vhdl_id = mkVHDLBasicId $ bndrToString name
ports = Maybe.catMaybes $
map (mkIfaceSigDec AST.In) args
++ [mkIfaceSigDec AST.Out res]
ports = Maybe.catMaybes $
map (mkIfaceSigDec AST.In) args
++ [mkIfaceSigDec AST.Out res]
-> VHDLState AST.ArchBody -- ^ The architecture for this function
createArchitecture (fname, expr) = do
-> VHDLState AST.ArchBody -- ^ The architecture for this function
createArchitecture (fname, expr) = do
- --signaturemap <- getA vsSignatures
- --let signature = Maybe.fromMaybe
- -- (error $ "Generating architecture for function " ++ (prettyShow hsfunc) ++ "without signature? This should not happen!")
- -- (Map.lookup hsfunc signaturemap)
- let entity_id = mkVHDLBasicId $ bndrToString fname
+ signaturemap <- getA vsSignatures
+ let signature = Maybe.fromMaybe
+ (error $ "Generating architecture for function " ++ (pprString fname) ++ "without signature? This should not happen!")
+ (Map.lookup fname signaturemap)
+ let entity_id = ent_id signature
-- Strip off lambda's, these will be arguments
let (args, letexpr) = CoreSyn.collectBinders expr
-- There must be a let at top level
-- Strip off lambda's, these will be arguments
let (args, letexpr) = CoreSyn.collectBinders expr
-- There must be a let at top level
let
signature = Maybe.fromMaybe
(error $ "Using function '" ++ (bndrToString f) ++ "' without signature? This should not happen!")
let
signature = Maybe.fromMaybe
(error $ "Using function '" ++ (bndrToString f) ++ "' without signature? This should not happen!")
- (Map.lookup (bndrToString f) signatures)
+ (Map.lookup f signatures)
entity_id = ent_id signature
label = bndrToString bndr
-- Add a clk port if we have state
entity_id = ent_id signature
label = bndrToString bndr
-- Add a clk port if we have state
type TypeFunMap = Map.Map OrdType [AST.SubProgBody]
-- A map of a Haskell function to a hardware signature
type TypeFunMap = Map.Map OrdType [AST.SubProgBody]
-- A map of a Haskell function to a hardware signature
-type SignatureMap = Map.Map String Entity
+type SignatureMap = Map.Map CoreSyn.CoreBndr Entity
-- A map of a builtin function to VHDL function builder
type NameTable = Map.Map String (Int, [AST.Expr] -> AST.Expr )
-- A map of a builtin function to VHDL function builder
type NameTable = Map.Map String (Int, [AST.Expr] -> AST.Expr )