From f13275bfa11c4f498d9b450d2998c60623f3a319 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Tue, 2 Apr 2019 01:00:02 -0400 Subject: [PATCH] fix Struct and Interface conversion for expressions within LHSs --- src/Convert/Interface.hs | 4 ++++ src/Convert/Struct.hs | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Convert/Interface.hs b/src/Convert/Interface.hs index b4fc6c2..560ded1 100644 --- a/src/Convert/Interface.hs +++ b/src/Convert/Interface.hs @@ -147,6 +147,10 @@ convertDescription interfaces modules (Part extern Module lifetime name ports it if Map.member x modports || Map.member x instances then LHSIdent (x ++ "_" ++ y) else orig + convertLHS (LHSBit l e) = + LHSBit l (traverseNestedExprs convertExpr e) + convertLHS (LHSRange l (e1, e2)) = + LHSRange l (traverseNestedExprs convertExpr e1, traverseNestedExprs convertExpr e2) convertLHS other = other convertPort :: Identifier -> [Identifier] convertPort ident = diff --git a/src/Convert/Struct.hs b/src/Convert/Struct.hs index b12a931..15f9d2b 100644 --- a/src/Convert/Struct.hs +++ b/src/Convert/Struct.hs @@ -142,12 +142,13 @@ convertAsgn structs types (lhs, expr) = Just t -> (t, LHSIdent x) convertLHS (LHSBit l e) = if null rs - then (Implicit Unspecified [], LHSBit l' e) - else (tf $ tail rs, LHSBit l' e) + then (Implicit Unspecified [], LHSBit l' e') + else (tf $ tail rs, LHSBit l' e') where (t, l') = convertLHS l (tf, rs) = typeRanges t - convertLHS (LHSRange l (rOuter @ (hiO, loO))) = + e' = snd $ convertSubExpr e + convertLHS (LHSRange l rOuterOrig) = case l' of LHSRange lInner (_, loI) -> (t, LHSRange lInner (simplify hi, simplify lo)) @@ -160,6 +161,9 @@ convertAsgn structs types (lhs, expr) = where (t, l') = convertLHS l (tf, rs) = typeRanges t + hiO = snd $ convertSubExpr $ fst rOuterOrig + loO = snd $ convertSubExpr $ snd rOuterOrig + rOuter = (hiO, loO) rs' = rOuter : tail rs convertLHS (LHSDot l x ) = case t of