-> AST.GenerateSm -- | The resulting generate statement
genMapCall len entity [arg, res] = genSm
where
- label = AST.unsafeVHDLBasicId "mapVector"
+ label = AST.unsafeVHDLBasicId ("mapVector" ++ (AST.fromVHDLId res))
nPar = AST.unsafeVHDLBasicId "n"
range = AST.ToRange (AST.PrimLit "0") (AST.PrimLit $ show (len-1))
genScheme = AST.ForGn nPar range
, AST.SubProgBody takeSpec [AST.SPVD takeVar] [takeExpr, takeRet]
, AST.SubProgBody dropSpec [AST.SPVD dropVar] [dropExpr, dropRet]
, AST.SubProgBody plusgtSpec [AST.SPVD plusgtVar] [plusgtExpr, plusgtRet]
- , AST.SubProgBody emptySpec [AST.SPVD emptyVar] [emptyExpr]
+ , AST.SubProgBody emptySpec [AST.SPVD emptyVar] [emptyExpr]
+ , AST.SubProgBody singletonSpec [AST.SPVD singletonVar] [singletonRet]
]
where
ixPar = AST.unsafeVHDLBasicId "ix"
[AST.ToRange (AST.PrimLit "0")
(AST.PrimLit "-1")]))
Nothing
- emptyExpr = AST.ReturnSm (Just $ AST.PrimName (AST.NSimple resId))
\ No newline at end of file
+ emptyExpr = AST.ReturnSm (Just $ AST.PrimName (AST.NSimple resId))
+ singletonSpec = AST.Function singletonId [AST.IfaceVarDec aPar elemTM ]
+ vectorTM
+ -- variable res : fsvec_x (0 to 0) := (others => a);
+ singletonVar =
+ AST.VarDec resId
+ (AST.SubtypeIn vectorTM
+ (Just $ AST.ConstraintIndex $ AST.IndexConstraint
+ [AST.ToRange (AST.PrimLit "0") (AST.PrimLit "0")]))
+ (Just $ AST.Aggregate [AST.ElemAssoc (Just AST.Others)
+ (AST.PrimName $ AST.NSimple aPar)])
+ singletonRet = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId)
\ No newline at end of file
, ("+>" , (2, Left $ genExprFCall plusgtId ) )
, ("map" , (2, Right $ genMapCall ) )
, ("empty" , (0, Left $ genExprFCall emptyId ) )
+ , ("singleton" , (1, Left $ genExprFCall singletonId ) )
, ("hwxor" , (2, Left $ genExprOp2 AST.Xor ) )
, ("hwand" , (2, Left $ genExprOp2 AST.And ) )
, ("hwor" , (2, Left $ genExprOp2 AST.Or ) )
-- It's a global value imported from elsewhere. These can be builtin
-- functions.
funSignatures <- getA vsNameTable
- entSignatures <- getA vsSignatures
+ signatures <- getA vsSignatures
case (Map.lookup (bndrToString f) funSignatures) of
Just (arg_count, builder) ->
if length valargs == arg_count then
return [AST.CSSASm assign]
Right genBuilder ->
let
- sigs = map (varBndr) valargs
+ sigs = map varBndr valargs
signature = Maybe.fromMaybe
(error $ "Using function '" ++ (bndrToString (head sigs)) ++ "' without signature? This should not happen!")
- (Map.lookup (head sigs) entSignatures)
- arg_name = mkVHDLExtId (bndrToString (last sigs))
+ (Map.lookup (head sigs) signatures)
+ arg_names = map (mkVHDLExtId . bndrToString) (tail sigs)
dst_name = mkVHDLExtId (bndrToString bndr)
- genSm = genBuilder 4 signature [arg_name, dst_name]
+ genSm = genBuilder 4 signature (arg_names ++ [dst_name])
in return [AST.CSGSm genSm]
else
error $ "VHDL.mkConcSm Incorrect number of arguments to builtin function: " ++ pprString f ++ " Args: " ++ pprString valargs