mirror of https://github.com/zachjs/sv2v.git
assume 0-based sized ranges are non-negative
This commit is contained in:
parent
2429a2c9f0
commit
8a8b089a92
|
|
@ -178,6 +178,7 @@ rangeSizeHiLo (hi, lo) =
|
||||||
-- 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
|
||||||
endianCondExpr :: Range -> Expr -> Expr -> Expr
|
endianCondExpr :: Range -> Expr -> Expr -> Expr
|
||||||
|
endianCondExpr SizedRange{} e _ = e
|
||||||
endianCondExpr r e1 e2 = simplify $ Mux (uncurry (BinOp Ge) r) e1 e2
|
endianCondExpr r e1 e2 = simplify $ Mux (uncurry (BinOp Ge) r) e1 e2
|
||||||
|
|
||||||
-- chooses one or the other range based on the endianness of the given range,
|
-- chooses one or the other range based on the endianness of the given range,
|
||||||
|
|
@ -197,3 +198,8 @@ dimensionsSize ranges =
|
||||||
foldl (BinOp Mul) (RawNum 1) $
|
foldl (BinOp Mul) (RawNum 1) $
|
||||||
map rangeSize $
|
map rangeSize $
|
||||||
ranges
|
ranges
|
||||||
|
|
||||||
|
-- "sized ranges" are of the form [E-1:0], where E is any expression; in most
|
||||||
|
-- designs, we can safely assume that E >= 1, allowing for more succinct output
|
||||||
|
pattern SizedRange :: Expr -> Range
|
||||||
|
pattern SizedRange expr = (BinOp Sub expr (RawNum 1), RawNum 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue