never executed always true always false
    1 {-# LANGUAGE OverloadedStrings #-}
    2 {-# LANGUAGE NoMonomorphismRestriction #-}
    3 
    4 {- |
    5 Module      : NITTA.Project.Context
    6 Description : Context for project template
    7 Copyright   : (c) Aleksandr Penskoi, 2021
    8 License     : BSD3
    9 Maintainer  : aleksandr.penskoi@gmail.com
   10 Stability   : experimental
   11 -}
   12 module NITTA.Project.Context (
   13     projectContext,
   14     implementationContext,
   15 ) where
   16 
   17 import Data.Text qualified as T
   18 import NITTA.Project.TestBench
   19 import NITTA.Project.Types
   20 import NITTA.Utils
   21 import Text.Ginger
   22 
   23 nittaContextDict
   24     prj@Project
   25         { pName
   26         , pUnit
   27         , pUnitEnv
   28         , pTargetProjectPath
   29         , pInProjectNittaPath
   30         , pAbsTargetProjectPath
   31         , pAbsNittaPath
   32         } =
   33         dict
   34             [ ("instance", toGVal $ doc2text $ hardwareInstance (moduleName pName pUnit) pUnit pUnitEnv)
   35             ,
   36                 ( "paths"
   37                 , dict
   38                     [ ("abs_project", toGVal pAbsTargetProjectPath)
   39                     , ("project", toGVal pTargetProjectPath)
   40                     , ("abs_nitta", toGVal pAbsNittaPath)
   41                     , ("nitta", toGVal pInProjectNittaPath)
   42                     ]
   43                 )
   44             , ("files", toGVal $ verilogProjectFiles prj)
   45             ,
   46                 ( "testbench"
   47                 , dict
   48                     [ ("module_name", toGVal $ testBenchTopModuleName prj)
   49                     ]
   50                 )
   51             ]
   52 
   53 -- | projectContext - used for template generation
   54 projectContext prj = makeContextText $ \case
   55     "nitta" -> nittaContextDict prj
   56     unknown -> error $ "template error, variable '" <> T.unpack unknown <> "' not defined (see 'NITTA.Project.Template')"
   57 
   58 -- | projectContext - used for Implementation generation
   59 implementationContext prj nest = makeContextText $ \case
   60     "nitta" -> nittaContextDict prj
   61     "impl" -> dict [("paths", dict [("nest", toGVal nest)])]
   62     unknown -> error $ "template error, variable '" <> T.unpack unknown <> "' not defined (see 'NITTA.Project.Template')"