Commit e62074c7 by Zachary Snow

type operator full select support

parent 22d6ba49
...@@ -125,14 +125,6 @@ convertBits (Right e) = ...@@ -125,14 +125,6 @@ convertBits (Right e) =
foldl (BinOp Add) (Number "0") $ foldl (BinOp Add) (Number "0") $
map (convertBits . Right) $ map (convertBits . Right) $
exprs 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 Stream _ _ exprs -> convertBits $ Right $ Concat exprs
Number n -> Number n ->
case elemIndex '\'' n of case elemIndex '\'' n of
......
...@@ -73,9 +73,22 @@ typeof (orig @ (Ident x)) = do ...@@ -73,9 +73,22 @@ typeof (orig @ (Ident x)) = do
typeof (orig @ (Call (Ident x) _)) = do typeof (orig @ (Call (Ident x) _)) = do
res <- gets $ Map.lookup x res <- gets $ Map.lookup x
return $ fromMaybe (TypeOf orig) res return $ fromMaybe (TypeOf orig) res
typeof (orig @ (Bit (Ident x) _)) = do typeof (orig @ (Bit e _)) = do
res <- gets $ Map.lookup x t <- typeof e
return $ maybe (TypeOf orig) popRange res 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 typeof other = return $ TypeOf other
-- combines a type with unpacked ranges -- combines a type with unpacked ranges
...@@ -84,8 +97,17 @@ injectRanges t [] = t ...@@ -84,8 +97,17 @@ injectRanges t [] = t
injectRanges (UnpackedType t rs) unpacked = UnpackedType t $ unpacked ++ rs injectRanges (UnpackedType t rs) unpacked = UnpackedType t $ unpacked ++ rs
injectRanges t unpacked = UnpackedType t unpacked 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 :: Type -> Type
popRange (UnpackedType t [_]) = t
popRange t = popRange t =
tf $ tail rs tf $ tail rs
where (tf, rs) = typeRanges t 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; ...@@ -23,6 +23,9 @@ module top;
$display($bits(foo)); $display($bits(foo));
`EXHAUST(Ram); `EXHAUST(Ram);
`EXHAUST(Ram[0+:2]);
`EXHAUST(Ram[1+:2]);
`EXHAUST(Ram[0][2-:1]);
`EXHAUST(RamPair); `EXHAUST(RamPair);
`EXHAUST(RamPair[0]); `EXHAUST(RamPair[0]);
`EXHAUST(Word); `EXHAUST(Word);
......
...@@ -15,6 +15,36 @@ module top; ...@@ -15,6 +15,36 @@ module top;
$display(1); $display(1);
$display(160); $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(2, 2, 10);
$display(0, 0, 0); $display(0, 0, 0);
$display(1, 1, 9); $display(1, 1, 9);
......
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