Encode enumerations as unsigned integers instead of vhdls enum type
[matthijs/master-project/cλash.git] / clash / CLasH / VHDL / Generate.hs
index 8c59334085fe6e53bcd153eb514320e96b2a67d0..e546821ceb8b9d0b36589a0a1072774d5f46c129 100644 (file)
@@ -1113,7 +1113,7 @@ genApplication (dst, dsttype) f args = do
                   return ([mkUncondAssign dst arg'], [])
                 -- In all other cases, a record type is created.
                 _ -> case htype_either of
-                  Right htype@(AggrType _ _ _) -> do
+                  Right htype@(AggrType _ etype _) -> do
                     let dc_i = datacon_index dsttype dc
                     let labels = getFieldLabels htype dc_i
                     arg_exprs <- argsToVHDLExprs argsNoState
@@ -1125,8 +1125,9 @@ genApplication (dst, dsttype) f args = do
                           -- constructor used to the constructor field as
                           -- well.
                           Just dc_label ->
-                            let dc_expr = AST.PrimName $ AST.NSimple $ mkVHDLExtId $ varToString f in
-                            (dc_label:labels, dc_expr:arg_exprs)
+                            let { dc_index = getConstructorIndex (snd $ Maybe.fromJust etype) (varToString f)
+                                ; dc_expr = AST.PrimLit $ show dc_index 
+                                } in (dc_label:labels, dc_expr:arg_exprs)
                     return (zipWith mkassign final_labels final_exprs, [])
                     where
                       mkassign :: AST.VHDLId -> AST.Expr -> AST.ConcSm