Commit 710da1a6 by Zachary Snow

fix PackedArray ident prefix conditions

parent 15d85b46
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
- derive one from the other. The derivation direction is decided based on - derive one from the other. The derivation direction is decided based on
- which version, if any, is exposed directly as a port. - which version, if any, is exposed directly as a port.
- -
- TODO FIXME XXX: The Parser/AST don't yet support indexing into an identifier
- twice, or indexing into an identifier, and then selecting a range.
-
- TODO: This assumes that the first range index is the upper bound. We could - TODO: This assumes that the first range index is the upper bound. We could
- probably get around this with some cleverness in the generate block. I don't - probably get around this with some cleverness in the generate block. I don't
- think it's urgent to have support for "backwards" ranges. - think it's urgent to have support for "backwards" ranges.
...@@ -210,23 +207,25 @@ rewriteModuleItem info = ...@@ -210,23 +207,25 @@ rewriteModuleItem info =
traverseStmts rewriteStmt . traverseStmts rewriteStmt .
traverseExprs rewriteExpr traverseExprs rewriteExpr
where where
Info typeDims portDirs idxUses seqUses = info Info typeDims _ idxUses seqUses = info
duoUses = Set.intersection idxUses seqUses duoUses = Set.intersection idxUses seqUses
rewriteIdent :: Bool -> Identifier -> Identifier rewriteIdent :: Bool -> Identifier -> Identifier
rewriteIdent isAsgn x = rewriteIdent isSeqUsage x =
if isDuod && (isOutputPort == isAsgn) if Set.member x duoUses
then prefix x then
-- if an array is used both ways, then the original name is
-- the flattened version
if isSeqUsage
then x
else prefix x
else x else x
where rewriteSeqIdent = rewriteIdent True
isDuod = Set.member x duoUses rewriteIdxIdent = rewriteIdent False
isOutputPort = Map.lookup x portDirs == Just Output
rewriteReadIdent = rewriteIdent False
rewriteAsgnIdent = rewriteIdent True
rewriteExpr :: Expr -> Expr rewriteExpr :: Expr -> Expr
rewriteExpr (Ident i) = Ident i rewriteExpr (Ident i) = Ident $ rewriteSeqIdent i
rewriteExpr (Bit (Ident i) e) = Bit (Ident $ rewriteReadIdent i) e rewriteExpr (Bit (Ident i) e) = Bit (Ident $ rewriteIdxIdent i) e
rewriteExpr (Range (Ident i) (r @ (s, e))) = rewriteExpr (Range (Ident i) (r @ (s, e))) =
if Map.member i typeDims if Map.member i typeDims
then Range (Ident i) r' then Range (Ident i) r'
...@@ -240,9 +239,9 @@ rewriteModuleItem info = ...@@ -240,9 +239,9 @@ rewriteModuleItem info =
rewriteExpr other = other rewriteExpr other = other
rewriteLHS :: LHS -> LHS rewriteLHS :: LHS -> LHS
rewriteLHS (LHSIdent x ) = LHSIdent (rewriteAsgnIdent x) rewriteLHS (LHSIdent x ) = LHSIdent (rewriteSeqIdent x)
rewriteLHS (LHSBit (LHSBit (LHSIdent x) a) b) = rewriteLHS (LHSBit (LHSIdent x) e) =
LHSBit (LHSBit (LHSIdent $ rewriteReadIdent x) a) b LHSBit (LHSIdent $ rewriteIdxIdent x) e
rewriteLHS (LHSBit l e) = LHSBit (rewriteLHS l) e rewriteLHS (LHSBit l e) = LHSBit (rewriteLHS l) e
rewriteLHS (LHSRange l r) = LHSRange (rewriteLHS l) r rewriteLHS (LHSRange l r) = LHSRange (rewriteLHS l) r
rewriteLHS (LHSDot l x) = LHSDot (rewriteLHS l) x rewriteLHS (LHSDot l x) = LHSDot (rewriteLHS l) x
......
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