From 85693fb7ac19042b767cd712e92aec9897a0155e Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 14 Aug 2009 13:27:31 +0200 Subject: [PATCH] Be more strict in state recognition. Previously, any cast that involves a state variable, would be classified as state (un)packing. Now, only do this if the cast actually changes a variable from (packed) state to non state (e.g., unpacked state). --- "c\316\273ash/CLasH/VHDL/Generate.hs" | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git "a/c\316\273ash/CLasH/VHDL/Generate.hs" "b/c\316\273ash/CLasH/VHDL/Generate.hs" index 149c6ec..1547458 100644 --- "a/c\316\273ash/CLasH/VHDL/Generate.hs" +++ "b/c\316\273ash/CLasH/VHDL/Generate.hs" @@ -142,12 +142,12 @@ getArchitecture fname = Utils.makeCached fname tsArchitectures $ do -> TranslatorSession ((Maybe CoreSyn.CoreBndr, Maybe CoreSyn.CoreBndr), ([AST.ConcSm], [CoreSyn.CoreBndr])) -- ^ ((Input state variable, output state variable), (statements, used entities)) -- newtype unpacking is just a cast - dobind (bndr, (CoreSyn.Cast expr coercion)) - | hasStateType expr + dobind (bndr, unpacked@(CoreSyn.Cast packed coercion)) + | hasStateType packed && not (hasStateType unpacked) = return ((Just bndr, Nothing), ([], [])) -- With simplCore, newtype packing is just a cast - dobind (bndr, expr@(CoreSyn.Cast (CoreSyn.Var state) coercion)) - | hasStateType expr + dobind (bndr, packed@(CoreSyn.Cast unpacked@(CoreSyn.Var state) coercion)) + | hasStateType packed && not (hasStateType unpacked) = return ((Nothing, Just state), ([], [])) -- Without simplCore, newtype packing uses a data constructor dobind (bndr, (CoreSyn.App (CoreSyn.App (CoreSyn.Var con) (CoreSyn.Type _)) (CoreSyn.Var state))) -- 2.30.2