Commit 0a3e9f4f by Zachary Snow

more range-bit edge cases in Struct conversion

parent 650c602b
...@@ -147,14 +147,20 @@ convertAsgn structs types (lhs, expr) = ...@@ -147,14 +147,20 @@ convertAsgn structs types (lhs, expr) =
where where
(t, l') = convertLHS l (t, l') = convertLHS l
(tf, rs) = typeRanges t (tf, rs) = typeRanges t
convertLHS (LHSRange l r ) = convertLHS (LHSRange l (rOuter @ (hiO, loO))) =
if null rs case l' of
then (Implicit Unspecified [], LHSRange l' r) LHSRange lInner (hiI, loI) ->
else (tf rs', LHSRange l' r) (t, LHSRange lInner (simplify hi, simplify lo))
where
hi = BinOp Add (BinOp Sub hiI loI) hiO
lo = BinOp Add loI loO
_ -> if null rs
then (Implicit Unspecified [], LHSRange l' rOuter)
else (tf rs', LHSRange l' rOuter)
where where
(t, l') = convertLHS l (t, l') = convertLHS l
(tf, rs) = typeRanges t (tf, rs) = typeRanges t
rs' = r : tail rs rs' = rOuter : tail rs
convertLHS (LHSDot l x ) = convertLHS (LHSDot l x ) =
case t of case t of
InterfaceT _ _ _ -> (Implicit Unspecified [], LHSDot l' x) InterfaceT _ _ _ -> (Implicit Unspecified [], LHSDot l' x)
...@@ -229,7 +235,7 @@ convertAsgn structs types (lhs, expr) = ...@@ -229,7 +235,7 @@ convertAsgn structs types (lhs, expr) =
convertSubExpr (Range eOuter (rOuter @ (hiO, loO))) = convertSubExpr (Range eOuter (rOuter @ (hiO, loO))) =
-- VCS doesn't allow ranges to be cascaded, so we need to combine -- VCS doesn't allow ranges to be cascaded, so we need to combine
-- nested Ranges into a single range. My understanding of the -- nested Ranges into a single range. My understanding of the
-- semantics are that a range return a new, zero-indexed sub-range. -- semantics are that a range returns a new, zero-indexed sub-range.
case eOuter' of case eOuter' of
Range eInner (hiI, loI) -> Range eInner (hiI, loI) ->
(t, Range eInner (simplify hi, simplify lo)) (t, Range eInner (simplify hi, simplify lo))
...@@ -246,7 +252,10 @@ convertAsgn structs types (lhs, expr) = ...@@ -246,7 +252,10 @@ convertAsgn structs types (lhs, expr) =
(_, e1') = convertSubExpr e1 (_, e1') = convertSubExpr e1
(_, e2') = convertSubExpr e2 (_, e2') = convertSubExpr e2
convertSubExpr (Bit e i) = convertSubExpr (Bit e i) =
(t', Bit e' i') case e' of
Range eInner (_, loI) ->
(t', Bit eInner (simplify $ BinOp Add loI i'))
_ -> (t', Bit e' i')
where where
(t, e') = convertSubExpr e (t, e') = convertSubExpr e
t' = case typeRanges t of t' = case typeRanges t of
......
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