X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Generate.hs;h=637ef27a0186847712f1c2a8303f7f16c3f72c1e;hb=aa03222c571e37a1a05b6fbf4e09c748cf786286;hp=f81d7692434a7247325f1d1fdc3f1292d23df9b7;hpb=de5278001659d6673ba90e9b721c665805ce4962;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Generate.hs b/Generate.hs index f81d769..637ef27 100644 --- a/Generate.hs +++ b/Generate.hs @@ -31,7 +31,7 @@ genMapCall :: -> 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 @@ -62,7 +62,8 @@ genUnconsVectorFuns elemTM vectorTM = , 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" @@ -209,4 +210,15 @@ genUnconsVectorFuns elemTM vectorTM = [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