mirror of https://github.com/zachjs/sv2v.git
added partial support for implicitly sized arrays
This commit is contained in:
parent
454afa97a3
commit
d57c967090
|
|
@ -592,6 +592,7 @@ DeclOrStmtTokens(delim) :: { [DeclToken] }
|
|||
| "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] }
|
||||
DeclOrStmtToken :: { DeclToken }
|
||||
: "," { DTComma }
|
||||
| "[" "]" { DTAutoDim }
|
||||
| PartSelect { DTRange $1 }
|
||||
| Identifier { DTIdent $1 }
|
||||
| Direction { DTDir $1 }
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import Language.SystemVerilog.AST
|
|||
-- [PUBLIC]: combined (irregular) tokens for declarations
|
||||
data DeclToken
|
||||
= DTComma
|
||||
| DTAutoDim
|
||||
| DTAsgn AsgnOp Expr
|
||||
| DTAsgnNBlk (Maybe Timing) Expr
|
||||
| DTRange (PartSelectMode, Range)
|
||||
|
|
@ -384,10 +385,22 @@ takeRanges (token : tokens) =
|
|||
case token of
|
||||
DTRange (NonIndexed, r) -> (r : rs, rest )
|
||||
DTBit s -> (asRange s : rs, rest )
|
||||
DTAutoDim ->
|
||||
case rest of
|
||||
(DTAsgn AsgnOpEq (Pattern l) : _) -> autoDim l
|
||||
(DTAsgn AsgnOpEq (Concat l) : _) -> autoDim l
|
||||
_ -> ([] , token : tokens)
|
||||
_ -> ([] , token : tokens)
|
||||
where
|
||||
(rs, rest) = takeRanges tokens
|
||||
asRange s = (Number "0", BinOp Sub s (Number "1"))
|
||||
autoDim :: [a] -> ([Range], [DeclToken])
|
||||
autoDim l =
|
||||
((lo, hi) : rs, rest)
|
||||
where
|
||||
n = length l
|
||||
lo = Number "0"
|
||||
hi = Number $ show (n - 1)
|
||||
|
||||
-- Matching DTAsgnNBlk here allows tripLookahead to work both for standard
|
||||
-- declarations and in `parseDTsAsDeclOrAsgn`, where we're checking for an
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ module top;
|
|||
logic [3:0] data;
|
||||
} packet_t;
|
||||
initial begin
|
||||
// TODO: Add support for implicitly sized arrays.
|
||||
logic [1:0] array[4] = '{ 2'b10, 2'b01, 2'b11, 2'b00 };
|
||||
logic [1:0] array[] = '{ 2'b10, 2'b01, 2'b11, 2'b00 };
|
||||
packet_t packet = {<<4{ {<<2{array}} }};
|
||||
$display("packet addr = %b", packet.addr);
|
||||
$display("packet data = %b", packet.data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue