|
1 | 1 | {-|
|
2 | 2 | Copyright : (C) 2019, Myrtle Software Ltd.
|
3 |
| - 2020-2023, QBayLogic B.V. |
| 3 | + 2020-2024, QBayLogic B.V. |
4 | 4 | 2021, Myrtle.ai
|
5 | 5 | 2022-2023, Google Inc
|
6 | 6 | License : BSD2 (see the file LICENSE)
|
@@ -127,7 +127,8 @@ import Clash.Netlist.Types hiding (Component, toBit)
|
127 | 127 | import Clash.Netlist.Util
|
128 | 128 | import Clash.Util (clogBase)
|
129 | 129 | import qualified Data.String.Interpolate as I
|
130 |
| -import Language.Haskell.TH (Name) |
| 130 | +import qualified Language.Haskell.TH as TH |
| 131 | +import qualified Language.Haskell.TH.Syntax as TH |
131 | 132 | import Prelude
|
132 | 133 |
|
133 | 134 | -- | Options for 'blackBoxHaskell' function. Use 'def' from package
|
@@ -164,9 +165,9 @@ instance Default BlackBoxHaskellOpts where
|
164 | 165 | --
|
165 | 166 | -- @[1,2]@ would mean this blackbox __ignores__ its second and third argument.
|
166 | 167 | blackBoxHaskell
|
167 |
| - :: Name |
| 168 | + :: TH.Name |
168 | 169 | -- ^ blackbox name
|
169 |
| - -> Name |
| 170 | + -> TH.Name |
170 | 171 | -- ^ template function name
|
171 | 172 | -> BlackBoxHaskellOpts
|
172 | 173 | -- ^ Options, see data structure for more information
|
@@ -649,14 +650,21 @@ constructProduct ty els =
|
649 | 650 |
|
650 | 651 | -- | Create an n-tuple of 'TExpr'
|
651 | 652 | tuple :: HasCallStack => [TExpr] -> TExpr
|
652 |
| -tuple [] = error $ "nTuple: Cannot create empty tuple" |
| 653 | +tuple [] = error $ "tuple: Cannot create empty tuple" |
653 | 654 | tuple [_] =
|
654 | 655 | -- If we don't put this in: tuple . untuple /= id
|
655 |
| - error $ "nTuple: Cannot create 1-tuple" |
| 656 | + error $ "tuple: Cannot create 1-tuple" |
656 | 657 | tuple els = constructProduct tupTy els
|
657 | 658 | where
|
658 | 659 | commas = Text.replicate (length els - 1) ","
|
659 |
| - tupTy = Product ("GHC.Tuple.(" <> commas <> ")") Nothing (map ety els) |
| 660 | + tupTy = Product (tupModule <> ".(" <> commas <> ")") Nothing (map ety els) |
| 661 | + tupModule = |
| 662 | + $( |
| 663 | + let tupNm = ''(,) |
| 664 | + in case (TH.nameModule tupNm, TH.nameBase tupNm) of |
| 665 | + (Just modNm, "(,)") -> TH.lift modNm :: TH.ExpQ |
| 666 | + _ -> error $ "tuple: (,) has an unexpected name: " <> show tupNm |
| 667 | + ) |
660 | 668 |
|
661 | 669 | -- | Try to get the literal string value of an expression.
|
662 | 670 | getStr :: TExpr -> Maybe String
|
|
0 commit comments