mirror of https://github.com/zachjs/sv2v.git
type operator full select support
This commit is contained in:
parent
22d6ba4927
commit
e62074c756
|
|
@ -125,14 +125,6 @@ convertBits (Right e) =
|
|||
foldl (BinOp Add) (Number "0") $
|
||||
map (convertBits . Right) $
|
||||
exprs
|
||||
Range expr mode range ->
|
||||
simplify $ BinOp Mul size
|
||||
(convertBits $ Right $ Bit expr (Number "0"))
|
||||
where
|
||||
size = case mode of
|
||||
NonIndexed -> rangeSize range
|
||||
IndexedPlus -> snd range
|
||||
IndexedMinus -> snd range
|
||||
Stream _ _ exprs -> convertBits $ Right $ Concat exprs
|
||||
Number n ->
|
||||
case elemIndex '\'' n of
|
||||
|
|
|
|||
|
|
@ -73,9 +73,22 @@ typeof (orig @ (Ident x)) = do
|
|||
typeof (orig @ (Call (Ident x) _)) = do
|
||||
res <- gets $ Map.lookup x
|
||||
return $ fromMaybe (TypeOf orig) res
|
||||
typeof (orig @ (Bit (Ident x) _)) = do
|
||||
res <- gets $ Map.lookup x
|
||||
return $ maybe (TypeOf orig) popRange res
|
||||
typeof (orig @ (Bit e _)) = do
|
||||
t <- typeof e
|
||||
return $ case t of
|
||||
TypeOf _ -> TypeOf orig
|
||||
_ -> popRange t
|
||||
typeof (orig @ (Range e mode r)) = do
|
||||
t <- typeof e
|
||||
return $ case t of
|
||||
TypeOf _ -> TypeOf orig
|
||||
_ -> replaceRange (lo, hi) t
|
||||
where
|
||||
lo = fst r
|
||||
hi = case mode of
|
||||
NonIndexed -> snd r
|
||||
IndexedPlus -> BinOp Sub (uncurry (BinOp Add) r) (Number "1")
|
||||
IndexedMinus -> BinOp Add (uncurry (BinOp Sub) r) (Number "1")
|
||||
typeof other = return $ TypeOf other
|
||||
|
||||
-- combines a type with unpacked ranges
|
||||
|
|
@ -84,8 +97,17 @@ injectRanges t [] = t
|
|||
injectRanges (UnpackedType t rs) unpacked = UnpackedType t $ unpacked ++ rs
|
||||
injectRanges t unpacked = UnpackedType t unpacked
|
||||
|
||||
-- removes the outermost range of the given type
|
||||
-- removes the most significant range of the given type
|
||||
popRange :: Type -> Type
|
||||
popRange (UnpackedType t [_]) = t
|
||||
popRange t =
|
||||
tf $ tail rs
|
||||
where (tf, rs) = typeRanges t
|
||||
|
||||
-- replaces the most significant range of the given type
|
||||
replaceRange :: Range -> Type -> Type
|
||||
replaceRange r (UnpackedType t (_ : rs)) =
|
||||
UnpackedType t (r : rs)
|
||||
replaceRange r t =
|
||||
tf $ r : tail rs
|
||||
where (tf, rs) = typeRanges t
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ module top;
|
|||
$display($bits(foo));
|
||||
|
||||
`EXHAUST(Ram);
|
||||
`EXHAUST(Ram[0+:2]);
|
||||
`EXHAUST(Ram[1+:2]);
|
||||
`EXHAUST(Ram[0][2-:1]);
|
||||
`EXHAUST(RamPair);
|
||||
`EXHAUST(RamPair[0]);
|
||||
`EXHAUST(Word);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,36 @@ module top;
|
|||
$display(1);
|
||||
$display(160);
|
||||
|
||||
$display(2, 2, 16);
|
||||
$display(0, 0, 16);
|
||||
$display(1, 1, 1);
|
||||
$display(1, 1, 16);
|
||||
$display(0, 0, 1);
|
||||
$display(-1, -1, 1);
|
||||
$display(2);
|
||||
$display(1);
|
||||
$display(32);
|
||||
|
||||
$display(2, 2, 16);
|
||||
$display(1, 1, 16);
|
||||
$display(2, 2, 1);
|
||||
$display(2, 2, 16);
|
||||
$display(1, 1, 1);
|
||||
$display(-1, -1, 1);
|
||||
$display(2);
|
||||
$display(1);
|
||||
$display(32);
|
||||
|
||||
$display(1, 1, 1'bx);
|
||||
$display(2, 2, 1'bx);
|
||||
$display(2, 2, 1'bx);
|
||||
$display(2, 2, 1'bx);
|
||||
$display(2, 2, 1'bx);
|
||||
$display(1, 1, 1'bx);
|
||||
$display(1);
|
||||
$display(0);
|
||||
$display(1);
|
||||
|
||||
$display(2, 2, 10);
|
||||
$display(0, 0, 0);
|
||||
$display(1, 1, 9);
|
||||
|
|
|
|||
Loading…
Reference in New Issue