From 7cacb62e7b75961babba01ca4fe44bc2e552869a Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 1 Dec 2018 14:14:00 +0000 Subject: Add helper methods --- src/Test/VeriFuzz/VerilogAST.hs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/Test') diff --git a/src/Test/VeriFuzz/VerilogAST.hs b/src/Test/VeriFuzz/VerilogAST.hs index 8314acb..53efad1 100644 --- a/src/Test/VeriFuzz/VerilogAST.hs +++ b/src/Test/VeriFuzz/VerilogAST.hs @@ -1,14 +1,12 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} module Test.VeriFuzz.VerilogAST where import Control.Lens +import Data.Text as T import Data.Text (Text) -newtype NetLVal = NetLVal { _getNetLVal :: Text } - deriving (Show) -makeLenses ''NetLVal - newtype Identifier = Identifier { _getIdentifier :: Text } deriving (Show) makeLenses ''Identifier @@ -49,7 +47,7 @@ data Expression = PrimExpr Primary deriving (Show) makeLenses ''Expression -data ContAssign = ContAssign { _contAssignNetLVal :: NetLVal +data ContAssign = ContAssign { _contAssignNetLVal :: Identifier , _contAssignExpr :: Expression } deriving (Show) makeLenses ''ContAssign @@ -83,3 +81,14 @@ makeLenses ''Description newtype SourceText = SourceText { _getSourceText :: [Description] } deriving (Show) makeLenses ''SourceText + +numExpr :: Int -> Int -> Expression +numExpr = ((PrimExpr . PrimNum) .) . Number + +emptyMod :: ModuleDecl +emptyMod = + ModuleDecl (Identifier "") [] $ Assign $ ContAssign (Identifier "") $ + OpExpr (numExpr 32 0) BinAnd (numExpr 32 0) + +setModName :: Text -> ModuleDecl -> ModuleDecl +setModName str = moduleId .~ (Identifier str) -- cgit