From d5b0ff4cba238f52765c56b21c4efd01e355bb88 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 30 Nov 2018 23:30:53 +0000 Subject: Add more types --- src/Test/VeriFuzz/VerilogAST.hs | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/Test') diff --git a/src/Test/VeriFuzz/VerilogAST.hs b/src/Test/VeriFuzz/VerilogAST.hs index e4d19ec..d4514cc 100644 --- a/src/Test/VeriFuzz/VerilogAST.hs +++ b/src/Test/VeriFuzz/VerilogAST.hs @@ -4,28 +4,35 @@ module Test.VeriFuzz.VerilogAST where import Control.Lens import Data.Text (Text) -import qualified Data.Text as T -type NetLVal = Text +newtype NetLVal = NetLVal { _getNetLVal :: Text } + deriving (Show) +makeLenses ''NetLVal -type Identifier = Text +newtype Identifier = Identifier { _getIdentifier :: Text } + deriving (Show) +makeLenses ''Identifier data Number = Number { _numSize :: Int , _numVal :: Int } deriving (Show) +makeLenses ''Number data BinaryOperator = BinAnd | BinOr | BinXor deriving (Show) +makeLenses ''BinaryOperator data UnaryOperator = UnNot | UnMinus deriving (Show) +makeLenses ''UnaryOperator data Primary = PrimNum Number | PrimId Identifier deriving (Show) +makeLenses ''Primary data Expression = PrimExpr Primary | UnPrimExpr { _exprUnOp :: UnaryOperator @@ -40,34 +47,40 @@ data Expression = PrimExpr Primary , _exprFalse :: Expression } deriving (Show) +makeLenses ''Expression data ContAssign = ContAssign { _contAssignNetLVal :: NetLVal , _contAssignExpr :: Expression } deriving (Show) +makeLenses ''ContAssign data PortDir = Input | Output | InOut deriving (Show) +makeLenses ''PortDir data Port = Port { _portName :: Identifier , _portDir :: PortDir } deriving (Show) +makeLenses ''Port -type ModuleItem = Text +newtype ModuleItem = ModuleItem { _getModuleItem :: Text } + deriving (Show) +makeLenses ''ModuleItem -- | 'module' module_identifier [list_of_ports] ';' { module_item } 'end_module' data ModuleDecl = ModuleDecl { _moduleId :: Identifier , _modPorts :: [Port] , _moduleItem :: ModuleItem } deriving (Show) +makeLenses ''ModuleDecl -type Description = ModuleDecl - -type SourceText = [Description] +newtype Description = Description { _getDescription :: ModuleDecl } + deriving (Show) +makeLenses ''Description -makeLenses ''Number -makeLenses ''Expression -makeLenses ''ContAssign -makeLenses ''Port -makeLenses ''ModuleDecl +newtype SourceText = SourceText { _getSourceText :: [Description] } + deriving (Show + ) +makeLenses ''SourceText -- cgit