Commit db4c3963 by Zachary Snow

minor multi-packed verbosity improvement

parent 8f2d7dd5
...@@ -93,8 +93,8 @@ combineRanges r1 r2 = r ...@@ -93,8 +93,8 @@ combineRanges r1 r2 = r
combine (s1, e1) (s2, e2) = combine (s1, e1) (s2, e2) =
(simplify upper, simplify lower) (simplify upper, simplify lower)
where where
size1 = rangeSize (s1, e1) size1 = rangeSizeHiLo (s1, e1)
size2 = rangeSize (s2, e2) size2 = rangeSizeHiLo (s2, e2)
lower = BinOp Add e2 (BinOp Mul e1 size2) lower = BinOp Add e2 (BinOp Mul e1 size2)
upper = BinOp Add (BinOp Mul size1 size2) upper = BinOp Add (BinOp Mul size1 size2)
(BinOp Sub lower (Number "1")) (BinOp Sub lower (Number "1"))
......
...@@ -19,6 +19,7 @@ module Language.SystemVerilog.AST.Expr ...@@ -19,6 +19,7 @@ module Language.SystemVerilog.AST.Expr
, showExprOrRange , showExprOrRange
, simplify , simplify
, rangeSize , rangeSize
, rangeSizeHiLo
, endianCondExpr , endianCondExpr
, endianCondRange , endianCondRange
, dimensionsSize , dimensionsSize
...@@ -274,8 +275,12 @@ rangeSize :: Range -> Expr ...@@ -274,8 +275,12 @@ rangeSize :: Range -> Expr
rangeSize (s, e) = rangeSize (s, e) =
endianCondExpr (s, e) a b endianCondExpr (s, e) a b
where where
a = simplify $ BinOp Add (BinOp Sub s e) (Number "1") a = rangeSizeHiLo (s, e)
b = simplify $ BinOp Add (BinOp Sub e s) (Number "1") b = rangeSizeHiLo (e, s)
rangeSizeHiLo :: Range -> Expr
rangeSizeHiLo (hi, lo) =
simplify $ BinOp Add (BinOp Sub hi lo) (Number "1")
-- chooses one or the other expression based on the endianness of the given -- chooses one or the other expression based on the endianness of the given
-- range; [hi:lo] chooses the first expression -- range; [hi:lo] chooses the first expression
......
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