elucidate relationship between statement terminating EOL and advancing to keyword
This commit is contained in:
parent
8a197b25a1
commit
db6034db40
52
TODO.md
52
TODO.md
|
@ -1,30 +1,50 @@
|
||||||
# General and Planning
|
# General and Planning
|
||||||
- [ ] might need many validation phases
|
- [ ] might need many validation phases
|
||||||
- [ ] it's conceivable that one could construct a Yosys memory Cell with invalid parameters
|
- [ ] it's conceivable that one could construct a Yosys memory Cell
|
||||||
|
with invalid parameters
|
||||||
- [ ] detect mismatched sizes in assignments
|
- [ ] detect mismatched sizes in assignments
|
||||||
- [ ] need canonical form making it easy to run all these validation passes
|
- [ ] need canonical form making it easy to run all these validation
|
||||||
- [ ] are recursive slices inclusive
|
passes
|
||||||
- [ ] what are the semantics of connection `<conn-stmt>`? Where is `<conn-stmt>` employed?
|
- [ ] are recursive slices inclusive?
|
||||||
|
- [ ] what are the semantics of connection `<conn-stmt>`? Where is
|
||||||
|
`<conn-stmt>` employed?
|
||||||
- [ ] Validate that `123456789[0:9][0:8]` is valid RTLIL
|
- [ ] Validate that `123456789[0:9][0:8]` is valid RTLIL
|
||||||
- [ ] reload VSCode window
|
|
||||||
- [ ] add validation section to README
|
- [ ] add validation section to README
|
||||||
- [ ] just support Cell memV2
|
- [ ] just support Cell memV2
|
||||||
- [ ] for value, what happens if we have 0 binary digits
|
- [ ] for value, what happens if we have 0 binary digits
|
||||||
- [ ] ask ChatGPT about how to get my parser to ignore comments... - should probably wait until parser is finished before asking
|
- [ ] modify parser to ignore comments... - should probably wait until
|
||||||
- [ ] modify AST to support src tracking - needed to allow for human readable and correctable validation errors
|
parser is finished before asking
|
||||||
- [ ] you could have a concated signal that gets sliced
|
- [ ] modify AST to support src tracking - needed to allow for human
|
||||||
|
readable and correctable validation errors
|
||||||
- [ ] when writing simulator, must specify directions on cell ports
|
- [ ] when writing simulator, must specify directions on cell ports
|
||||||
- [ ] in the <process>, why are we allowed to have <assign-stmt> before and after the optional <switch> stmt?
|
- [ ] in the <process>, why are we allowed to have <assign-stmt> before
|
||||||
- [ ] make TODO file
|
and after the optional <switch> stmt?
|
||||||
- [ ] inspect Chris's mini-RTLIL
|
- [ ] inspect Chris's mini-RTLIL
|
||||||
- [ ] split/organize imports/exports by section
|
|
||||||
- [ ] add RST grammar file to repo
|
- [ ] add RST grammar file to repo
|
||||||
- [ ] figure out whitespaces
|
- [ ] name parsers so that that we know where failures occured
|
||||||
- [ ] I think only EOL terminated parsers should be responsible for pre-winding the Parsec scanner to the next non-space...
|
- [ ] may want to also derive equality statements
|
||||||
- [ ] lift grammar into prover and show that all EOL terminated parsers are either followed by EOF or a keyword such "module", "autoidx", etc
|
- [x] replace both `pEol *> pMaybeWs` and `pEol <* pMaybeWs`
|
||||||
- [ ] name parsers that that we know where failures occured?
|
with `pEolAndAdvanceToNextNonWs`
|
||||||
|
|
||||||
|
# Parser Development
|
||||||
|
- [ ] Sync
|
||||||
|
- [ ] Process
|
||||||
|
- [ ] Module
|
||||||
|
|
||||||
|
# Parser Verification
|
||||||
|
- [ ] I think only EOL terminated parsers should be responsible
|
||||||
|
for pre-winding the Parsec scanner to the next non-space...
|
||||||
|
- [ ] lift grammar into prover and show that all EOL terminated parsers
|
||||||
|
are either followed by EOF or a keyword such "module", "autoidx",
|
||||||
|
etc
|
||||||
- [ ] first, manually inspect switch parser and try and see if it
|
- [ ] first, manually inspect switch parser and try and see if it
|
||||||
can infinitely recurse... Then empirically validate against corpus
|
can infinitely recurse... Then empirically validate against
|
||||||
|
corpus
|
||||||
|
|
||||||
|
# Simulation Behavior
|
||||||
|
- [ ] Figure out the computational semantics of what it means to
|
||||||
|
sync on `high`. I already understand the computational
|
||||||
|
semantics around synchronizing on `posedge` for example...
|
||||||
|
|
||||||
# Simulation
|
# Simulation
|
||||||
- [ ] dump to VCD
|
- [ ] dump to VCD
|
||||||
|
|
|
@ -35,7 +35,10 @@ module RTLILParser.AST (
|
||||||
|
|
||||||
-- Switches
|
-- Switches
|
||||||
Switch(..), SwitchStmt(..), Case(..), CaseStmt(..), Compare(..),
|
Switch(..), SwitchStmt(..), Case(..), CaseStmt(..), Compare(..),
|
||||||
CaseBodyVariants(..), CaseBody(..)
|
CaseBodyVariants(..), CaseBody(..),
|
||||||
|
|
||||||
|
-- Syncs
|
||||||
|
Sync(..), SyncStmt(..), SyncType(..), UpdateStmt(..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Text.Read (Lexeme(Ident))
|
import Text.Read (Lexeme(Ident))
|
||||||
|
@ -128,10 +131,11 @@ data CellBodyStmt = CellBodyParameter
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
-- Processes
|
-- Processes
|
||||||
data DestSigSpec = DestSigSpec SigSpec deriving (Show)
|
-- data ProcessBody = ProcessBody [AssignStmt]
|
||||||
data SrcSigSpec = SrcSigSpec SigSpec deriving (Show)
|
|
||||||
data AssignStmt = AssignStmt DestSigSpec SrcSigSpec
|
data AssignStmt = AssignStmt DestSigSpec SrcSigSpec
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
data DestSigSpec = DestSigSpec SigSpec deriving (Show)
|
||||||
|
data SrcSigSpec = SrcSigSpec SigSpec deriving (Show)
|
||||||
|
|
||||||
-- Switches
|
-- Switches
|
||||||
data Switch = Switch SwitchStmt [Case]
|
data Switch = Switch SwitchStmt [Case]
|
||||||
|
@ -147,4 +151,18 @@ data CaseBodyVariants = CaseBodySwitchVariant Switch
|
||||||
| CaseBodyAssignVariant AssignStmt
|
| CaseBodyAssignVariant AssignStmt
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
data CaseBody = CaseBody [CaseBodyVariants] deriving (Show)
|
data CaseBody = CaseBody [CaseBodyVariants] deriving (Show)
|
||||||
|
|
||||||
-- Syncs
|
-- Syncs
|
||||||
|
data Sync = Sync SyncStmt [UpdateStmt] deriving (Show)
|
||||||
|
data SyncStmt = SigSpecPredicated SyncType SigSpec
|
||||||
|
| Global
|
||||||
|
| Init
|
||||||
|
| Always
|
||||||
|
deriving (Show)
|
||||||
|
data SyncType = Low
|
||||||
|
| High
|
||||||
|
| Posedge
|
||||||
|
| Negedge
|
||||||
|
| Edge
|
||||||
|
deriving (Show)
|
||||||
|
data UpdateStmt = UpdateStmt DestSigSpec SrcSigSpec deriving (Show)
|
|
@ -41,7 +41,10 @@ import RTLILParser.AST (
|
||||||
|
|
||||||
-- Switches
|
-- Switches
|
||||||
Switch(..), SwitchStmt(..), Case(..), CaseStmt(..), Compare(..),
|
Switch(..), SwitchStmt(..), Case(..), CaseStmt(..), Compare(..),
|
||||||
CaseBodyVariants(..), CaseBody(..)
|
CaseBodyVariants(..), CaseBody(..),
|
||||||
|
|
||||||
|
-- Syncs
|
||||||
|
Sync(..), SyncStmt(..), SyncType(..), UpdateStmt(..)
|
||||||
)
|
)
|
||||||
import RTLILParser.Primitives(
|
import RTLILParser.Primitives(
|
||||||
pWs
|
pWs
|
||||||
|
@ -50,6 +53,7 @@ import RTLILParser.Primitives(
|
||||||
,pEol
|
,pEol
|
||||||
,pOctal
|
,pOctal
|
||||||
,pEscapedChar
|
,pEscapedChar
|
||||||
|
,pEolAndAdvanceToNextNonWs
|
||||||
)
|
)
|
||||||
import Text.Parsec.Token (GenLanguageDef(caseSensitive))
|
import Text.Parsec.Token (GenLanguageDef(caseSensitive))
|
||||||
import GHC.IO.Handle.Types (Handle__(Handle__))
|
import GHC.IO.Handle.Types (Handle__(Handle__))
|
||||||
|
@ -106,17 +110,20 @@ pString =
|
||||||
|
|
||||||
-- Autoindex statements
|
-- Autoindex statements
|
||||||
pAutoIdxStmt :: Parser AutoIdxStmt
|
pAutoIdxStmt :: Parser AutoIdxStmt
|
||||||
pAutoIdxStmt = AutoIdxStmt <$> (string "autoidx" *> pWs *> pInteger <* pEol <* pMaybeWs)
|
pAutoIdxStmt = AutoIdxStmt
|
||||||
|
<$> (string "autoidx" *> pWs *>
|
||||||
|
pInteger <* pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
-- Module
|
-- Module
|
||||||
pModuleStmt :: Parser Id
|
pModuleStmt :: Parser Id
|
||||||
pModuleStmt = string "module" *> pWs *> pId <* pEol <* pMaybeWs
|
pModuleStmt = string "module" *> pWs *> pId <*
|
||||||
|
pEolAndAdvanceToNextNonWs
|
||||||
|
|
||||||
pParamStmt :: Parser ParamStmt
|
pParamStmt :: Parser ParamStmt
|
||||||
pParamStmt = ParamStmt
|
pParamStmt = ParamStmt
|
||||||
<$> (string "parameter" *> pWs *> pId <* pWs)
|
<$> (string "parameter" *> pWs *> pId <* pWs)
|
||||||
<*> optionMaybe pConstant
|
<*> optionMaybe pConstant
|
||||||
<* pEol <* pMaybeWs
|
<* pEolAndAdvanceToNextNonWs
|
||||||
|
|
||||||
pConstant :: Parser Constant
|
pConstant :: Parser Constant
|
||||||
pConstant =
|
pConstant =
|
||||||
|
@ -132,7 +139,7 @@ pAttrStmt :: Parser AttrStmt
|
||||||
pAttrStmt = AttrStmt
|
pAttrStmt = AttrStmt
|
||||||
<$> (string "attribute" *> pWs *> pId)
|
<$> (string "attribute" *> pWs *> pId)
|
||||||
<*> (pWs *> pConstant)
|
<*> (pWs *> pConstant)
|
||||||
<* pEol <* pMaybeWs
|
<* pEolAndAdvanceToNextNonWs
|
||||||
|
|
||||||
-- Signal Specifications
|
-- Signal Specifications
|
||||||
pSigSpec :: Parser SigSpec
|
pSigSpec :: Parser SigSpec
|
||||||
|
@ -169,7 +176,7 @@ pConnStmt :: Parser ConnStmt
|
||||||
pConnStmt = ConnStmt
|
pConnStmt = ConnStmt
|
||||||
<$> (string "connect" *> pWs *> pSigSpec)
|
<$> (string "connect" *> pWs *> pSigSpec)
|
||||||
<*> (pWs *> pSigSpec)
|
<*> (pWs *> pSigSpec)
|
||||||
<* pEol <* pMaybeWs
|
<* pEolAndAdvanceToNextNonWs
|
||||||
|
|
||||||
-- Wires
|
-- Wires
|
||||||
pWire :: Parser Wire
|
pWire :: Parser Wire
|
||||||
|
@ -186,7 +193,7 @@ pWireStmt =
|
||||||
<*> (WireId <$> pId)
|
<*> (WireId <$> pId)
|
||||||
<* pWs
|
<* pWs
|
||||||
<*> many pWireOption
|
<*> many pWireOption
|
||||||
<* pEol <* pMaybeWs
|
<* pEolAndAdvanceToNextNonWs
|
||||||
|
|
||||||
pWireId :: Parser WireId
|
pWireId :: Parser WireId
|
||||||
pWireId = WireId <$> pId
|
pWireId = WireId <$> pId
|
||||||
|
@ -216,7 +223,7 @@ pMemoryStmt =
|
||||||
<*> (MemoryID <$> pId)
|
<*> (MemoryID <$> pId)
|
||||||
<* pWs
|
<* pWs
|
||||||
<*> many pMemoryOption
|
<*> many pMemoryOption
|
||||||
<* pEol <* pMaybeWs
|
<* pEolAndAdvanceToNextNonWs
|
||||||
|
|
||||||
pMemoryOption :: Parser MemoryOption
|
pMemoryOption :: Parser MemoryOption
|
||||||
pMemoryOption =
|
pMemoryOption =
|
||||||
|
@ -239,7 +246,7 @@ pCellStmt = do
|
||||||
cellType <- CellType <$> pId
|
cellType <- CellType <$> pId
|
||||||
_ <- pWs
|
_ <- pWs
|
||||||
cellId <- CellId <$> pId
|
cellId <- CellId <$> pId
|
||||||
_ <- pEol <* pMaybeWs
|
_ <- pEolAndAdvanceToNextNonWs
|
||||||
return $ CellStmt cellId cellType
|
return $ CellStmt cellId cellType
|
||||||
|
|
||||||
pCellBodyStmt :: Parser CellBodyStmt
|
pCellBodyStmt :: Parser CellBodyStmt
|
||||||
|
@ -255,37 +262,33 @@ pCellBodyParameter = do
|
||||||
_ <- string "parameter" <* pWs
|
_ <- string "parameter" <* pWs
|
||||||
sign <- optionMaybe pParameterSign <* pMaybeWs
|
sign <- optionMaybe pParameterSign <* pMaybeWs
|
||||||
id <- pId
|
id <- pId
|
||||||
const <- pConstant <* pEol <* pMaybeWs
|
const <- pConstant <* pEolAndAdvanceToNextNonWs
|
||||||
return $ CellBodyParameter sign id const
|
return $ CellBodyParameter sign id const
|
||||||
|
|
||||||
pCellBodyConnect :: Parser CellBodyStmt
|
pCellBodyConnect :: Parser CellBodyStmt
|
||||||
pCellBodyConnect = do
|
pCellBodyConnect = do
|
||||||
_ <- string "connect" <* pWs
|
_ <- string "connect" <* pWs
|
||||||
id <- pId <* pWs
|
id <- pId <* pWs
|
||||||
sigSpec <- pSigSpec <* pEol <* pMaybeWs
|
sigSpec <- pSigSpec <* pEolAndAdvanceToNextNonWs
|
||||||
return $ CellConnect id sigSpec
|
return $ CellConnect id sigSpec
|
||||||
|
|
||||||
-- Processes
|
-- Processes
|
||||||
|
-- pProcessBody ::
|
||||||
|
pAssignStmt :: Parser AssignStmt
|
||||||
|
pAssignStmt = AssignStmt
|
||||||
|
<$> (string "assign" *> pWs *> pDestSigSpec)
|
||||||
|
<*> (pWs *> pSrcSigSpec <* pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
pDestSigSpec :: Parser DestSigSpec
|
pDestSigSpec :: Parser DestSigSpec
|
||||||
pDestSigSpec = DestSigSpec <$> pSigSpec
|
pDestSigSpec = DestSigSpec <$> pSigSpec
|
||||||
|
|
||||||
pSrcSigSpec :: Parser SrcSigSpec
|
pSrcSigSpec :: Parser SrcSigSpec
|
||||||
pSrcSigSpec = SrcSigSpec <$> pSigSpec
|
pSrcSigSpec = SrcSigSpec <$> pSigSpec
|
||||||
|
|
||||||
pAssignStmt :: Parser AssignStmt
|
pProcEndStmt :: Parser ()
|
||||||
pAssignStmt = AssignStmt
|
pProcEndStmt = void (string "end" <* pEolAndAdvanceToNextNonWs)
|
||||||
<$> (string "assign" *> pWs *> pDestSigSpec)
|
|
||||||
<*> (pWs *> pSrcSigSpec <* pEol <* pMaybeWs)
|
|
||||||
|
|
||||||
-- Switches
|
-- Switches
|
||||||
-- - [ ] <switch> ::= <switch-stmt> <case>* <switch-end-stmt>
|
|
||||||
-- - [ ] <switch-stmt> ::= <attr-stmt>* switch <sigspec> <eol>
|
|
||||||
-- - [ ] <case> ::= <attr-stmt>* <case-stmt> <case-body>
|
|
||||||
-- - [x] <case-stmt> ::= case <compare>? <eol>
|
|
||||||
-- - [x] <compare> ::= <sigspec> (, <sigspec>)*
|
|
||||||
-- - [ ] <case-body> ::= (<switch> | <assign-stmt>)*
|
|
||||||
-- - [ ] <switch-end-stmt> ::= end <eol>
|
|
||||||
|
|
||||||
pSwitch :: Parser Switch
|
pSwitch :: Parser Switch
|
||||||
pSwitch = Switch
|
pSwitch = Switch
|
||||||
<$> pSwitchStmt
|
<$> pSwitchStmt
|
||||||
|
@ -295,7 +298,7 @@ pSwitchStmt :: Parser SwitchStmt
|
||||||
pSwitchStmt = do
|
pSwitchStmt = do
|
||||||
attrs <- many pAttrStmt
|
attrs <- many pAttrStmt
|
||||||
_ <- string "switch" <* pWs
|
_ <- string "switch" <* pWs
|
||||||
sigspec <- pSigSpec <* pEol <* pMaybeWs
|
sigspec <- pSigSpec <* pEolAndAdvanceToNextNonWs
|
||||||
return $ SwitchStmt sigspec attrs
|
return $ SwitchStmt sigspec attrs
|
||||||
|
|
||||||
pCase :: Parser Case
|
pCase :: Parser Case
|
||||||
|
@ -309,7 +312,7 @@ pCaseStmt = CaseStmt
|
||||||
<$> (
|
<$> (
|
||||||
string "case" *> pWs
|
string "case" *> pWs
|
||||||
*> optionMaybe pCompare
|
*> optionMaybe pCompare
|
||||||
<* pEol <* pMaybeWs)
|
<* pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
pCompare :: Parser Compare
|
pCompare :: Parser Compare
|
||||||
pCompare = Compare
|
pCompare = Compare
|
||||||
|
@ -324,11 +327,21 @@ pCaseBodyVariant =
|
||||||
(CaseBodyAssignVariant <$> pAssignStmt)
|
(CaseBodyAssignVariant <$> pAssignStmt)
|
||||||
|
|
||||||
pSwitchEndStmt :: Parser ()
|
pSwitchEndStmt :: Parser ()
|
||||||
pSwitchEndStmt = void (string "end" *> pEol *> pMaybeWs)
|
pSwitchEndStmt = void (string "end" *> pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
-- Syncs
|
-- Syncs
|
||||||
|
pSyncType :: Parser SyncType
|
||||||
|
pSyncType =
|
||||||
|
(Low <$ string "low" ) <|>
|
||||||
|
(High <$ string "high" ) <|>
|
||||||
|
(Posedge <$ string "posedge" ) <|>
|
||||||
|
(Negedge <$ string "negedge" ) <|>
|
||||||
|
(Edge <$ string "edge" )
|
||||||
|
|
||||||
|
pUpdateStmt :: Parser UpdateStmt
|
||||||
|
pUpdateStmt = UpdateStmt
|
||||||
|
<$> (string "update" *> pWs *> pDestSigSpec)
|
||||||
|
<*> (pWs *> pSrcSigSpec <* pEolAndAdvanceToNextNonWs)
|
||||||
|
|
||||||
|
|
||||||
-- would correspond to `123456789[0:9][0:8]`
|
-- would correspond to `123456789[0:9][0:8]`
|
||||||
|
|
|
@ -5,6 +5,7 @@ module RTLILParser.Primitives(
|
||||||
,pEol
|
,pEol
|
||||||
,pOctal
|
,pOctal
|
||||||
,pEscapedChar
|
,pEscapedChar
|
||||||
|
,pEolAndAdvanceToNextNonWs
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad (void)
|
import Control.Monad (void)
|
||||||
|
@ -43,3 +44,6 @@ pNonWs = noneOf " \t\r\n"
|
||||||
|
|
||||||
pEol :: Parser String
|
pEol :: Parser String
|
||||||
pEol = many1 (oneOf "\r\n")
|
pEol = many1 (oneOf "\r\n")
|
||||||
|
|
||||||
|
pEolAndAdvanceToNextNonWs :: Parser ()
|
||||||
|
pEolAndAdvanceToNextNonWs = void $ pEol *> pMaybeWs
|
Loading…
Reference in a new issue