Skip to content

Commit

Permalink
add BlockAssign_ data type. prepare for AST (blockingAssignment and n…
Browse files Browse the repository at this point in the history
…onBlockingAssignment)
  • Loading branch information
kei-os committed Dec 25, 2008
1 parent c887b83 commit 3ccce36
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* NetType_, RegType_ データ型を追加。
* statementが Stmt_を返すように変更した。Stmt_を扱う準備。
* BlockAssign_型を追加。blockingAssignment, nonBlockingAssignmentを AST準備した。

2008-12-25 kei-os <[email protected]>

Expand Down
65 changes: 37 additions & 28 deletions Vparsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ data ModuleItem_ = MI_DECL String
| MI_ALWAYS Stmt_
deriving (Eq, Show)

data Stmt_ = ST_BLOCKING_ASSIGN String -- Assign_ XXX TODO : need any instance
| ST_NON_BLOCKING_ASSIGN String -- TODO : need any instance
data Stmt_ = ST_BLOCKING_ASSIGN String -- use BlockAssign_
| ST_NON_BLOCKING_ASSIGN String -- use BlockAssign_
| ST_CONTINUOUS_ASSIGN String -- [NetAssign_]
| ST_TIMING_CONTROL_STMT String -- TimingControl_
| ST_CONDITIONAL_STMT String
Expand All @@ -95,8 +95,9 @@ data SeqBlock_ = SEQ_BLOCK Stmt_ NameOfBlock_ OutputDecl_ deriving (Show) -- t
type NameOfBlock_ = String
type OutputDecl_ = String -- XXX temp

data DelayOrEvent_ = DELAY_CONTROL DelayControl_
| EVENT_CONTROL EventControl_
data DelayOrEvent_ = DE_DELAY_CONTROL DelayControl_
| DE_EVENT_CONTROL EventControl_
| DE_NIL
deriving (Show)

data DelayControl_ = DELAY_VALUE Integer deriving (Show)
Expand All @@ -118,6 +119,11 @@ data LValue_ = LV_IDENT String
| LV_CONCAT [Expr_]
deriving (Show)

data BlockAssign_ = BLOCK_ASSIGN
{ baValue_ :: LValue_
, baCtrl_ :: DelayOrEvent_
, baExpr_ :: Expr_ } deriving (Show)

------------------------------------------------------------

type Max_ = Int
Expand All @@ -130,6 +136,7 @@ type Range_ = (Max_, Min_, Width_)
data Sig_ = PORT_SIG { direction_ :: Direction_ , name_ :: [String] , range_ :: Range_ }
| NET_SIG { netType_ :: NetType_, name_ :: [String], range_ :: Range_ }
| REG_SIG { regType_ :: RegType_, name_ :: [String], range_ :: Range_ }

deriving (Eq, Show, Ord)

data Direction_ = INPUT | OUTPUT | INOUT | NONE deriving (Eq, Show, Ord)
Expand Down Expand Up @@ -543,36 +550,38 @@ commaAssignment = do { a <- comma
; b <- assignment
; return $ a ++ b } <?> "commaAssignment"

--blockingAssignment :: Parser String
blockingAssignment :: Parser Stmt_
blockingAssignment = try(do { a <- lexeme lvalue
; b <- symbol "="
; c <- expression
blockingAssignment = try(do { lv <- lexeme lvalue
; symbol "="
; expr <- expression
-- ; return $ a ++ b ++ c })
; return $ ST_BLOCKING_ASSIGN $ "ST_BLOCKING_ASSIGN:1 " }) -- XXX FIXME : temp
<|> try(do { a <- lexeme lvalue
; b <- symbol "="
; c <- lexeme delayOrEventControl
; d <- lexeme expression
; e <- semi
-- ; return $ a ++ b ++ c ++ d ++ e })
; return $ ST_BLOCKING_ASSIGN $ "ST_BLOCKING_ASSIGN:2 " }) -- FIXME : temp
-- ; return $ ST_BLOCKING_ASSIGN { baValue_ = lv, baCtrl_ = DE_NUL, baExpr_ = expr } -- XXX TODO : enable
<|> try(do { lv <- lexeme lvalue
; symbol "="
; de <- lexeme delayOrEventControl
; expr <- lexeme expression
; semi
-- ; return $ a ++ b ++ c ++ d ++ e })
; return $ ST_BLOCKING_ASSIGN $ "ST_BLOCKING_ASSIGN:2 " }) -- FIXME : temp
-- ; return $ ST_BLOCKING_ASSIGN { baValue_ = lv, baCtrl_ = de, baExpr_ = expr } -- XXX TODO : enable
<?> "blockingAssignment"

--nonBlockingAssignment :: Parser String
nonBlockingAssignment :: Parser Stmt_
nonBlockingAssignment = try(do { a <- lexeme lvalue
; b <- symbol "<="
; c <- expression
-- ; return $ a ++ b ++ c })
; return $ ST_NON_BLOCKING_ASSIGN $ "ST_NON_BLOCKING_ASSIGN:1 " }) -- FIXME : temp
<|> try(do { a <- lexeme lvalue
; b <- symbol "<="
; c <- lexeme delayOrEventControl
; d <- lexeme expression
; e <- semi
-- ; return $ a ++ b ++ c ++ d ++ e })
; return $ ST_NON_BLOCKING_ASSIGN $ "ST_NON_BLOCKING_ASSIGN:2 " }) -- FIXME : temp
nonBlockingAssignment = try(do { lv <- lexeme lvalue
; symbol "<="
; expr <- expression
-- ; return $ a ++ b ++ c })
; return $ ST_NON_BLOCKING_ASSIGN $ "ST_NON_BLOCKING_ASSIGN:1 " }) -- FIXME : temp
-- ; return $ ST_NON_BLOCKING_ASSIGN { baValue_ = lv, baCtrl_ = DE_NIL, baExpr_ = expr } -- XXX TODO : enable
<|> try(do { lv <- lexeme lvalue
; symbol "<="
; de <- lexeme delayOrEventControl
; expr <- lexeme expression
; semi
-- ; return $ a ++ b ++ c ++ d ++ e })
; return $ ST_NON_BLOCKING_ASSIGN $ "ST_NON_BLOCKING_ASSIGN:2 " }) -- FIXME : temp
-- ; return $ ST_NON_BLOCKING_ASSIGN { baValue_ = lv, baCtrl_ = de, baExpr_ = expr } -- XXX TODO : enable
<?> "nonBlockingAssignment"

--proceduralContinuousAssignments :: Parser String
Expand Down

0 comments on commit 3ccce36

Please sign in to comment.