X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=VHDL.hs;h=c952dddf5e2f6a9485e2fdf076a1a0bd6eb057d2;hb=5d228d03054226ebb6e9b9194c180e94a038a81c;hp=c1b42b3bc89a9b2764ff60626957a036b9242649;hpb=38ac166769b7280fcb9e63f6fda3955d9b58ce11;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/VHDL.hs b/VHDL.hs index c1b42b3..c952ddd 100644 --- a/VHDL.hs +++ b/VHDL.hs @@ -35,19 +35,21 @@ createDesignFiles :: -> [(AST.VHDLId, AST.DesignFile)] createDesignFiles flatfuncmap = - -- TODO: Output types - (mkVHDLId "types", AST.DesignFile [] [type_package]) : - map (Arrow.second $ AST.DesignFile context) units + (mkVHDLId "types", AST.DesignFile ieee_context [type_package]) : + map (Arrow.second $ AST.DesignFile full_context) units where init_session = VHDLSession Map.empty builtin_funcs (units, final_session) = State.runState (createLibraryUnits flatfuncmap) init_session ty_decls = Map.elems (final_session ^. vsTypes) - context = [ - AST.Library $ mkVHDLId "IEEE", - AST.Use $ (AST.NSimple $ mkVHDLId "IEEE.std_logic_1164") AST.:.: AST.All, - AST.Use $ (AST.NSimple $ mkVHDLId "work.types") AST.:.: AST.All] + ieee_context = [ + AST.Library $ mkVHDLId "IEEE", + AST.Use $ (AST.NSimple $ mkVHDLId "IEEE.std_logic_1164") AST.:.: AST.All + ] + full_context = + (AST.Use $ (AST.NSimple $ mkVHDLId "work.types") AST.:.: AST.All) + : ieee_context type_package = AST.LUPackageDec $ AST.PackageDec (mkVHDLId "types") (map (AST.PDITD . snd) ty_decls) createLibraryUnits :: @@ -168,8 +170,6 @@ createArchitecture hsfunc flatfunc = do args = flat_args flatfunc res = flat_res flatfunc defs = flat_defs flatfunc - -- TODO: Unique ty_decls - -- TODO: Store ty_decls somewhere procs = map mkStateProcSm (makeStatePairs flatfunc) procs' = map AST.CSPSm procs -- mkSigDec only uses vsTypes from the state @@ -369,11 +369,13 @@ mk_fsvec_ty ty args = do -- Assume there are two type arguments let [len, el_ty] = args -- TODO: Find actual number - let ty_id = mkVHDLId ("vector_" ++ (show len)) + -- Construct the type id, but filter out dots (since these are not allowed). + let ty_id = mkVHDLId $ filter (/='.') ("vector_" ++ (show len)) -- TODO: Use el_ty let range = AST.IndexConstraint [AST.ToRange (AST.PrimLit "0") (AST.PrimLit "16")] let ty_def = AST.TDA $ AST.ConsArrayDef range std_logic_ty let ty_dec = AST.TypeDec ty_id ty_def + -- TODO: Check name uniqueness State.modify (Map.insert (OrdType ty) (ty_id, ty_dec)) return ty_id