From: christiaanb Date: Wed, 23 Jun 2010 10:05:35 +0000 (+0200) Subject: rotate alternatives of a case-statement if there is a default case X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=f69e59a92472c3a827ac25b52ab5d70895e19b7e;hp=e82d5210946093b03d9c46b7ffbcb556304e5b0b;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git rotate alternatives of a case-statement if there is a default case --- diff --git a/clash/CLasH/VHDL/Generate.hs b/clash/CLasH/VHDL/Generate.hs index 191ae9c..06bc265 100644 --- a/clash/CLasH/VHDL/Generate.hs +++ b/clash/CLasH/VHDL/Generate.hs @@ -311,7 +311,11 @@ mkConcSm (bndr, expr@(CoreSyn.Case (CoreSyn.Var scrut) _ _ alts)) = do -- alternatives. let cond_exprs = map (\x -> cmp AST.:=: x) altcons -- Rotate expressions to the left, so that the expression related to the default case is the last - exprs <- MonadState.lift tsType $ mapM (varToVHDLExpr . (\(_,_,CoreSyn.Var expr) -> expr)) ((tail alts) ++ [head alts]) + let alts' = case alts of + ((CoreSyn.DEFAULT,_,_):_) -> ((tail alts) ++ [head alts]) + otherwise -> alts + + exprs <- MonadState.lift tsType $ mapM (varToVHDLExpr . (\(_,_,CoreSyn.Var expr) -> expr)) alts' --((tail alts) ++ [head alts]) return ([mkAltsAssign (Left bndr) cond_exprs exprs], []) mkConcSm (_, CoreSyn.Case _ _ _ _) = error "\nVHDL.mkConcSm: Not in normal form: Case statement does not have a simple variable as scrutinee"