--- A single alt case must be a selector
-mkConcSm (bndr, (Case (Var scrut) b ty [alt])) = error "Single case alt not supported yet"
+-- A single alt case must be a selector. This means thee scrutinee is a simple
+-- variable, the alternative is a dataalt with a single non-wild binder that
+-- is also returned.
+mkConcSm (bndr, expr@(Case (Var scrut) b ty [alt])) =
+ case alt of
+ (DataAlt dc, bndrs, (Var sel_bndr)) -> do
+ case List.elemIndex sel_bndr bndrs of
+ Just i -> do
+ labels <- getFieldLabels (Id.idType scrut)
+ let label = labels!!i
+ let scrut_name = AST.NSimple $ bndrToVHDLId scrut
+ let sel_suffix = AST.SSimple $ label
+ let sel_name = AST.NSelected $ scrut_name AST.:.: sel_suffix
+ let sel_expr = AST.PrimName sel_name
+ let sel_wform = AST.Wform [AST.WformElem sel_expr Nothing]
+ let dst_name = AST.NSimple (bndrToVHDLId bndr)
+ -- TODO: Reduce code duplication with the next mkConcSm clause
+ let assign = dst_name AST.:<==: (AST.ConWforms [] sel_wform Nothing)
+ return $ AST.CSSASm assign
+ Nothing -> error $ "VHDL.mkConcSM Not in normal form: Not a selector case:\n" ++ (pprString expr)
+
+ _ -> error $ "VHDL.mkConcSM Not in normal form: Not a selector case:\n" ++ (pprString expr)
+