From 70654a9d134697f4d3703ff4a8747a1e078afd7b Mon Sep 17 00:00:00 2001 From: christiaanb Date: Thu, 24 Jun 2010 11:34:01 +0200 Subject: [PATCH] Always rotate alternatives of case-statements. Original bug was caused by reverse order of true and false vhdl literals --- clash/CLasH/VHDL/Generate.hs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/clash/CLasH/VHDL/Generate.hs b/clash/CLasH/VHDL/Generate.hs index 2fea7a3..b6aa8c6 100644 --- a/clash/CLasH/VHDL/Generate.hs +++ b/clash/CLasH/VHDL/Generate.hs @@ -301,7 +301,7 @@ mkConcSm (bndr, expr@(CoreSyn.Case (CoreSyn.Var scrut) _ _ alts)) = do let enums = [AST.PrimLit "'1'", AST.PrimLit "'0'"] return (enums, scrut_expr) (BuiltinType "Bool") -> do - let enums = [AST.PrimLit "true", AST.PrimLit "false"] + let enums = [AST.PrimLit "false", AST.PrimLit "true"] return (enums, scrut_expr) _ -> error $ "\nSelector case on weird scrutinee: " ++ pprString scrut ++ " scrutinee type: " ++ pprString (Id.idType scrut) -- Omit first condition, which is the default. Look up each altcon in @@ -311,11 +311,7 @@ mkConcSm (bndr, expr@(CoreSyn.Case (CoreSyn.Var scrut) _ _ alts)) = do -- alternatives. let cond_exprs = map (\x -> cmp AST.:=: x) altcons -- Rotate expressions to the leftso that the expression related to the default case is the last - -- Does NOT apply when there is no DEFAULT case and there are no binders - let alts' = if ((any (\(_,x,_) -> not (null x)) alts) || ((\(x,_,_)->x) (head alts)) == CoreSyn.DEFAULT ) then - ((tail alts) ++ [head alts]) - else - alts + let alts' = (tail alts) ++ [head alts] exprs <- MonadState.lift tsType $ mapM (varToVHDLExpr . (\(_,_,CoreSyn.Var expr) -> expr)) alts' --((tail alts) ++ [head alts]) return ([mkAltsAssign (Left bndr) cond_exprs exprs], []) -- 2.30.2