now parsing memory statements
This commit is contained in:
parent
cbbc7e73bd
commit
38fb13556f
6 changed files with 103 additions and 24 deletions
|
@ -7,11 +7,14 @@ import Control.Monad (void)
|
|||
import Text.Parsec
|
||||
import Text.Parsec.String (Parser)
|
||||
import RTLILParser.AST(
|
||||
AutoIdxStmt(..), ParamStmt(..), AutogenId(..),
|
||||
Constant(..), CellStmt(..), PublicId(..),
|
||||
AttrStmt(..), Value(..), Id(..),
|
||||
CellId(..), CellType(..), WireId(..),
|
||||
SigSpec(..), Slice(..)
|
||||
AutoIdxStmt(..) ,ParamStmt(..) ,AutogenId(..)
|
||||
,Constant(..) ,CellStmt(..) ,PublicId(..)
|
||||
,AttrStmt(..) ,Value(..) ,Id(..)
|
||||
,CellId(..) ,CellType(..) ,WireId(..)
|
||||
,SigSpec(..) ,Slice(..) ,ConnStmt(..)
|
||||
,WireOption(..) ,WireStmt(..) ,Wire(..)
|
||||
,MemoryOption(..) ,MemoryStmt(..) ,Memory(..)
|
||||
,MemoryID(..)
|
||||
)
|
||||
import Util(binaryStringToInt)
|
||||
import RTLILParser.Primitives(pEscapedChar)
|
||||
|
@ -141,6 +144,59 @@ pSigSpec =
|
|||
try pSigSpecConcat -- Check for concatenation first
|
||||
<|> pSingleSigSpec -- Otherwise parse a single sigspec
|
||||
|
||||
pConnStmt :: Parser ConnStmt
|
||||
pConnStmt = ConnStmt
|
||||
<$> (string "connect" *> pWs *> pSigSpec)
|
||||
<*> (pWs *> pSigSpec)
|
||||
<* pEol
|
||||
|
||||
pWireOption :: Parser WireOption
|
||||
pWireOption =
|
||||
try (WireOptionWidth <$> (string "width" *> pWs *> pInteger)) <|>
|
||||
try (WireOptionOffset <$> (string "offset" *> pWs *> pInteger)) <|>
|
||||
try (WireOptionInput <$> (string "input" *> pWs *> pInteger)) <|>
|
||||
try (WireOptionOutput <$> (string "output" *> pWs *> pInteger)) <|>
|
||||
try (WireOptionInout <$> (string "inout" *> pWs *> pInteger)) <|>
|
||||
(string "upto" *> return WireOptionUpto) <|>
|
||||
(string "signed" *> return WireOptionSigned)
|
||||
|
||||
pWireStmt :: Parser WireStmt
|
||||
pWireStmt =
|
||||
WireStmt
|
||||
<$ string "wire"
|
||||
<* pWs
|
||||
<*> (WireId <$> pId)
|
||||
<* pWs
|
||||
<*> many pWireOption
|
||||
<* pEol
|
||||
|
||||
pWire :: Parser Wire
|
||||
pWire = do
|
||||
attrs <- many pAttrStmt
|
||||
wireStmt <- pWireStmt
|
||||
return $ Wire wireStmt attrs
|
||||
|
||||
pMemoryOption :: Parser MemoryOption
|
||||
pMemoryOption =
|
||||
try (MemoryOptionWidth <$> (string "width" *> pWs *> pInteger)) <|>
|
||||
try (MemoryOptionSize <$> (string "size" *> pWs *> pInteger)) <|>
|
||||
try (MemoryOptionOffset <$> (string "offset" *> pWs *> pInteger))
|
||||
|
||||
pMemoryStmt :: Parser MemoryStmt
|
||||
pMemoryStmt =
|
||||
MemoryStmt
|
||||
<$ string "memory"
|
||||
<* pWs
|
||||
<*> (MemoryID <$> pId)
|
||||
<* pWs
|
||||
<*> many pMemoryOption
|
||||
<* pEol
|
||||
|
||||
pMemory :: Parser Memory
|
||||
pMemory = do
|
||||
attrs <- many pAttrStmt
|
||||
memoryStmt <- pMemoryStmt
|
||||
return $ Memory memoryStmt attrs
|
||||
|
||||
-- would correspond to `123456789[0:9][0:8]`
|
||||
exampleSigSpecSlice =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue