2019-03-23 00:24:45 +01:00
|
|
|
{- sv2v
|
|
|
|
|
- Author: Zachary Snow <zach@zachjs.com>
|
|
|
|
|
- Initial Verilog AST Author: Tom Hawkins <tomahawkins@gmail.com>
|
|
|
|
|
-
|
|
|
|
|
- This AST allows for the representation of many syntactically invalid things,
|
|
|
|
|
- like input regs or modport declarations inside a module. Representing only
|
|
|
|
|
- syntactically valid files would make working with the AST a nightmare. We
|
|
|
|
|
- have placed an emphasis on making the conversion procedures in this project
|
|
|
|
|
- more easier to write, interpret, and maintain.
|
|
|
|
|
-
|
|
|
|
|
- In the future, we may want to have a utility which performs some basic
|
|
|
|
|
- invariant checks. I want to avoid making a full type-checker though, as we
|
|
|
|
|
- should only be given valid SystemVerilog input files.
|
|
|
|
|
-}
|
|
|
|
|
|
2019-02-08 06:19:39 +01:00
|
|
|
module Language.SystemVerilog.AST
|
2019-04-04 02:24:09 +02:00
|
|
|
( AST
|
2019-03-26 06:54:16 +01:00
|
|
|
, module Attr
|
2019-03-25 18:29:35 +01:00
|
|
|
, module Decl
|
2019-04-04 02:24:09 +02:00
|
|
|
, module Description
|
2019-03-23 00:24:45 +01:00
|
|
|
, module Expr
|
2019-04-04 02:24:09 +02:00
|
|
|
, module GenItem
|
2019-03-25 18:29:35 +01:00
|
|
|
, module LHS
|
2019-04-04 02:24:09 +02:00
|
|
|
, module ModuleItem
|
2019-03-23 00:24:45 +01:00
|
|
|
, module Op
|
2019-03-25 18:29:35 +01:00
|
|
|
, module Stmt
|
2019-03-23 00:24:45 +01:00
|
|
|
, module Type
|
2019-04-23 02:44:35 +02:00
|
|
|
, exprToLHS
|
2019-03-23 00:24:45 +01:00
|
|
|
) where
|
|
|
|
|
|
2019-03-26 06:54:16 +01:00
|
|
|
import Language.SystemVerilog.AST.Attr as Attr
|
2019-03-25 18:29:35 +01:00
|
|
|
import Language.SystemVerilog.AST.Decl as Decl
|
2019-04-04 02:24:09 +02:00
|
|
|
import Language.SystemVerilog.AST.Description as Description
|
2019-03-23 00:24:45 +01:00
|
|
|
import Language.SystemVerilog.AST.Expr as Expr
|
2019-04-04 02:24:09 +02:00
|
|
|
import Language.SystemVerilog.AST.GenItem as GenItem
|
2019-03-25 18:29:35 +01:00
|
|
|
import Language.SystemVerilog.AST.LHS as LHS
|
2019-04-04 02:24:09 +02:00
|
|
|
import Language.SystemVerilog.AST.ModuleItem as ModuleItem
|
2019-03-23 00:24:45 +01:00
|
|
|
import Language.SystemVerilog.AST.Op as Op
|
2019-03-25 18:29:35 +01:00
|
|
|
import Language.SystemVerilog.AST.Stmt as Stmt
|
2019-03-23 00:24:45 +01:00
|
|
|
import Language.SystemVerilog.AST.Type as Type
|
|
|
|
|
|
2019-02-18 09:59:17 +01:00
|
|
|
type AST = [Description]
|
2019-04-23 02:44:35 +02:00
|
|
|
|
|
|
|
|
exprToLHS :: Expr -> Maybe LHS
|
|
|
|
|
exprToLHS (Ident x ) = Just $ LHSIdent x
|
|
|
|
|
exprToLHS (Bit l e ) = do
|
|
|
|
|
l' <- exprToLHS l
|
|
|
|
|
Just $ LHSBit l' e
|
|
|
|
|
exprToLHS (Range l m r) = do
|
|
|
|
|
l' <- exprToLHS l
|
|
|
|
|
Just $ LHSRange l' m r
|
|
|
|
|
exprToLHS (Dot l x ) = do
|
|
|
|
|
l' <- exprToLHS l
|
|
|
|
|
Just $ LHSDot l' x
|
|
|
|
|
exprToLHS (Concat ls ) = do
|
|
|
|
|
ls' <- mapM exprToLHS ls
|
|
|
|
|
Just $ LHSConcat ls'
|
|
|
|
|
exprToLHS _ = Nothing
|