functiontest :: TFVec D3 (TFVec D4 Bit) -> TFVec D12 Bit
functiontest = \v -> let r = concat v in r
-functiontest2 :: SizedInt D8 -> SizedInt D8
-functiontest2 = \a -> let r = a + 1 in r
+functiontest2 :: SizedInt D8 -> SizedInt D7
+functiontest2 = \a -> let r = Data.SizedInt.resize a in r
xhwnot x = hwnot x
map (\exp -> Nothing AST.:=>: AST.ADExpr exp) args
genFromSizedWord' (Right name) _ _ = error $ "\nGenerate.genFromSizedWord': Cannot generate builtin function call assigned to a VHDLName: " ++ show name
+genResize :: BuiltinBuilder
+genResize = genExprArgs $ genExprRes genResize'
+genResize' :: Either CoreSyn.CoreBndr AST.VHDLName -> CoreSyn.CoreBndr -> [AST.Expr] -> VHDLSession AST.Expr
+genResize' (Left res) f [arg] = do {
+ ; let { ty = Var.varType res
+ ; (tycon, args) = Type.splitTyConApp ty
+ ; name = Name.getOccString (TyCon.tyConName tycon)
+ } ;
+ ; len <- case name of
+ "SizedInt" -> MonadState.lift vsType $ tfp_to_int (sized_int_len_ty ty)
+ "SizedWord" -> MonadState.lift vsType $ tfp_to_int (sized_word_len_ty ty)
+ ; return $ AST.PrimFCall $ AST.FCall (AST.NSimple (mkVHDLBasicId resizeId))
+ [Nothing AST.:=>: AST.ADExpr arg, Nothing AST.:=>: AST.ADExpr( AST.PrimLit (show len))]
+ }
+genResize' (Right name) _ _ = error $ "\nGenerate.genFromSizedWord': Cannot generate builtin function call assigned to a VHDLName: " ++ show name
+
-- FIXME: I'm calling genLitArgs which is very specific function,
-- which needs to be fixed as well
genFromInteger :: BuiltinBuilder
, (minusId , (2, genOperator2 (AST.:-:) ) )
, (fromSizedWordId , (1, genFromSizedWord ) )
, (fromIntegerId , (1, genFromInteger ) )
+ , (resizeId , (1, genResize ) )
]
maintainer: christiaan.baaij@gmail.com & matthijs@stdin.nl
build-depends: base > 4, syb, ghc, ghc-paths, transformers, haskell98,
ForSyDe > 3.0, regex-posix ,data-accessor-template, pretty,
- data-accessor, containers, prettyclass, tfp > 0.3.1,
+ data-accessor, containers, prettyclass, tfp > 0.3.2,
tfvec > 0.1.2, QuickCheck, template-haskell, filepath
executable: clash