Commit 7883e263 by Zachary Snow

several conversion bug fixes

- convert default pattern used to fill a vector
- convert Logic in parameter and localparam types
- interface conversion should happen early for type resolution later on
- interface conversion handles renaming of usages of inlined decls
parent dc759dbb
......@@ -28,7 +28,6 @@ type Phase = AST -> AST
phases :: [Job.Exclude] -> [Phase]
phases excludes =
extras ++
[ Convert.AsgnOp.convert
, Convert.FuncRet.convert
, Convert.Enum.convert
......@@ -40,7 +39,7 @@ phases excludes =
, Convert.Typedef.convert
, Convert.UnbasedUnsized.convert
, Convert.Unique.convert
]
] ++ extras
where
availableExcludes =
[ (Job.Interface, Convert.Interface.convert)
......
......@@ -112,13 +112,13 @@ convertDescription interfaces (Part extern Module lifetime name ports items) =
convertExpr :: Expr -> Expr
convertExpr (orig @ (Dot (Ident x) y)) =
if Map.member x modports
if Map.member x modports || Map.member x instances
then Ident (x ++ "_" ++ y)
else orig
convertExpr other = other
convertLHS :: LHS -> LHS
convertLHS (orig @ (LHSDot (LHSIdent x) y)) =
if Map.member x modports
if Map.member x modports || Map.member x instances
then LHSIdent (x ++ "_" ++ y)
else orig
convertLHS other = other
......
......@@ -47,6 +47,10 @@ convertDescription orig =
convertModuleItem other = other
-- all other logics (i.e. inside of functions) become regs
convertDecl :: Decl -> Decl
convertDecl (Parameter (IntegerVector TLogic sg rs) x e) =
Parameter (Implicit sg rs) x e
convertDecl (Localparam (IntegerVector TLogic sg rs) x e) =
Localparam (Implicit sg rs) x e
convertDecl (Variable d (IntegerVector TLogic sg rs) x a me) =
Variable d (IntegerVector TReg sg rs) x a me
convertDecl other = other
......
......@@ -175,7 +175,14 @@ convertAsgn structs types (lhs, expr) =
-- try expression conversion by looking at the *outermost* type first
convertExpr :: Type -> Expr -> Expr
convertExpr (Struct _ fields []) (Pattern [(Just "default", e)]) =
-- TODO: This is really a conversion for using default patterns to
-- populate arrays. Maybe this should be somewhere else?
convertExpr (IntegerVector t sg (r:rs)) (Pattern [(Just "default", e)]) =
Repeat (rangeSize r) [e']
where e' = convertExpr (IntegerVector t sg rs) e
convertExpr (Struct (Packed sg) fields (_:rs)) (Bit e _) =
convertExpr (Struct (Packed sg) fields rs) e
convertExpr (Struct (Packed _) fields _) (Pattern [(Just "default", e)]) =
Concat $ take (length fields) (repeat e)
convertExpr (Struct (Packed sg) fields []) (Pattern items) =
if Map.notMember structTf structs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment