mirror of https://github.com/zachjs/sv2v.git
support for indexed part select in first procedural Stmt
This commit is contained in:
parent
9b51d7566b
commit
dca3a55fa6
|
|
@ -402,7 +402,7 @@ DeclOrStmtTokens(delim) :: { [DeclToken] }
|
||||||
| "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] }
|
| "<=" opt(DelayOrEventControl) Expr delim { [DTAsgnNBlk $2 $3] }
|
||||||
DeclOrStmtToken :: { DeclToken }
|
DeclOrStmtToken :: { DeclToken }
|
||||||
: "," { DTComma }
|
: "," { DTComma }
|
||||||
| Range { DTRange $1 }
|
| PartSelect { DTRange $1 }
|
||||||
| Identifier { DTIdent $1 }
|
| Identifier { DTIdent $1 }
|
||||||
| Direction { DTDir $1 }
|
| Direction { DTDir $1 }
|
||||||
| "[" Expr "]" { DTBit $2 }
|
| "[" Expr "]" { DTBit $2 }
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ data DeclToken
|
||||||
= DTComma
|
= DTComma
|
||||||
| DTAsgn AsgnOp Expr
|
| DTAsgn AsgnOp Expr
|
||||||
| DTAsgnNBlk (Maybe Timing) Expr
|
| DTAsgnNBlk (Maybe Timing) Expr
|
||||||
| DTRange Range
|
| DTRange (PartSelectMode, Range)
|
||||||
| DTIdent Identifier
|
| DTIdent Identifier
|
||||||
| DTDir Direction
|
| DTDir Direction
|
||||||
| DTType (Signing -> [Range] -> Type)
|
| DTType (Signing -> [Range] -> Type)
|
||||||
|
|
@ -137,7 +137,8 @@ parseDTsAsIntantiations (DTIdent name : tokens) =
|
||||||
where
|
where
|
||||||
(inst, toks') = span (DTComma /=) toks
|
(inst, toks') = span (DTComma /=) toks
|
||||||
(x, mr, p) = case inst of
|
(x, mr, p) = case inst of
|
||||||
[DTIdent a, DTRange s, DTInstance b] -> (a, Just s , b)
|
[DTIdent a, DTRange (NonIndexed, s), DTInstance b] ->
|
||||||
|
(a, Just s , b)
|
||||||
[DTIdent a, DTInstance b] -> (a, Nothing, b)
|
[DTIdent a, DTInstance b] -> (a, Nothing, b)
|
||||||
_ -> error $ "unrecognized instantiation: " ++ show inst
|
_ -> error $ "unrecognized instantiation: " ++ show inst
|
||||||
follow = x `seq` if null toks' then [] else step (tail toks')
|
follow = x `seq` if null toks' then [] else step (tail toks')
|
||||||
|
|
@ -235,7 +236,7 @@ takeLHSStep :: Maybe LHS -> DeclToken -> Maybe LHS
|
||||||
takeLHSStep (Nothing ) (DTConcat lhss) = Just $ LHSConcat lhss
|
takeLHSStep (Nothing ) (DTConcat lhss) = Just $ LHSConcat lhss
|
||||||
takeLHSStep (Nothing ) (DTIdent x ) = Just $ LHSIdent x
|
takeLHSStep (Nothing ) (DTIdent x ) = Just $ LHSIdent x
|
||||||
takeLHSStep (Just curr) (DTBit e ) = Just $ LHSBit curr e
|
takeLHSStep (Just curr) (DTBit e ) = Just $ LHSBit curr e
|
||||||
takeLHSStep (Just curr) (DTRange r ) = Just $ LHSRange curr NonIndexed r
|
takeLHSStep (Just curr) (DTRange (m,r)) = Just $ LHSRange curr m r
|
||||||
takeLHSStep (Just curr) (DTDot x ) = Just $ LHSDot curr x
|
takeLHSStep (Just curr) (DTDot x ) = Just $ LHSDot curr x
|
||||||
takeLHSStep (maybeCurr) token =
|
takeLHSStep (maybeCurr) token =
|
||||||
error $ "unexpected token in LHS: " ++ show (maybeCurr, token)
|
error $ "unexpected token in LHS: " ++ show (maybeCurr, token)
|
||||||
|
|
@ -323,7 +324,7 @@ takeRanges :: [DeclToken] -> ([Range], [DeclToken])
|
||||||
takeRanges [] = ([], [])
|
takeRanges [] = ([], [])
|
||||||
takeRanges (token : tokens) =
|
takeRanges (token : tokens) =
|
||||||
case token of
|
case token of
|
||||||
DTRange r -> (r : rs, rest )
|
DTRange (NonIndexed, r) -> (r : rs, rest )
|
||||||
DTBit s -> (asRange s : rs, rest )
|
DTBit s -> (asRange s : rs, rest )
|
||||||
_ -> ([] , token : tokens)
|
_ -> ([] , token : tokens)
|
||||||
where
|
where
|
||||||
|
|
@ -342,7 +343,7 @@ takeAsgn rest = (Nothing, rest)
|
||||||
takeComma :: [DeclToken] -> (Bool, [DeclToken])
|
takeComma :: [DeclToken] -> (Bool, [DeclToken])
|
||||||
takeComma [] = (False, [])
|
takeComma [] = (False, [])
|
||||||
takeComma (DTComma : rest) = (True, rest)
|
takeComma (DTComma : rest) = (True, rest)
|
||||||
takeComma _ = error "take comma encountered neither comma nor end of tokens"
|
takeComma toks = error $ "expected comma or end of decl, got: " ++ show toks
|
||||||
|
|
||||||
takeIdent :: [DeclToken] -> (Identifier, [DeclToken])
|
takeIdent :: [DeclToken] -> (Identifier, [DeclToken])
|
||||||
takeIdent (DTIdent x : rest) = (x, rest)
|
takeIdent (DTIdent x : rest) = (x, rest)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue