{-# LANGUAGE OverloadedStrings #-}
module Clash.Primitives.GHC.Word (wordTF) where
import Clash.Core.Literal (Literal(WordLiteral))
import Clash.Core.Term (Term(Literal))
import Clash.Core.Type (Type)
import Clash.Primitives.GHC.Literal
(literalTF, unsigned, unsignedLiteral, assign)
import Clash.Netlist.Types (BlackBox(BBTemplate))
import Clash.Netlist.BlackBox.Types
(BlackBoxFunction, Element(Arg, Result), emptyBlackBoxMeta
,BlackBoxMeta, bbKind, TemplateKind(TDecl))
wordTF :: BlackBoxFunction
wordTF :: BlackBoxFunction
wordTF = Text
-> (Bool -> [Either Term Type] -> Int -> (BlackBoxMeta, BlackBox))
-> BlackBoxFunction
literalTF "GHC.Word.W" Bool -> [Either Term Type] -> Int -> (BlackBoxMeta, BlackBox)
wordTF'
wordTF'
:: Bool
-> [Either Term Type]
-> Int
-> (BlackBoxMeta, BlackBox)
wordTF' :: Bool -> [Either Term Type] -> Int -> (BlackBoxMeta, BlackBox)
wordTF' False [Left (Literal (WordLiteral n :: Integer
n))] wordSize :: Int
wordSize =
( BlackBoxMeta
emptyBlackBoxMeta
, BlackBoxTemplate -> BlackBox
BBTemplate [Int -> Integer -> Element
unsignedLiteral Int
wordSize Integer
n])
wordTF' True [Left (Literal (WordLiteral n :: Integer
n))] wordSize :: Int
wordSize =
( BlackBoxMeta
emptyBlackBoxMeta
, BlackBoxTemplate -> BlackBox
BBTemplate (Element -> BlackBoxTemplate -> BlackBoxTemplate
assign (Bool -> Element
Result Bool
False) [Int -> Integer -> Element
unsignedLiteral Int
wordSize Integer
n]))
wordTF' _isDecl :: Bool
_isDecl _args :: [Either Term Type]
_args _wordSize :: Int
_wordSize =
( BlackBoxMeta
emptyBlackBoxMeta {bbKind :: TemplateKind
bbKind = TemplateKind
TDecl }
, BlackBoxTemplate -> BlackBox
BBTemplate (Element -> BlackBoxTemplate -> BlackBoxTemplate
assign (Bool -> Element
Result Bool
False) (Element -> BlackBoxTemplate
unsigned (Bool -> Int -> Element
Arg Bool
False 0))))